Comparing version 1.3.3 to 1.4.0
@@ -0,0 +0,0 @@ { |
var path = require("path"); | ||
module.exports = require(path.join(__dirname, "lib", Number(process.version.replace("v", "").split(".")[0]) >= 6 ? "tiny-lru.es6" : "tiny-lru")); |
@@ -5,6 +5,6 @@ /** | ||
* @author Jason Mulligan <jason.mulligan@avoidwork.com> | ||
* @copyright 2016 | ||
* @copyright 2017 | ||
* @license BSD-3-Clause | ||
* @link https://github.com/avoidwork/tiny-lru | ||
* @version 1.3.3 | ||
* @version 1.4.0 | ||
*/ | ||
@@ -16,3 +16,2 @@ "use strict"; | ||
class LRU { | ||
@@ -36,2 +35,15 @@ constructor (max) { | ||
clear (silent = false) { | ||
this.cache = {}; | ||
this.first = null; | ||
this.last = null; | ||
this.length = 0; | ||
if (!silent && this.notify) { | ||
next(this.onchange("clear", this.dump())); | ||
} | ||
return this; | ||
} | ||
delete (key) { | ||
@@ -38,0 +50,0 @@ return this.remove(key); |
@@ -5,6 +5,6 @@ /** | ||
* @author Jason Mulligan <jason.mulligan@avoidwork.com> | ||
* @copyright 2016 | ||
* @copyright 2017 | ||
* @license BSD-3-Clause | ||
* @link https://github.com/avoidwork/tiny-lru | ||
* @version 1.3.3 | ||
* @version 1.4.0 | ||
*/ | ||
@@ -45,2 +45,18 @@ "use strict"; | ||
_createClass(LRU, [{ | ||
key: "clear", | ||
value: function clear() { | ||
var silent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; | ||
this.cache = {}; | ||
this.first = null; | ||
this.last = null; | ||
this.length = 0; | ||
if (!silent && this.notify) { | ||
next(this.onchange("clear", this.dump())); | ||
} | ||
return this; | ||
} | ||
}, { | ||
key: "delete", | ||
@@ -47,0 +63,0 @@ value: function _delete(key) { |
{ | ||
"name": "tiny-lru", | ||
"description": "Tiny LRU cache for Client or Server", | ||
"version": "1.3.3", | ||
"version": "1.4.0", | ||
"homepage": "https://github.com/avoidwork/tiny-lru", | ||
@@ -6,0 +6,0 @@ "author": "Jason Mulligan <jason.mulligan@avoidwork.com>", |
@@ -21,2 +21,15 @@ # Tiny LRU | ||
## clear | ||
### Method | ||
Clears the contents of the cache | ||
return {Object} LRU instance | ||
**Example** | ||
```javascript | ||
cache.clear(); | ||
``` | ||
## evict | ||
@@ -176,3 +189,3 @@ ### Method | ||
## License | ||
Copyright (c) 2016 Jason Mulligan | ||
Copyright (c) 2017 Jason Mulligan | ||
Licensed under the BSD-3 license. |
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
14005
332
190