Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

memoizee

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

memoizee

Memoize/cache function results

  • 0.3.10
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is memoizee?

The memoizee npm package is a complete memoization library for JavaScript. It allows for caching the results of function calls based on the arguments provided. This can significantly improve performance for expensive function calls that are invoked repeatedly with the same parameters.

What are memoizee's main functionalities?

Basic memoization

This feature allows you to memoize any function, caching its results so that subsequent calls with the same arguments return immediately without recomputing.

const memoize = require('memoizee');
const expensiveFunction = (arg) => { /* complex computation */ };
const memoized = memoize(expensiveFunction);

Memoization with options

This feature allows you to customize the memoization behavior with options such as maxAge for cache expiration, preFetch for renewing cache just before it expires, and max for limiting the number of cache entries.

const memoize = require('memoizee');
const memoized = memoize(expensiveFunction, { maxAge: 1000, preFetch: 0.5, max: 10 });

Primitive mode

Primitive mode ensures that the cache keys are based on the value of the arguments rather than their reference, which is useful for arguments that are primitive values.

const memoize = require('memoizee');
const memoized = memoize(expensiveFunction, { primitive: true });

Asynchronous function memoization

This feature allows memoization of asynchronous functions, caching the resolved value of the promise.

const memoize = require('memoizee');
const expensiveAsyncFunction = async (arg) => { /* complex async computation */ };
const memoized = memoize(expensiveAsyncFunction, { promise: true });

WeakMap-based memoization

This feature uses WeakMap to store cache entries, which allows for garbage collection of non-referenced keys, useful for memoizing functions that accept objects as arguments.

const memoize = require('memoizee/weak');
const memoized = memoize(expensiveFunction);

Other packages similar to memoizee

Keywords

FAQs

Package last updated on 21 Apr 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