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

asyncmemo

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

asyncmemo

memoize asynchronous function calls

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
169
increased by1590%
Maintainers
1
Weekly downloads
 
Created
Source

asyncmemo

Memoize asynchronous function calls. Combine multiple calls with the same argument so that the underlying function is only called once for that argument. Optionally cache the result for that argument.

Install

npm install --save asyncmemo

Example

var asyncMemo = require('asyncmemo')
var xhr = require('xhr')
var get = asyncMemo(function (base, path, cb) {
  xhr.get(base + path, cb)
}, 'http://localhost')
get('/foo', function (err, resp) {
  console.log(err, resp)
})

API

asyncMemo([opts,] fn, [args...]): memo

  • opts.cache: cache object, or false to disable cache
  • fn([args...], arg, cb(err, result)): the asyncronous function to memoize
  • args: arguments to prepend to each call to fn
  • memo(arg, cb(err, result)): memoized asynchronous function

A custom cache object can be passed using the cache option. This should have has, get, and set methods.

  • async-memo
  • async-cache
  • memo-cache
  • memoizeasync
  • thunky - does the same except memoizes only one value

License

Copyright (c) 2016 Charles Lehner

Usage of the works is permitted provided that this instrument is retained with the works, so that any entity that uses the works is notified of this instrument.

DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.

Keywords

FAQs

Package last updated on 22 Nov 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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