GitShow/sindresorhus/memoize
sindresorhus

memoize

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

by sindresorhus
Star on GitHubForknpm

TypeScript

1.2k stars55 forks18 contributorsActive · 1mo agoSince 2015v11.0.0MIT

Meet the team

See all 18 on GitHub →
sindresorhus
sindresorhus61 contributions
fregante
fregante22 contributions
SamVerschueren
SamVerschueren5 contributions
Richienb
Richienb3 contributions
BendingBender
BendingBender2 contributions
bencehornak
bencehornak1 contribution
coreyfarrell
coreyfarrell1 contribution
dylang
dylang1 contribution

Languages

View on GitHub →
TypeScript100%

Commit activity

Last 12 weeks · 0 commits

Full graph →

Community health

4 of 6 standards met

Community profile →
85
✓README✓License✓Contributing✓Code of Conduct○Issue Template○PR Template

Recent PRs & issues

Active · 2 in progress · Last activity 1mo ago
See all on GitHub →
zfaustk
Warn when only one argument is memoizedOpenPR

Fixes #90 Warn when a function declares more than one parameter but memoization still uses the default first-argument cache key. The warning runs once when the wrapper is created, so repeated calls do not add hot-path noise. Supplying silences it. The test also verifies that single-parameter functions stay silent and that an explicit is treated as intentional. I removed one redundant type assertion flagged by the current XO toolchain so the canonical suite remains green after a fresh install. Tests: (XO, 68 AVA tests, TypeScript build, tsd) Implemented and tested with Codex assistance.

zfaustk · 1w ago
sindresorhus
Add `isMemoized()` and `Memoized` typeOpenPR

The return type of is unchanged, so the tag is only earned after the runtime guard. Fixes #114 Why not an property on the returned function? It changes the shape of the function, which defeats the point of mimicking the input exactly. It's also trivially forgeable and would show up in spreads, , and snapshots. The information already exists internally in a , so the check needs no extra surface. Why not brand the return type of by default? It would leak into every hover and error message, and can cause declaration-emit friction for consumers re-exporting a memoized function. A brand on the return value is also just an assertion, whereas the guard reflects reality: returns the input unchanged since nothing is cached, and correctly reports for it.

sindresorhus · 4w ago
fregante
Tagged return typeOpenIssue

I want my helper to only accept memoized functions, but unlike , attempts to mimic the input function and type entirely. An easy/ugly way would be to return but I'd be happy to just get a type of sorts

fregante · 1mo ago

Recent fixes

View closed PRs →
fregante
Don't add parameters after functions ClosedIssue

While this reads fine: This is bad practice: This could be enforced by a linter, since APIs like exist natively, but ideally and should accept a single parameter: It complicates types a bit but it requires the much cleaner: _Personal note:_ I went through this recently in webext-storage-cache, changing to

fregante · 5mo ago
Copilot
Export CacheItem and CacheLike types for TypeScript custom cache definitionsMergedPR

TypeScript users need to manually copy internal type definitions to create custom caches because and are not exported. Changes index.ts: Export and types test-d/index.test-d.ts: Add type tests verifying exported types work with custom cache implementations Usage Original prompt This section details on the original issue you should resolve* Defining custom cache in TypeScript Neither , nor are exported. So, in order to define a custom cache, I have to manually copy the types: or, a bit nicer: Could we have some exported types? ## Comments on the Issue (you are @copilot in this section) Fixes sindresorhus/memoize#111 💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot · 5mo ago
Richienb
Defining custom cache in TypeScriptClosedIssue

Neither , nor are exported. So, in order to define a custom cache, I have to manually copy the types: or, a bit nicer: Could we have some exported types?

Richienb · 5mo ago
Structured data for AI agents

Repository: sindresorhus/memoize. Description: Memoize functions - an optimization technique used to speed up consecutive function calls by caching the result of calls with identical input Stars: 1163, Forks: 55. Primary language: TypeScript. Languages: TypeScript (100%). License: MIT. Latest release: v11.0.0 (5mo ago). Open PRs: 2, open issues: 2. Last activity: 1mo ago. Community health: 85%. Top contributors: sindresorhus, fregante, SamVerschueren, Richienb, BendingBender, bencehornak, coreyfarrell, dylang, elvinn, keithamus and others.

·@ofershap

Replace github.com with gitshow.dev