Git Product home page Git Product logo

Comments (4)

jonschlinkert avatar jonschlinkert commented on May 29, 2024 1

I'm updating some things in cache-base now.

I think it should be a new method if we're going to still allow passing in multiple arguments to create the key:

I think we should just remove support for passing multiple arguments, and passing keys as an array, and just support strings. I've never really liked this feature, for the types of reasons you're pointing out. Currently, if the key is passed as more than one argument or an array of segments, it's joined into a dot-notated string anyway, which makes it hard to see the point of supporting that. In earlier versions of js, it was nice to be able to dynamically build up keys that way, but it's not necessary and complicates the code.

Closing, I don't think we'll add support for this, but I might want to add support for a similar feature using a different method.

from cache-base.

tunnckoCore avatar tunnckoCore commented on May 29, 2024

Good idea. 👍

from cache-base.

doowb avatar doowb commented on May 29, 2024

I like this idea, but I think it should be a new method if we're going to still allow passing in multiple arguments to create the key:

app.get('foo', 'bar', 'baz');

That's a complicated case to figure out (e.g. is it using 'baz' as the default for foo.bar or the getting the value for foo.bar.baz).

Something like app.getDefault() or app.default() might be good and it will indicate that the last value will always be the default if a value doesn't exist for the key created using the rest of the arguments.

The other option is to only allow 2 arguments to .get where the first argument may be a string or an array and the second is the default value. I think this is how we use .get most of the time anyway.

from cache-base.

tunnckoCore avatar tunnckoCore commented on May 29, 2024

I think this is how we use .get most of the time anyway.

Exactly, it's enough. Otherwise going to be too complicated.

from cache-base.

Related Issues (16)

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.