memoize-fs
Advanced tools
Comparing version 1.1.0 to 1.2.0
@@ -0,1 +1,5 @@ | ||
### 1.2.0 (2017-08-26) | ||
* added astBody option | ||
### 1.1.0 (2017-02-05) | ||
@@ -2,0 +6,0 @@ |
11
index.js
@@ -9,2 +9,3 @@ 'use strict' | ||
var crypto = require('crypto') | ||
var parseScript = require('shift-parser').parseScript | ||
@@ -53,9 +54,5 @@ module.exports = function (options) { | ||
var salt = opt.salt || '' | ||
var fnStr = (opt.noBody ? '' : String(fn)) | ||
var argsStr | ||
var hash | ||
argsStr = serialize(args) | ||
hash = crypto.createHash('md5').update(fnStr + argsStr + salt).digest('hex') | ||
var fnStr = (opt.noBody ? '' : opt.astBody ? JSON.stringify(parseScript(String(fn))) : String(fn)) | ||
var argsStr = serialize(args) | ||
var hash = crypto.createHash('md5').update(fnStr + argsStr + salt).digest('hex') | ||
return path.join(options.cachePath, opt.cacheId, hash) | ||
@@ -62,0 +59,0 @@ } |
{ | ||
"name": "memoize-fs", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "memoize/cache in file system solution for Node.js", | ||
@@ -28,3 +28,4 @@ "author": "Boris Diakur <contact@borisdiakur.com> (https://github.com/borisdiakur)", | ||
"mkdirp": "^0.5.0", | ||
"rimraf": "^2.4.0" | ||
"rimraf": "^2.4.0", | ||
"shift-parser": "^5.0.7" | ||
}, | ||
@@ -31,0 +32,0 @@ "devDependencies": { |
@@ -51,3 +51,3 @@ # memoize-fs | ||
__Note that a result of a momoized function is always a [Promise](http://www.html5rocks.com/en/tutorials/es6/promises/) instance!__ | ||
__Note that a result of a memoized function is always a [Promise](http://www.html5rocks.com/en/tutorials/es6/promises/) instance!__ | ||
@@ -113,3 +113,3 @@ ### Memoizing asynchronous functions | ||
The `cacheId` option which you can specify during momoization of a function resolves to the name of a subfolder created inside the root cache folder. | ||
The `cacheId` option which you can specify during memoization of a function resolves to the name of a subfolder created inside the root cache folder. | ||
Cached function calls will be cached inside that folder: | ||
@@ -148,2 +148,10 @@ | ||
#### astBody | ||
If you want to use the function AST instead the function body when generating the hash ([see serialization](#serialization)), set the option `astBody` to `true`. This allows the function source code to be reformatted without busting the cache. See https://github.com/borisdiakur/memoize-fs/issues/6 for details. | ||
```javascript | ||
memoize.fn(fun, { astBody: true }).then(... | ||
``` | ||
#### noBody | ||
@@ -150,0 +158,0 @@ |
Sorry, the diff of this file is not supported yet
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
20491
232
0
4
221
+ Addedshift-parser@^5.0.7
+ Addedd@1.0.2(transitive)
+ Addedes5-ext@0.10.64(transitive)
+ Addedes6-iterator@2.0.3(transitive)
+ Addedes6-map@0.1.5(transitive)
+ Addedes6-set@0.1.6(transitive)
+ Addedes6-symbol@3.1.4(transitive)
+ Addedesniff@2.0.1(transitive)
+ Addedevent-emitter@0.3.5(transitive)
+ Addedext@1.7.0(transitive)
+ Addedmultimap@0.1.1(transitive)
+ Addednext-tick@1.1.0(transitive)
+ Addedshift-ast@4.0.0(transitive)
+ Addedshift-parser@5.2.4(transitive)
+ Addedshift-reducer@4.4.1(transitive)
+ Addedtype@2.7.3(transitive)