config-cache
Advanced tools
Comparing version 6.0.0 to 6.0.1
62
index.js
@@ -14,9 +14,9 @@ 'use strict'; | ||
var omit = lazy('object.omit'); | ||
var typeOf = lazy('kind-of'); | ||
var extend = lazy('extend-shallow'); | ||
var flatten = lazy('arr-flatten'); | ||
var union = lazy('array-union'); | ||
var set = lazy('set-value'); | ||
var get = lazy('get-value'); | ||
lazy('object.omit', 'omit'); | ||
lazy('kind-of', 'typeOf'); | ||
lazy('extend-shallow', 'extend'); | ||
lazy('arr-flatten', 'flatten'); | ||
lazy('array-union', 'union'); | ||
lazy('set-value', 'set'); | ||
lazy('get-value', 'get'); | ||
@@ -28,3 +28,3 @@ /** | ||
* ```js | ||
* var cache = new Config(); | ||
* var config = new Config(); | ||
* ``` | ||
@@ -84,6 +84,6 @@ * @param {Object} `cache` | ||
Config.prototype.set = function(key, value) { | ||
if (arguments.length === 1 && typeOf()(key) === 'object') { | ||
if (arguments.length === 1 && lazy.typeOf(key) === 'object') { | ||
this.extend(key); | ||
} else { | ||
set()(this.cache, key, value); | ||
lazy.set(this.cache, key, value); | ||
} | ||
@@ -116,35 +116,6 @@ this.emit('set', key, value); | ||
Config.prototype.get = function(key, escape) { | ||
return key ? get()(this.cache, key, escape) : this.cache; | ||
return key ? lazy.get(this.cache, key, escape) : this.cache; | ||
}; | ||
/** | ||
* Create a constant (getter/setter) for setting and getting values | ||
* on the given `namespace` or `this.cache`. | ||
* | ||
* ```js | ||
* config.constant('site.title', 'Foo'); | ||
* ``` | ||
* | ||
* @param {String} `key` | ||
* @param {*} `value` | ||
* @chainable | ||
* @api public | ||
*/ | ||
Config.prototype.constant = function(key, value, namespace) { | ||
var getter; | ||
if (typeof value !== 'function'){ | ||
getter = function() { | ||
return value; | ||
}; | ||
} else { | ||
getter = value; | ||
} | ||
namespace = namespace || 'cache'; | ||
this[namespace] = this[namespace] || {}; | ||
this[namespace].__defineGetter__(key, getter); | ||
return this; | ||
}; | ||
/** | ||
* Add values to an array on the `cache`. | ||
@@ -176,3 +147,3 @@ * | ||
} | ||
this.set(key, union()(arr, flatten()(args))); | ||
this.set(key, lazy.union(arr, lazy.flatten(args))); | ||
this.emit('union', key); | ||
@@ -214,6 +185,6 @@ return this; | ||
} | ||
var e = extend(); | ||
var extend = lazy.extend; | ||
if (typeof args[0] === 'string') { | ||
var o = this.get(args[0]) || {}; | ||
o = e.apply(e, union()([o], args.slice(1))); | ||
o = extend.apply(extend, lazy.union([o], args.slice(1))); | ||
this.set(args[0], o); | ||
@@ -223,3 +194,3 @@ this.emit('extend'); | ||
} | ||
e.apply(e, union()([this.cache], args)); | ||
extend.apply(extend, lazy.union([this.cache], args)); | ||
this.emit('extend'); | ||
@@ -241,3 +212,3 @@ return this; | ||
Config.prototype.del = function(keys) { | ||
this.cache = keys ? omit()(this.cache, keys) : {}; | ||
this.cache = keys ? lazy.omit(this.cache, keys) : {}; | ||
this.emit('del', keys); | ||
@@ -252,2 +223,1 @@ return this; | ||
module.exports = Config; | ||
/* deps: arr-flatten array-union extend-shallow get-value kind-of object.omit set-value */ |
{ | ||
"name": "config-cache", | ||
"description": "General purpose JavaScript object storage methods.", | ||
"version": "6.0.0", | ||
"version": "6.0.1", | ||
"homepage": "https://github.com/jonschlinkert/config-cache", | ||
"repository": "jonschlinkert/config-cache", | ||
"author": "Jon Schlinkert (https://github.com/jonschlinkert)", | ||
@@ -13,6 +14,2 @@ "maintainers": [ | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/jonschlinkert/config-cache.git" | ||
}, | ||
"bugs": { | ||
@@ -36,7 +33,7 @@ "url": "https://github.com/jonschlinkert/config-cache/issues" | ||
"component-emitter": "^1.2.0", | ||
"extend-shallow": "^1.1.4", | ||
"extend-shallow": "^2.0.1", | ||
"get-value": "^1.1.5", | ||
"kind-of": "^2.0.0", | ||
"lazy-cache": "^0.1.0", | ||
"object.omit": "^1.1.0", | ||
"lazy-cache": "^0.2.3", | ||
"object.omit": "^2.0.0", | ||
"set-value": "^0.2.0" | ||
@@ -43,0 +40,0 @@ }, |
@@ -53,3 +53,3 @@ # config-cache [![NPM version](https://badge.fury.io/js/config-cache.svg)](http://badge.fury.io/js/config-cache) [![Build Status](https://travis-ci.org/jonschlinkert/config-cache.svg)](https://travis-ci.org/jonschlinkert/config-cache) | ||
```js | ||
var cache = new Config(); | ||
var config = new Config(); | ||
``` | ||
@@ -186,3 +186,3 @@ | ||
If `expand: true` is defined on the options, the value will be set using [expander](https://github.com/tkellen/expander). | ||
If `expand: true` is defined on the options, the value will be set using [expander]. | ||
@@ -193,6 +193,6 @@ **Examples:** | ||
// as a key-value pair | ||
cache.set('a', {b: 'c'}); | ||
config.set('a', {b: 'c'}); | ||
// or as an object | ||
cache.set({a: {b: 'c'}}); | ||
config.set({a: {b: 'c'}}); | ||
@@ -208,6 +208,6 @@ // chaining is possible | ||
```js | ||
cache.set('a', {b: '${c}', c: 'd'}, true); | ||
config.set('a', {b: '${c}', c: 'd'}, true); | ||
``` | ||
Visit the [expander](https://github.com/tkellen/expander)docs for more info. | ||
Visit the [expander] docs for more info. | ||
@@ -214,0 +214,0 @@ ## Related |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13140
192
1
+ Addedextend-shallow@2.0.1(transitive)
+ Addedobject.omit@2.0.1(transitive)
- Removedansi-wrap@0.1.0(transitive)
- Removedansi-yellow@0.1.1(transitive)
- Removedextend-shallow@1.1.4(transitive)
- Removedkind-of@1.1.0(transitive)
- Removedlazy-cache@0.1.0(transitive)
- Removedobject.omit@1.1.0(transitive)
Updatedextend-shallow@^2.0.1
Updatedlazy-cache@^0.2.3
Updatedobject.omit@^2.0.0