Comments (1)
I've been using sublevel and have come around to the approach for extending levelup, but it's still not quite enough, what I really want is something between hooks and the approach I outlined in #97. Perhaps hooks can be adapted though.
So, what I really want is to be able to intercept calls in the middle of the original LevelUP method. Lets say I want to intercept all put()
calls and write some special entries based on the key and/or value (in a sublevel). But, there's a couple of barriers: if I monkey-patch then I have to deal with the optional arguments bit and also the encoding. Say I want to take the key and use it to insert some other key into a sublevel based on it and also based on something special in the options
that may or may not have been passed to the method. First I have to do the same thing that LevelUP already does to find the options
argument and decode it (e.g. it could just be a string which would be turned in to 'valueEncoding'
). Then I have to encode the key, perhaps they are doing JSON encoding on keys, I'll need to do the same thing in order to have enough information to proceed. After all that I need to make sure I pass the originals back to LevelUP.
I don't believe level-hooks does enough of this to help, perhaps it can be adapted to do so? What I want is something like what the externr code was doing by giving me an injection point right in the middle of the method where I can have the encoded key and value and even the internal options object.
How can we have it all?
from community.
Related Issues (20)
- Proposal: add map method to abstract-down HOT 4
- Add `db.getMany(keys)` across the board HOT 8
- Refactor encodings HOT 6
- `rocksdb`: to be ported from `leveldown` (after other recent PRs)
- Fix Typings on DefinitelyTyped HOT 7
- Proposal: Add `db.has(key)` and `db.hasMany(keys)` HOT 12
- Deprecate old modules
- Package level with electron HOT 2
- Redisdown: how to create new `level-` libs? HOT 1
- Replace Sauce Labs with Playwright HOT 3
- Tracking issue: implicit and explicit snapshots
- willing to help revive some databases with abstract-level api HOT 4
- rocks-level implementation HOT 6
- Switch to dependabot HOT 9
- Dump Buffer for TypedArrays (for compactness and efficiency) HOT 6
- Any interest in maintaining 'lmdb'? HOT 3
- Counting entries in a level database HOT 4
- leveldown to remote database HOT 1
- Maintenance round: drop legacy features & runtime environments HOT 1
- Move to GitHub Actions HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from community.