Gathering detailed insights and metrics for async-memoize-one
Gathering detailed insights and metrics for async-memoize-one
Gathering detailed insights and metrics for async-memoize-one
Gathering detailed insights and metrics for async-memoize-one
npm install async-memoize-one
82.9
Supply Chain
93.9
Quality
77.6
Maintenance
100
Vulnerability
100
License
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
29 Stars
41 Commits
5 Forks
2 Watching
1 Branches
2 Contributors
Updated on 07 Sept 2024
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-34.1%
1,345
Compared to previous day
Last week
5.1%
7,826
Compared to previous week
Last month
97%
27,832
Compared to previous month
Last year
-13.9%
206,113
Compared to previous year
Memoize the last result, in async way.
async-memoize-one simply remembers the last arguments, and if the function is next called with the same arguments then it returns the previous result.
It's used for micro-caching scenarios, where you want to prevent perform an action previously done during a short period of time.
No need to worry about cache busting mechanisms such as maxAge, maxSize, exclusions and so on which can be prone to memory leaks.
1$ npm install async-memoize-one --save
1const get = require('util').promisify(require('simple-get')) 2const memoizeOne = require('async-memoize-one') 3 4const fetchData = memoizeOne(url => get(`https://api.microlink.io?url=${url}`)) 5 6;(async () => { 7 // fecthing data for first time 8 console.time('fetch') 9 await fetchData('https://example.com/one') 10 console.timeEnd('fetch') 11 12 // served data from cache; no fetching! 13 console.time('fetch') 14 await fetchData('https://example.com/one') 15 console.timeEnd('fetch') 16 17 // previous execution parameters are different, so fetching again 18 console.time('fetch') 19 await fetchData('https://example.com/two') 20 console.timeEnd('fetch') 21 22 // previous execution parameters are different, so fetching again 23 console.time('fetch') 24 await fetchData('https://example.com/one') 25 console.timeEnd('fetch') 26})()
Required
Type: function
Promise-returning or async function to be memoized.
Type: function
Default: fast-deep-equal
The compare function to determinate if both executions are the same.
An equality function should return true if the arguments are equal. If true is returned then the wrapped function will not be called.
Type: boolean
Default: false
Cache rejected promises.
async-memoize-one © microlink.io, released under the MIT License.
Authored and maintained by Kiko Beats with help from contributors.
microlink.io · GitHub microlink.io · Twitter @microlinkhq
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 1/20 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn Morememoize-one
A memoization library which only remembers the latest invocation
p-memoize
Memoize promise-returning & async functions
@formatjs/fast-memoize
fork of fast-memoize and support esm
memoize
Memoize functions - An optimization used to speed up consecutive function calls by caching the result of calls with identical input