Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Micro npm Packages
  3. mem

mem

MITTypeScriptv11.0.0

A memoization library for JavaScript functions that caches results to optimize consecutive calls with identical input.

GitHubGitHub
1.2k stars54 forks0 contributors

What is mem?

Memoize is a JavaScript library that implements memoization, a technique to optimize function performance by caching the results of previous calls. When a memoized function is called with the same arguments, it returns the cached result instead of recomputing, significantly speeding up repeated operations. It's particularly useful for expensive computations, API requests, or any function where inputs repeat frequently.

Target Audience

JavaScript developers working on performance-sensitive applications, especially those dealing with expensive function calls, repeated calculations, or caching strategies. It's also suitable for library authors who want to add memoization to their APIs.

Value Proposition

Developers choose Memoize for its balance of simplicity and flexibility—it works out of the box with sensible defaults but allows deep customization through cache keys, storage backends, and expiration policies. Its decorator support and utilities for cache inspection make it a comprehensive solution for memoization in modern JavaScript.

Overview

Memoize functions - an optimization technique used to speed up consecutive function calls by caching the result of calls with identical input

Use Cases

Best For

  • Optimizing expensive mathematical or computational functions in JavaScript
  • Caching API responses or network requests to reduce latency
  • Improving performance in React or other frameworks by memoizing callbacks
  • Reducing redundant calculations in data processing pipelines
  • Adding memoization to class methods or getters using decorators
  • Implementing custom caching strategies with serializable or complex arguments

Not Ideal For

  • Applications requiring advanced Promise memoization with features like error caching or retry logic
  • Functions with multiple arguments that need deep equality caching without additional setup
  • Projects targeting environments without native support for TC39 stage 3 decorators

Pros & Cons

Pros

Flexible Cache Configuration

Allows custom cacheKey functions and alternative stores like WeakMap, enabling memoization of complex arguments such as objects using JSON.stringify.

Automatic Memory Management

Cache entries expire based on configurable maxAge, preventing memory leaks by automatically clearing stale data without manual intervention.

Decorator Support for Methods

Provides memoizeDecorator for memoizing class methods and getters using TC39 stage 3 decorators, simplifying integration in modern JavaScript.

Cache Inspection Utilities

Includes memoizeIsCached and memoizeClear functions to check cache status and clear entries, aiding in debugging and control.

Cons

Default Single-Argument Caching

Only the first argument is considered by default, which can lead to incorrect caching for multi-parameter functions unless a custom cacheKey is explicitly set.

External Dependencies for Complex Cases

Memoizing non-serializable arguments requires adding libraries like many-keys-map, increasing bundle size and setup complexity beyond the core library.

Decorator Compatibility Constraints

Relies on TC39 stage 3 decorators, which may not be natively supported in older environments, necessitating transpilation and limiting out-of-the-box use.

Frequently Asked Questions

Quick Stats

Stars1,153
Forks54
Contributors0
Open Issues1
Last commit1 month ago
CreatedSince 2015

Tags

#performance-optimization#decorators#memoization#nodejs#utility-library#cache-management#javascript

Built With

J
JavaScript

Included in

Node.js65.5kMicro npm Packages4.6k
Auto-fetched 8 hours ago

Related Projects

huskyhusky

Git hooks made easy 🐶 woof!

Stars35,015
Forks1,081
Last commit1 month ago
jsdomjsdom

A JavaScript implementation of various web standards, for use with Node.js

Stars21,569
Forks1,777
Last commit3 days ago
dotenvdotenv

Loads environment variables from .env for nodejs projects.

Stars20,410
Forks937
Last commit15 days ago
patch-packagepatch-package

Fix broken node modules instantly 🏃🏽‍♀️💨

Stars11,165
Forks322
Last commit7 months ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub