Giter VIP home page Giter VIP logo

Comments (9)

alevy avatar alevy commented on September 1, 2024

Yes, flags are a pretty useful feature. It's on the TODO (in README.md) list but I never got around to it, thanks for the kick in the butt

from memjs.

dblock avatar dblock commented on September 1, 2024

Yeah, what am I paying you for? :-)

from memjs.

alevy avatar alevy commented on September 1, 2024

OK, I'm looking at doing this right now. The biggest question is where should the argument go such that I don't break people's existing code in some hard to debug way. The current signature for set is:

set(key, value, callback, expires)

Where expires was added at the end specifically for this reason. An obvious option is to stick flags at the end again, but this starts to seem ugly (why isn't the callback last?). Two alternatives come to mind:

  1. Phase out the current interface and opt for a jQuery dictionary style argument to set et al.
  2. Do the hack where we look at the type of the arguments and use that to simulate method overloading.
  3. Some combination of (1) and (2) where we support the legacy interface by looking at the types, but if the first parameter is a dictionary, use (1) instead.

Thoughts? Other suggestions?

from memjs.

reubano avatar reubano commented on September 1, 2024

You haven't reached 1.0 yet so breaking charges are still allowed. 1) seems the cleanest, but you can try 3) with a deprecation warning if a dictionary isn't used.

from memjs.

alevy avatar alevy commented on September 1, 2024

OK, I buy that. People are using it in production, nontheless, so I'd rather not totally break API, but 3 with a deprecation warning makes sense. Does a dictionary in fact seem like a decent API? In jQuery, for example, they use that API under the hood, but have higher level functions take regular arguments. I suspect because the dictionary can be cumbersome for sequencing callbacks...

from memjs.

dblock avatar dblock commented on September 1, 2024

And be aware that npm gets you new versions by default. Not everybody is disciplined enough to npm shrinkwrap and what not.

from memjs.

reubano avatar reubano commented on September 1, 2024

Most of the other libs I've used take a dict options = {some: 'some', dict: 'dict'} for the initial setup, i.e., new winston.transports.File options and sometimes have it as the first argument, i.e., request options callback. Can you give an example of how callback sequencing gets cumbersome?

from memjs.

alevy avatar alevy commented on September 1, 2024

Ah, no that seems fine. At the moment newer arguments have been stuck on after the callback to maintain backwards-compatability. The way you are suggesting doesn't make chaining harder at all

from memjs.

alevy avatar alevy commented on September 1, 2024

Duplicate of #53

from memjs.

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.