cache-base
Advanced tools
Comparing version 0.2.1 to 0.3.0
18
index.js
'use strict'; | ||
var util = require('util'); | ||
var chalk = require('chalk'); | ||
var typeOf = require('kind-of'); | ||
var Options = require('option-cache'); | ||
var slice = require('array-slice'); | ||
var get = require('get-value'); | ||
@@ -79,3 +79,3 @@ var _ = require('lodash'); | ||
} | ||
if (/\./.test(key)) { | ||
if (key.indexOf('.') !== -1) { | ||
return get(this.cache, key, true); | ||
@@ -272,4 +272,3 @@ } | ||
if (typeof o === 'string') { | ||
key = o; | ||
o = this.cache; | ||
key = o; o = this.cache; | ||
} | ||
@@ -333,3 +332,3 @@ return {}.hasOwnProperty.call(o, key); | ||
Cache.prototype.clear = function (key) { | ||
Cache.prototype.remove = function (key) { | ||
if (key) { | ||
@@ -341,1 +340,10 @@ delete this.cache[key]; | ||
}; | ||
/** | ||
* Deprecate | ||
*/ | ||
Cache.prototype.clear = function (key) { | ||
console.warn(chalk.yellow('[cache-base]: `.clear()` is deprecated. Use `.remove()` instead.')); | ||
this.remove(key); | ||
}; |
{ | ||
"name": "cache-base", | ||
"description": "Basic, general purpose object cache for node.js/javascript projects.", | ||
"version": "0.2.1", | ||
"description": "Generic object cache for node.js/javascript projects.", | ||
"version": "0.3.0", | ||
"homepage": "https://github.com/jonschlinkert/cache-base", | ||
@@ -20,12 +20,7 @@ "author": { | ||
"type": "MIT", | ||
"url": "https://github.com/jonschlinkert/cache-base/blob/master/LICENSE-MIT" | ||
"url": "https://github.com/jonschlinkert/cache-base/blob/master/LICENSE" | ||
} | ||
], | ||
"keywords": [ | ||
"config", | ||
"hash", | ||
"object", | ||
"store", | ||
"data", | ||
"cache" | ||
"files": [ | ||
"index.js" | ||
], | ||
@@ -37,3 +32,4 @@ "main": "index.js", | ||
"scripts": { | ||
"test": "mocha -R spec" | ||
"test": "mocha", | ||
"lint": "deps -e test" | ||
}, | ||
@@ -45,8 +41,16 @@ "devDependencies": { | ||
"dependencies": { | ||
"array-slice": "^0.2.2", | ||
"get-value": "^0.2.1", | ||
"kind-of": "^0.1.0", | ||
"lodash": "^2.4.1", | ||
"option-cache": "^0.1.4" | ||
} | ||
"chalk": "^0.5.1", | ||
"get-value": "^1.0.2", | ||
"kind-of": "^1.1.0", | ||
"lodash": "^3.2.0", | ||
"option-cache": "^1.1.0" | ||
}, | ||
"keywords": [ | ||
"config", | ||
"hash", | ||
"object", | ||
"store", | ||
"data", | ||
"cache" | ||
] | ||
} |
# cache-base [![NPM version](https://badge.fury.io/js/cache-base.svg)](http://badge.fury.io/js/cache-base) | ||
> Basic, general purpose object cache for node.js/javascript projects. | ||
> Generic object cache for node.js/javascript projects. | ||
## Install | ||
### Install with [npm](npmjs.org) | ||
## Install with [npm](npmjs.org) | ||
@@ -49,3 +48,3 @@ ```bash | ||
## API | ||
## [Cache](index.js#L29) | ||
### [Cache](index.js#L29) | ||
@@ -60,3 +59,3 @@ Create a new instance of `Cache` | ||
## [.set](index.js#L52) | ||
### [.set](index.js#L52) | ||
@@ -76,3 +75,3 @@ Assign `value` to `key` or return the value of `key`. | ||
## [.get](index.js#L75) | ||
### [.get](index.js#L75) | ||
@@ -89,3 +88,3 @@ Return the stored value of `key`. If `key` is not defined, the `cache` is returned. | ||
## [.exists](index.js#L101) | ||
### [.exists](index.js#L101) | ||
@@ -104,3 +103,3 @@ Return `true` if the element exists. Dot notation may be used for nested properties. | ||
## [.extend](index.js#L124) | ||
### [.extend](index.js#L124) | ||
@@ -119,3 +118,3 @@ Extend the `cache` with the given object. | ||
## [.merge](index.js#L155) | ||
### [.merge](index.js#L155) | ||
@@ -134,3 +133,3 @@ Deep merge an object onto the `cache`. | ||
## [.forOwn](index.js#L182) | ||
### [.forOwn](index.js#L182) | ||
@@ -146,3 +145,3 @@ Return the keys on `obj` or `this.cache`. | ||
## [.keys](index.js#L202) | ||
### [.keys](index.js#L202) | ||
@@ -158,3 +157,3 @@ Return the keys on `obj` or `this.cache`. | ||
## [.functions](index.js#L220) | ||
### [.functions](index.js#L220) | ||
@@ -171,3 +170,3 @@ Return an object of only the properties on `this.cache` or the given `obj` that have function values. | ||
## [.has](index.js#L246) | ||
### [.has](index.js#L246) | ||
@@ -183,3 +182,3 @@ Return true if a deep property is on the given object or `this.cache`. | ||
## [.hasOwn](index.js#L269) | ||
### [.hasOwn](index.js#L269) | ||
@@ -198,3 +197,3 @@ Return true if `key` is an own, enumerable property of `this.cache` or the given `obj`. | ||
## [.clone](index.js#L289) | ||
### [.clone](index.js#L288) | ||
@@ -210,3 +209,3 @@ Clone the given `obj` or `cache`. | ||
## [.omit](index.js#L307) | ||
### [.omit](index.js#L306) | ||
@@ -223,3 +222,3 @@ Delete a property or array of properties from the cache then re-save the cache. | ||
## [.clear](index.js#L331) | ||
### [.remove](index.js#L330) | ||
@@ -236,2 +235,3 @@ Remove `key` from the cache, or if no value is specified the entire cache is reset. | ||
## Author | ||
@@ -245,3 +245,3 @@ | ||
## License | ||
Copyright (c) 2014 Jon Schlinkert | ||
Copyright (c) 2014-2015 Jon Schlinkert | ||
Released under the MIT license | ||
@@ -251,2 +251,2 @@ | ||
_This file was generated by [verb](https://github.com/assemble/verb) on November 15, 2014._ | ||
_This file was generated by [verb](https://github.com/assemble/verb) on February 13, 2015._ |
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
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
303
0
11522
3
+ Addedchalk@^0.5.1
+ Addedansi-regex@0.2.1(transitive)
+ Addedansi-styles@1.1.0(transitive)
+ Addedansi-wrap@0.1.0(transitive)
+ Addedansi-yellow@0.1.1(transitive)
+ Addedarr-flatten@1.1.0(transitive)
+ Addedchalk@0.5.1(transitive)
+ Addedcomponent-emitter@1.3.1(transitive)
+ Addeddashify@0.1.0(transitive)
+ Addedescape-string-regexp@1.0.5(transitive)
+ Addedfor-in@1.0.2(transitive)
+ Addedget-value@1.3.12.0.6(transitive)
+ Addedhas-ansi@0.1.0(transitive)
+ Addedhas-value@0.2.1(transitive)
+ Addedhas-values@0.1.4(transitive)
+ Addedis-buffer@1.1.6(transitive)
+ Addedis-extendable@0.1.11.0.1(transitive)
+ Addedis-plain-object@2.0.4(transitive)
+ Addedis-primitive@2.0.0(transitive)
+ Addedisobject@1.0.23.0.1(transitive)
+ Addedkind-of@1.1.02.0.1(transitive)
+ Addedlazy-cache@0.1.00.2.7(transitive)
+ Addedlodash@3.10.1(transitive)
+ Addedmixin-deep@1.3.2(transitive)
+ Addednoncharacters@1.1.0(transitive)
+ Addedoption-cache@1.5.0(transitive)
+ Addedset-value@0.2.0(transitive)
+ Addedstrip-ansi@0.3.0(transitive)
+ Addedsupports-color@0.2.0(transitive)
+ Addedto-arg@1.1.0(transitive)
+ Addedto-flags@0.1.0(transitive)
- Removedarray-slice@^0.2.2
- Removedarray-slice@0.2.3(transitive)
- Removedget-value@0.2.2(transitive)
- Removedisobject@0.2.0(transitive)
- Removedkind-of@0.1.2(transitive)
- Removedlodash@2.4.2(transitive)
- Removedoption-cache@0.1.4(transitive)
Updatedget-value@^1.0.2
Updatedkind-of@^1.1.0
Updatedlodash@^3.2.0
Updatedoption-cache@^1.1.0