SkillAgentSearch skills...

Memoize

A JavaScript function wrapper to memorize / cache result with the same input

Install / Use

/learn @cyan33/Memoize
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

memoize

:beginner: A JavaScript function wrapper to memorize / cache result with the same input

Installation

npm install --save @changyan/memoize

Basic Usage

import { memoize, memoizeAsync } from '@changyan/memoize'

const add = (a, b) => a + b

const memoizedAdd = memoize(add)

memoizedAdd(1, 2) // => 3
memoizedAdd(1, 2) // => return the cached "3"

const getFakeAsyncResult = () => new Promise((resolve, reject) => setTimeout(resolve, 1000))

// and it supports caching async functions
const memoizedGetAsyncResult = memoizeAsync(getFakeAsyncResult)

Contribution

PRs are welcomed!

View on GitHub
GitHub Stars6
CategoryDevelopment
Updated8y ago
Forks0

Languages

JavaScript

Security Score

75/100

Audited on Nov 16, 2017

No findings