Wrap a function with memo to get a function back that automagically returns values that have already been calculated.
import*as
import _
_from'radashi'
const
consttimestamp: () =>number
timestamp=
import _
_.
memo<[], number>(func: () => number, options?: _.MemoOptions<[]>|undefined): () => number
export memo
Creates a memoized function. The returned function will only
execute the source function when no value has previously been
computed. If a ttl (milliseconds) is given previously computed
values will be checked for expiration before being returned.
Enables basic storage and retrieval of dates and times.
Date.
DateConstructor.now(): number
Returns the number of milliseconds elapsed since midnight, January 1, 1970 Universal Coordinated Time (UTC).
now())
const
constnow:number
now=
consttimestamp: () =>number
timestamp()
const
constlater:number
later=
consttimestamp: () =>number
timestamp()
constnow:number
now===
constlater:number
later// => true
Expiration
You can optionally pass a ttl (time to live) that will expire memoized results. In versions prior to version 10, ttl had a value of 300 milliseconds if not specified.
import*as
import _
_from'radashi'
const
consttimestamp: () =>number
timestamp=
import _
_.
memo<[], number>(func: () => number, options?: _.MemoOptions<[]>|undefined): () => number
export memo
Creates a memoized function. The returned function will only
execute the source function when no value has previously been
computed. If a ttl (milliseconds) is given previously computed
values will be checked for expiration before being returned.
You can optionally customize how values are stored when memoized.
const
consttimestamp: (args_0: {
group:string;
}) =>string
timestamp=
import _
_.
memo<[{
group: string;
}], string>(func: (args_0: {
group:string;
}) =>string, options?:_.MemoOptions<[{
group:string;
}]> |undefined): (args_0: {
group:string;
}) => string
export memo
Creates a memoized function. The returned function will only
execute the source function when no value has previously been
computed. If a ttl (milliseconds) is given previously computed
values will be checked for expiration before being returned.