Comparing version 0.0.760 to 0.0.761
@@ -0,18 +1,25 @@ | ||
import type { NonNull } from './type'; | ||
import { isArray } from './alias'; | ||
import { Dict } from './dict'; | ||
import { equal } from './compare'; | ||
export function memoize<f extends (...as: [unknown, ...unknown[]]) => unknown, b = Parameters<f>[0]>(f: f, memory?: Dict<b, ReturnType<f>>): f; | ||
interface Cache<K, V> { | ||
add?(key: K, value: V): NonNull; | ||
set(key: K, value: V): this; | ||
get(key: K): V | undefined; | ||
has(key: K): boolean; | ||
} | ||
export function memoize<f extends (...as: [unknown, ...unknown[]]) => unknown, b = Parameters<f>[0]>(f: f, memory?: Cache<b, ReturnType<f>>): f; | ||
export function memoize<f extends (...as: [number, ...unknown[]]) => unknown, b extends number = Parameters<f>[0]>(f: f, memory: Record<b, ReturnType<f>>): f; | ||
export function memoize<f extends (...as: [unknown, ...unknown[]]) => unknown, b = Parameters<f>[0]>(f: f, identify: (...as: Parameters<f>) => b, memory?: Dict<b, ReturnType<f>>): f; | ||
export function memoize<f extends (...as: [unknown, ...unknown[]]) => unknown, b = Parameters<f>[0]>(f: f, identify: (...as: Parameters<f>) => b, memory?: Cache<b, ReturnType<f>>): f; | ||
export function memoize<f extends (...as: [unknown, ...unknown[]]) => unknown, b extends number = number>(f: f, identify: (...as: Parameters<f>) => b, memory: Record<b, ReturnType<f>>): f; | ||
export function memoize<a, z, b = a>(f: (a: a) => z, memory?: Dict<b, z>): typeof f; | ||
export function memoize<a, z, b = a>(f: (a: a) => z, memory?: Cache<b, z>): typeof f; | ||
export function memoize<a extends number, z, b extends number = a>(f: (a: a) => z, memory: Record<b, z>): typeof f; | ||
export function memoize<a, z, b = a>(f: (a: a) => z, identify: (a: a) => b, memory?: Dict<b, z>): typeof f; | ||
export function memoize<a, z, b = a>(f: (a: a) => z, identify: (a: a) => b, memory?: Cache<b, z>): typeof f; | ||
export function memoize<a, z, b extends number = number>(f: (a: a) => z, identify: (a: a) => b, memory: Record<b, z>): typeof f; | ||
export function memoize<as extends [unknown, ...unknown[]], z, b = as[0]>(f: (...as: as) => z, memory?: Dict<b, z>): typeof f; | ||
export function memoize<as extends [unknown, ...unknown[]], z, b = as[0]>(f: (...as: as) => z, memory?: Cache<b, z>): typeof f; | ||
export function memoize<as extends [number, ...unknown[]], z, b extends number = as[0]>(f: (...as: as) => z, memory: Record<b, z>): typeof f; | ||
export function memoize<as extends [unknown, ...unknown[]], z, b = as[0]>(f: (...as: as) => z, identify: (...as: as) => b, memory?: Dict<b, z>): typeof f; | ||
export function memoize<as extends [unknown, ...unknown[]], z, b = as[0]>(f: (...as: as) => z, identify: (...as: as) => b, memory?: Cache<b, z>): typeof f; | ||
export function memoize<as extends [unknown, ...unknown[]], z, b extends number = number>(f: (...as: as) => z, identify: (...as: as) => b, memory: Record<b, z>): typeof f; | ||
export function memoize<as extends [unknown, ...unknown[]], z, b = as[0]>(f: (...as: as) => z, identify?: Dict<b, z> | Record<number, z> | ((...as: as) => b), memory?: Dict<b, z> | Record<number, z>): typeof f { | ||
export function memoize<as extends [unknown, ...unknown[]], z, b = as[0]>(f: (...as: as) => z, identify?: Cache<b, z> | Record<number, z> | ((...as: as) => b), memory?: Cache<b, z> | Record<number, z>): typeof f { | ||
if (typeof identify === 'object') { | ||
@@ -29,3 +36,3 @@ memory = identify; | ||
default: | ||
return memoizeDict(f, identify, memory as Dict<b, z> ?? new Map()); | ||
return memoizeDict(f, identify, memory as Cache<b, z> ?? new Map()); | ||
} | ||
@@ -66,3 +73,3 @@ } | ||
identify: (...as: as) => b, | ||
memory: Dict<b, z>, | ||
memory: Cache<b, z>, | ||
): typeof f { | ||
@@ -69,0 +76,0 @@ let nullable = false; |
{ | ||
"name": "spica", | ||
"version": "0.0.760", | ||
"version": "0.0.761", | ||
"description": "Supervisor, Coroutine, Channel, select, AtomicPromise, Cancellation, Cache, List, Queue, Stack, and some utils.", | ||
@@ -5,0 +5,0 @@ "private": false, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
626334
225
17158