global-cache
Advanced tools
Comparing version 1.0.3 to 1.1.0
@@ -12,3 +12,6 @@ { | ||
"requireCurlyBraces": ["if", "else", "for", "while", "do", "try", "catch"], | ||
"requireCurlyBraces": { | ||
"allExcept": [], | ||
"keywords": ["if", "else", "for", "while", "do", "try", "catch"] | ||
}, | ||
@@ -20,2 +23,3 @@ "requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch", "function"], | ||
"disallowSpaceBeforeComma": true, | ||
"disallowSpaceAfterComma": false, | ||
"disallowSpaceBeforeSemicolon": true, | ||
@@ -32,3 +36,3 @@ | ||
"requireObjectKeysOnNewLine": true, | ||
"requireObjectKeysOnNewLine": { "allExcept": ["sameLine"] }, | ||
@@ -82,3 +86,3 @@ "requireSpacesInAnonymousFunctionExpression": { "beforeOpeningRoundBrace": true, "beforeOpeningCurlyBrace": true }, | ||
"requireDotNotation": true, | ||
"requireDotNotation": { "allExcept": ["keywords"] }, | ||
@@ -134,4 +138,27 @@ "requireParenthesesAroundIIFE": true, | ||
"requireSpaceAfterComma": true | ||
"requireSpaceAfterComma": { "allExcept": ["trailing"] }, | ||
"requireAlignedMultilineParams": false, | ||
"requireSpacesInGenerator": { | ||
"afterStar": true | ||
}, | ||
"disallowSpacesInGenerator": { | ||
"beforeStar": true | ||
}, | ||
"disallowVar": false, | ||
"requireArrayDestructuring": false, | ||
"requireEnhancedObjectLiterals": false, | ||
"requireObjectDestructuring": false, | ||
"requireEarlyReturn": false, | ||
"requireCapitalizedConstructorsNew": { | ||
"allExcept": ["Function", "String", "Object", "Symbol", "Number", "Date", "RegExp", "Error", "Boolean", "Array"] | ||
} | ||
} | ||
@@ -0,1 +1,8 @@ | ||
1.1.0 / 2016-01-29 | ||
================= | ||
* [New] add `#clear()` to clear the cache | ||
* [Dev Deps] update `tape`, `jscs`, `nsp`, `eslint`, `@ljharb/eslint-config`, `semver` | ||
* [Tests] up to `node` `v5.5`, don’t allow `0.8` to fail | ||
* [Tests] fix npm upgrades on older nodes | ||
1.0.3 / 2015-10-19 | ||
@@ -2,0 +9,0 @@ ================= |
21
index.js
@@ -10,10 +10,14 @@ 'use strict'; | ||
} | ||
if (!global[globalKey]) { | ||
var properties = {}; | ||
properties[globalKey] = {}; | ||
define(global, properties); | ||
} | ||
var cache = global[globalKey]; | ||
var ensureCache = function ensureCache() { | ||
if (!global[globalKey]) { | ||
var properties = {}; | ||
properties[globalKey] = {}; | ||
define(global, properties); | ||
} | ||
return global[globalKey]; | ||
}; | ||
var cache = ensureCache(); | ||
var isPrimitive = function isPrimitive(val) { | ||
@@ -37,2 +41,7 @@ return val === null || (typeof val !== 'object' && typeof val !== 'function'); | ||
var globalCache = { | ||
clear: function clear() { | ||
delete global[globalKey]; | ||
cache = ensureCache(); | ||
}, | ||
'delete': function deleteKey(key) { | ||
@@ -39,0 +48,0 @@ requirePrimitiveKey(key); |
{ | ||
"name": "global-cache", | ||
"version": "1.0.3", | ||
"version": "1.1.0", | ||
"author": { | ||
@@ -20,3 +20,4 @@ "name": "Jordan Harband", | ||
"scripts": { | ||
"test": "npm run lint && node --es-staging test.js && npm run security", | ||
"test": "npm run lint && npm run tests-only && npm run security", | ||
"tests-only": "node --es-staging test.js", | ||
"coverage": "covert test.js", | ||
@@ -27,3 +28,3 @@ "coverage-quiet": "covert test.js --quiet", | ||
"eslint": "eslint test.js *.js", | ||
"security": "nsp package" | ||
"security": "nsp check" | ||
}, | ||
@@ -46,10 +47,10 @@ "repository": { | ||
"devDependencies": { | ||
"tape": "^4.2.1", | ||
"tape": "^4.4.0", | ||
"covert": "^1.1.0", | ||
"jscs": "^2.3.4", | ||
"nsp": "^1.1.0", | ||
"eslint": "^1.7.1", | ||
"@ljharb/eslint-config": "^1.4.1", | ||
"jscs": "^2.9.0", | ||
"nsp": "^2.2.0", | ||
"eslint": "^1.10.3", | ||
"@ljharb/eslint-config": "^1.6.1", | ||
"replace": "^0.3.0", | ||
"semver": "^5.0.3" | ||
"semver": "^5.1.0" | ||
}, | ||
@@ -56,0 +57,0 @@ "testling": { |
@@ -23,2 +23,7 @@ 'use strict'; | ||
globalCache.set(key, bar); | ||
t.ok(globalCache.has(key), 'global cache has key before clear'); | ||
globalCache.clear(); | ||
t.notOk(globalCache.has(key), 'global cache does not have key after clear'); | ||
t.end(); | ||
@@ -25,0 +30,0 @@ }); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
19704
210