yeoman / configstore

Easily load and persist config without having to think about where and how
BSD 2-Clause "Simplified" License
868 stars 56 forks source link

Inclusion of setPlain() and getPlain() for non-dotProp keys #39

Closed dsl101 closed 8 years ago

dsl101 commented 8 years ago

I'm using CIDRs as config keys, and it makes less sense to use dotProp to set / get. I toyed with adding an option to specify whether to use dotProp or not, but in the end it was easier to add 2 new methods and use those to store plain strings with dots in the keys:

Configstore.prototype.setPlain = function (key, val) {
    var config = this.all;
    if (arguments.length === 1) {
        Object.keys(key).forEach(function (k) {
            config[k] = key[k];
        });
    } else {
        config[key] = val;
    }
    this.all = config;
};

and its counterpart:

Configstore.prototype.getPlain = function (key) {
    return this.all[key];
};

Might be useful to someone. I'm newish to github - should I fork the project, make the change and then create a pull request? Seems a lot of admin for 2 simple additions, but let me know..

Tx

sindresorhus commented 8 years ago

Thanks for the suggestion, but not something we're interested in.