{"_id":"promise-memoize","_rev":"10-1b984a4824255e966fadd6bbb6fcf388","name":"promise-memoize","description":"Memoize promise-returning functions. Includes cache expire and prefetch.","dist-tags":{"latest":"1.2.1"},"versions":{"0.1.0":{"name":"promise-memoize","version":"0.1.0","description":"Memoize promise-returning functions. Includes cache expire and prefetch.","keywords":["promise","memoize","cache"],"repository":{"type":"git","url":"git+https://github.com/nodeca/promise-memoize.git"},"license":"MIT","files":["index.js","lib/"],"scripts":{"lint":"eslint .","test":"npm run lint && ./node_modules/.bin/mocha","coverage":"rm -rf coverage && node_modules/.bin/istanbul cover node_modules/.bin/_mocha"},"devDependencies":{"co":"^4.6","eslint":"~2.10.2","istanbul":"^0.4.1","mocha":"^2.2.5"},"gitHead":"6e76a5f945eed16ce2550ed74dd9edfd757c831a","bugs":{"url":"https://github.com/nodeca/promise-memoize/issues"},"homepage":"https://github.com/nodeca/promise-memoize#readme","_id":"promise-memoize@0.1.0","_shasum":"48cea33723c734a1b3d8ae0cbabc99f9d124a92a","_from":".","_npmVersion":"2.15.1","_nodeVersion":"4.4.3","_npmUser":{"name":"vitaly","email":"vitaly@rcdesign.ru"},"maintainers":[{"name":"vitaly","email":"vitaly@rcdesign.ru"}],"dist":{"shasum":"48cea33723c734a1b3d8ae0cbabc99f9d124a92a","tarball":"https://registry.npmjs.org/promise-memoize/-/promise-memoize-0.1.0.tgz","integrity":"sha512-zXfS9rgVMn35VMKnPIzNyC6zmf4+ybW/FmUw6tBLs8tGSt7eDRagM4C+UBRQ6cVJR6nOOh5nneYVpCzOxltDLA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGfvKknmhmqyHNFW8JvNDh0WXx5wP0XPoPnVCp8PFg4lAiEA/WXFd1SUCzMi2U5NhNbHK1dlWIS06TdrK6y+J6osIII="}]},"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/promise-memoize-0.1.0.tgz_1463910978730_0.8743119849823415"}},"0.1.1":{"name":"promise-memoize","version":"0.1.1","description":"Memoize promise-returning functions. Includes cache expire and prefetch.","keywords":["promise","memoize","cache"],"repository":{"type":"git","url":"git+https://github.com/nodeca/promise-memoize.git"},"license":"MIT","files":["index.js","lib/"],"scripts":{"lint":"eslint .","test":"npm run lint && ./node_modules/.bin/mocha","coverage":"rm -rf coverage && node_modules/.bin/istanbul cover node_modules/.bin/_mocha","report-coveralls":"istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage"},"devDependencies":{"co":"^4.6","eslint":"~2.10.2","istanbul":"^0.4.1","mocha":"^2.2.5"},"dependencies":{"coveralls":"^2.11.9"},"gitHead":"13c74786e78a1b39ecaa344e4995899d5983caa5","bugs":{"url":"https://github.com/nodeca/promise-memoize/issues"},"homepage":"https://github.com/nodeca/promise-memoize#readme","_id":"promise-memoize@0.1.1","_shasum":"79251803c7e0cee6abd8003b61563a4ba2422b15","_from":".","_npmVersion":"2.15.1","_nodeVersion":"4.4.3","_npmUser":{"name":"vitaly","email":"vitaly@rcdesign.ru"},"maintainers":[{"name":"vitaly","email":"vitaly@rcdesign.ru"}],"dist":{"shasum":"79251803c7e0cee6abd8003b61563a4ba2422b15","tarball":"https://registry.npmjs.org/promise-memoize/-/promise-memoize-0.1.1.tgz","integrity":"sha512-wYRQe5mpDwsDP2tXJF5umypvmkzr9yCJLNB7/ZHVEBqZB6ZPByr4Y/TnzgGJ/ei3dIffrOmUqacIq2cuuViyng==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDZ8D13id4NDBKQ2b8NsMFQKVYwxzPTOFOjAECUkX1gzwIgNE0NrJI7nD1VhImwcg8kKoi30VjxvhzIFriclc4wUmc="}]},"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/promise-memoize-0.1.1.tgz_1464030742687_0.9817591584287584"}},"1.0.0":{"name":"promise-memoize","version":"1.0.0","description":"Memoize promise-returning functions. Includes cache expire and prefetch.","keywords":["promise","memoize","cache"],"repository":{"type":"git","url":"git+https://github.com/nodeca/promise-memoize.git"},"license":"MIT","files":["index.js","lib/"],"scripts":{"lint":"eslint .","test":"npm run lint && ./node_modules/.bin/mocha","coverage":"rm -rf coverage && node_modules/.bin/istanbul cover node_modules/.bin/_mocha","report-coveralls":"istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage"},"devDependencies":{"co":"^4.6","coveralls":"^2.11.9","eslint":"~2.11.1","istanbul":"^0.4.3","mocha":"^2.5.3"},"gitHead":"99367b5efd37f5d62902fa22ce8b15868fb3a583","bugs":{"url":"https://github.com/nodeca/promise-memoize/issues"},"homepage":"https://github.com/nodeca/promise-memoize#readme","_id":"promise-memoize@1.0.0","_shasum":"f20643c35124ca1850e9aa42d57ae97e09b78d7c","_from":".","_npmVersion":"2.15.5","_nodeVersion":"4.4.5","_npmUser":{"name":"vitaly","email":"vitaly@rcdesign.ru"},"maintainers":[{"name":"vitaly","email":"vitaly@rcdesign.ru"}],"dist":{"shasum":"f20643c35124ca1850e9aa42d57ae97e09b78d7c","tarball":"https://registry.npmjs.org/promise-memoize/-/promise-memoize-1.0.0.tgz","integrity":"sha512-Pjn4INz9oFvUKxXSvPDECdWCXhz8RziLlsXVlfXcvKNgko7maQyrKyylj9tqjMyKNSBKNM9RTmU6iW+eQOCywg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIET7wkoglqNIlLE/gu+kOwun54oY2WDwe1/ozjEkOHoTAiBoQW8xRHesSDpS7cb/C6HK3estz/Ua1F4f3p6l5U0saQ=="}]},"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/promise-memoize-1.0.0.tgz_1465058319890_0.42385982046835124"}},"1.1.0":{"name":"promise-memoize","version":"1.1.0","description":"Memoize promise-returning functions. Includes cache expire and prefetch.","keywords":["promise","memoize","cache"],"repository":{"type":"git","url":"git+https://github.com/nodeca/promise-memoize.git"},"license":"MIT","files":["index.js","lib/"],"scripts":{"lint":"eslint .","test":"npm run lint && mocha","coverage":"rm -rf coverage && istanbul cover _mocha","report-coveralls":"istanbul cover _mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | coveralls && rm -rf ./coverage"},"devDependencies":{"any-promise":"^1.3.0","chai":"^3.5.0","chai-as-promised":"^5.3.0","coveralls":"^2.11.9","eslint":"~2.13.1","istanbul":"^0.4.3","lie":"^3.0.4","mocha":"^2.5.3"},"gitHead":"cfd218a2ea15962d35296d45adbfda147ce45f93","bugs":{"url":"https://github.com/nodeca/promise-memoize/issues"},"homepage":"https://github.com/nodeca/promise-memoize#readme","_id":"promise-memoize@1.1.0","_shasum":"20eda71ac71a25165a070d87b6f35dab3db06d17","_from":".","_npmVersion":"2.15.5","_nodeVersion":"4.4.5","_npmUser":{"name":"vitaly","email":"vitaly@rcdesign.ru"},"maintainers":[{"name":"vitaly","email":"vitaly@rcdesign.ru"}],"dist":{"shasum":"20eda71ac71a25165a070d87b6f35dab3db06d17","tarball":"https://registry.npmjs.org/promise-memoize/-/promise-memoize-1.1.0.tgz","integrity":"sha512-uLDNg+xOg31bXaMsgKTPiIPqrST0XC+a41H5WYRTi1ptnrT0n7WK09itv33BI8AHOREBc44uByNugE5xJglBZg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCsCOnO3Sn/6QEI+QQYxifHkj8msNNRJPhSG7j+xMB9tQIgLISL7hYGB6u3HH3TSbvueLVyYIfZkNTmeushEpmEiyY="}]},"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/promise-memoize-1.1.0.tgz_1469265894268_0.7712560987565666"}},"1.2.0":{"name":"promise-memoize","version":"1.2.0","description":"Memoize promise-returning functions. Includes cache expire and prefetch.","keywords":["promise","memoize","cache"],"repository":{"type":"git","url":"git+https://github.com/nodeca/promise-memoize.git"},"license":"MIT","files":["index.js","lib/"],"scripts":{"lint":"eslint .","test":"npm run lint && mocha","coverage":"rm -rf coverage && istanbul cover _mocha","report-coveralls":"istanbul cover _mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | coveralls && rm -rf ./coverage"},"devDependencies":{"any-promise":"^1.3.0","chai":"^3.5.0","chai-as-promised":"^5.3.0","coveralls":"^2.11.9","eslint":"~2.13.1","istanbul":"^0.4.3","lie":"^3.0.4","mocha":"^2.5.3"},"gitHead":"6ddf3b3696e2a4b435b28002ddac0f5f94a74398","bugs":{"url":"https://github.com/nodeca/promise-memoize/issues"},"homepage":"https://github.com/nodeca/promise-memoize#readme","_id":"promise-memoize@1.2.0","_shasum":"e8b9345f2b42518d3016d76ffa4a7bb7dee7016f","_from":".","_npmVersion":"3.10.10","_nodeVersion":"6.9.4","_npmUser":{"name":"vitaly","email":"vitaly@rcdesign.ru"},"maintainers":[{"name":"vitaly","email":"vitaly@rcdesign.ru"}],"dist":{"shasum":"e8b9345f2b42518d3016d76ffa4a7bb7dee7016f","tarball":"https://registry.npmjs.org/promise-memoize/-/promise-memoize-1.2.0.tgz","integrity":"sha512-bTJ9Qro/9cwqYSxa3t9NHXEIVLzQte1cSfH1qT0VYz76wCzFlIXM58C+Tyfn2R+7tEwVKBPz+69B7/0YZ9t/Wg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIChchtMOV5nhyAIm6gzzZXuQsy9CWrKq7oa1HNaNWLJEAiBE+vgZYLFLi//zedTp2De/UNwJD6b2HXMxIG7ni5rHoQ=="}]},"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/promise-memoize-1.2.0.tgz_1489458285995_0.5532384719699621"}},"1.2.1":{"name":"promise-memoize","version":"1.2.1","description":"Memoize promise-returning functions. Includes cache expire and prefetch.","keywords":["promise","memoize","cache"],"repository":{"type":"git","url":"git+https://github.com/nodeca/promise-memoize.git"},"license":"MIT","files":["index.js","lib/"],"scripts":{"lint":"eslint .","test":"npm run lint && mocha","coverage":"rm -rf coverage && istanbul cover _mocha","report-coveralls":"istanbul cover _mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | coveralls && rm -rf ./coverage"},"devDependencies":{"any-promise":"^1.3.0","chai":"^4.1.2","chai-as-promised":"^7.1.1","coveralls":"^3.0.0","eslint":"^4.8.0","istanbul":"^0.4.3","lie":"^3.0.4","mocha":"^4.0.1"},"gitHead":"e59103f4468bb20c1de5eca1287bb9a23a2fd3ca","bugs":{"url":"https://github.com/nodeca/promise-memoize/issues"},"homepage":"https://github.com/nodeca/promise-memoize#readme","_id":"promise-memoize@1.2.1","_shasum":"71f9554a989cf6bf8987b43a52132d5c79312657","_from":".","_npmVersion":"2.15.11","_nodeVersion":"4.8.4","_npmUser":{"name":"vitaly","email":"vitaly@rcdesign.ru"},"maintainers":[{"name":"vitaly","email":"vitaly@rcdesign.ru"}],"dist":{"shasum":"71f9554a989cf6bf8987b43a52132d5c79312657","tarball":"https://registry.npmjs.org/promise-memoize/-/promise-memoize-1.2.1.tgz","integrity":"sha512-94LPGGAy5O6R2Tkrlaqo46Fpu3gzy9imbymA+zr6CXVQEtNokvbjKZgapQ275mR2OBk4BHMP0ZH26PqHKvkOzg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGt1ZRoLbH1AZiMM8m2cW7YNqTVK/avil0IpVykBz8MwAiA44juO481fZeigeIlbr7YFdhhGxtPGEiDwC9UVCSgC0Q=="}]},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/promise-memoize-1.2.1.tgz_1507956409035_0.44695843616500497"}}},"readme":"# promise-memoize\n\n[![Build Status](https://img.shields.io/travis/nodeca/promise-memoize/master.svg?style=flat)](https://travis-ci.org/nodeca/promise-memoize)\n[![NPM version](https://img.shields.io/npm/v/promise-memoize.svg?style=flat)](https://www.npmjs.org/package/promise-memoize)\n[![Coverage Status](https://coveralls.io/repos/github/nodeca/promise-memoize/badge.svg?branch=master)](https://coveralls.io/github/nodeca/promise-memoize?branch=master)\n\n> Memoize promise-returning functions. Includes cache expire and prefetch.\n\n- When data expire mode enabled, new values are fetched in advance. Cache\n  will be always valid, without \"gaps\".\n  - Prefetch happens only for items in use. Inactive ones will be GC-ed as usual.\n- Errors are not cached\n  - You still can enable cache with separate expire time for errors, to avoid\n    specific peak loads. For example, set 120s for good result and 1s on fail.\n\n\n## Install\n\n```bash\nnpm install promise-memoize --save\n```\n\n(\\*) IE9 and below will require [setTimeout polyfill](https://developer.mozilla.org/docs/Web/API/WindowTimers/setTimeout)\nfor correct work.\n\n\n## Usage example\n\n```js\n// Pseudo code\nlet db = require('mongoose').createConnection('mongodb://localhost/forum');\n\nfunction lastPosts(limit) {\n  return db.model('Post').find().limit(limit).orderBy('-_id').lean(true).exec(); // <- Promise\n}\n\nlet cachedLastPosts = require('promise-memoize')(lastPosts, { maxAge: 60000 });\n\n// Later...\ncachedLastPosts(10).then(posts => console.log(posts));\n```\n\n## API\n\n### promiseMemoize(fn [, options]) -> memoizedFn\n\nMemoize function `fn`.\n\n - **fn(params...)** — function, returning a promise (or any \"thenable\").\n   It can have any number of arguments, but arguments should be uniquely\n   castable to strings (see below).\n - **options** — options for memoization (optional)\n   - **maxAge** — an amount of milliseconds it should cache resolved\n     values for (default: `Infinity`, i.e. cache forever).\n   - **maxErrorAge** — an amount of milliseconds it should cache\n     rejected values for (default: `0`, i.e. don't cache).\n   - **resolve** — serialiser to build unique key from `fn` arguments.\n     (default: `simple`). Possible values:\n     - `simple` (string) — convert each param to string & join those.\n     - `json` (string) — JSON.stringify each param & join results.\n     - function(Array) — custom function, with `fn` params as array on input\n     - `[ String, Boolean, 'json', function ]` — array with custom functions,\n       specific for each `fn` param position (text shortcuts as above are allowed).\n\nReturn value is a function with the same signature as *fn*.\n\n**Note. How prefetch works.**\n\nIf `maxAge` used and request to cached data happens after `0.7 * maxAge` time, then:\n\n- cached data returned\n- `fn` call is executed in parallel\n- cached data will be substituted with new one on success, timeouts will be extended.\n\nSo your application will not have to wait for data fetch after cache expire.\n\n\n### memoizedFn(params...) -> promise\n\nReturns result as cached promise (errors are not cached by default). If `maxAge`\nused, tries to prefetch new value before expire to replace cache transparently.\n\n\n### memoizedFn.clear()\n\nRemove all cached data.\n\n\n## License\n\n[MIT](https://github.com/nodeca/promise-memoize/blob/master/LICENSE)\n","maintainers":[{"name":"vitaly","email":"vitaly@rcdesign.ru"}],"time":{"modified":"2022-06-24T18:51:02.022Z","created":"2016-05-22T09:56:19.771Z","0.1.0":"2016-05-22T09:56:19.771Z","0.1.1":"2016-05-23T19:12:24.888Z","1.0.0":"2016-06-04T16:38:41.495Z","1.1.0":"2016-07-23T09:24:55.978Z","1.2.0":"2017-03-14T02:24:46.675Z","1.2.1":"2017-10-14T04:46:50.013Z"},"homepage":"https://github.com/nodeca/promise-memoize#readme","keywords":["promise","memoize","cache"],"repository":{"type":"git","url":"git+https://github.com/nodeca/promise-memoize.git"},"bugs":{"url":"https://github.com/nodeca/promise-memoize/issues"},"license":"MIT","readmeFilename":"README.md","users":{"abhisekp":true,"pldin601":true}}