Giter Club home page Giter Club logo

Comments (1)

rvagg avatar rvagg commented on May 16, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.