New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

memoize-fs

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

memoize-fs - npm Package Compare versions

Comparing version 1.0.4 to 1.0.5

4

CHANGELOG.md

@@ -0,1 +1,5 @@

### 1.0.5 (2016-11-22)
* updated es6-promise@^4.0.5
### 1.0.4 (2015-08-11)

@@ -2,0 +6,0 @@

4

package.json
{
"name": "memoize-fs",
"version": "1.0.4",
"version": "1.0.5",
"description": "memoize/cache in file system solution for Node.js",

@@ -27,3 +27,3 @@ "author": "Boris Diakur <contact@borisdiakur.com> (https://github.com/borisdiakur)",

"dependencies": {
"es6-promise": "^3.0.0",
"es6-promise": "^4.0.5",
"mkdirp": "^0.5.0",

@@ -30,0 +30,0 @@ "rimraf": "^2.4.0"

@@ -8,11 +8,10 @@ # memoize-fs

[![Dependency Status](https://gemnasium.com/borisdiakur/memoize-fs.svg)](https://gemnasium.com/borisdiakur/memoize-fs)
[![npm version](https://badge.fury.io/js/memoize-fs.svg)](http://badge.fury.io/js/memoize-fs)
[![NPM](https://nodei.co/npm/memoize-fs.png?downloads=true)](https://nodei.co/npm/memoize-fs/)
## Motivation
This project is inspired by the [memoize project](https://github.com/medikoo/memoize) by [Mariusz Nowak aka medikoo](https://github.com/medikoo).
The motivation behind this module is that sometimes you have to persist cached function calls but you do not want to deal with an extra process
The motivation behind this module is that sometimes you have to persist cached function calls but you do not want to deal with an extra process
(ie. managing a Redis store).
Memoization is best technique to save on memory or CPU cycles when we deal with repeated operations. For detailed insight see:
Memoization is best technique to save on memory or CPU cycles when we deal with repeated operations. For detailed insight see:
http://en.wikipedia.org/wiki/Memoization

@@ -45,7 +44,7 @@

assert.strictEqual(result, 3);
memFn(1, 2).then(function (result) { // cache hit
assert.strictEqual(result, 3);
}, function (err) { /* handle error */ });
}, function (err) { /* handle error */ });
}, function (err) { /* handle error */ });
return memFn(1, 2); // cache hit
}).then(function (result) {
assert.strictEqual(result, 3);
}).catch( /* handle error */ );
}).catch( /* handle error */ );
```

@@ -70,7 +69,7 @@

memFn(1, 2, function (err, sum) { if (err) { throw err; } console.log(sum); }).then(function () {
memFn(1, 2, function (err, sum) { if (err) { throw err; } console.log(sum); }).then(function () { // cache hit
// callback is called with previously cached arguments
}, function (err) { /* handle error */ });
}, function (err) { /* handle error */ });
}, function (err) { /* handle error */ });
return memFn(1, 2, function (err, sum) { if (err) { throw err; } console.log(sum); }); // cache hit
}).then(function () {
// callback is called with previously cached arguments
}).catch( /* handle error */ );
}).catch( /* handle error */ );
```

@@ -81,3 +80,3 @@

You can also memoize a promisified function. memoize-fs assumes a function promisified if its result is _thenable_
which means that the result is an object with a property `then` of type `function`
which means that the result is an object with a property `then` of type `function`
(read more about JavaScript promises [here](http://www.html5rocks.com/en/tutorials/es6/promises/?redirect_from_locale=de)).

@@ -97,7 +96,7 @@ So again it's the same as with memoizing synchronous functions.

assert.strictEqual(result, 3);
memFn(1, 2).then(function (result) { // cache hit
assert.strictEqual(result, 3);
}, function (err) { /* handle error */ });
}, function (err) { /* handle error */ });
}, function (err) { /* handle error */ });
return memFn(1, 2); // cache hit
}).then(function (result) {
assert.strictEqual(result, 3);
}).catch( /* handle error */ );
}).catch( /* handle error */ );
```

@@ -117,3 +116,3 @@

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 momoization 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:

@@ -127,5 +126,5 @@

Functions may have references to variables outside their own scope. As a consequence two functions which look exactly the same
(they have the same function signature and function body) can return different results even when executed with identical arguments.
In order to avoid the same cache being used for two different functions you can use the `salt` option
Functions may have references to variables outside their own scope. As a consequence two functions which look exactly the same
(they have the same function signature and function body) can return different results even when executed with identical arguments.
In order to avoid the same cache being used for two different functions you can use the `salt` option
which mutates the hash key created for the memoized function which in turn defines the name of the cache file:

@@ -170,3 +169,3 @@

memoize-fs uses JSON to serialize the results of a memoized function.
It also uses JSON, when it tries to serialize the arguments of the memoized function in order to create a hash
It also uses JSON, when it tries to serialize the arguments of the memoized function in order to create a hash
which is used as the name of the cache file to be stored or retrieved.

@@ -173,0 +172,0 @@ The hash is created from the serialized arguments, the function body and the [salt](#salt) (if provided as an option).

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc