@graphql-tools/utils
Advanced tools
Comparing version 10.4.0-alpha-20240808024706-13ce91e5925ef720175c2a5f55583f7b34209017 to 10.4.0-alpha-20240809205104-4b5ae769b3963cc742e682b4049d634fc014d5b4
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.memoize2of5 = exports.memoize2of4 = exports.memoize5 = exports.memoize4 = exports.memoize3 = exports.memoize2 = exports.memoize1 = void 0; | ||
exports.memoize2of5 = exports.memoize2of4 = exports.memoize5 = exports.memoize4 = exports.memoize3of4 = exports.memoize3 = exports.memoize2 = exports.memoize1 = void 0; | ||
function memoize1(fn) { | ||
@@ -69,2 +69,33 @@ const memoize1cache = new WeakMap(); | ||
exports.memoize3 = memoize3; | ||
function memoize3of4(fn) { | ||
const memoize3Cache = new WeakMap(); | ||
return function memoized(a1, a2, a3, a4) { | ||
let cache2 = memoize3Cache.get(a1); | ||
if (!cache2) { | ||
cache2 = new WeakMap(); | ||
memoize3Cache.set(a1, cache2); | ||
const cache3 = new WeakMap(); | ||
cache2.set(a2, cache3); | ||
const newValue = fn(a1, a2, a3, a4); | ||
cache3.set(a3, newValue); | ||
return newValue; | ||
} | ||
let cache3 = cache2.get(a2); | ||
if (!cache3) { | ||
cache3 = new WeakMap(); | ||
cache2.set(a2, cache3); | ||
const newValue = fn(a1, a2, a3, a4); | ||
cache3.set(a3, newValue); | ||
return newValue; | ||
} | ||
const cachedValue = cache3.get(a3); | ||
if (cachedValue === undefined) { | ||
const newValue = fn(a1, a2, a3, a4); | ||
cache3.set(a3, newValue); | ||
return newValue; | ||
} | ||
return cachedValue; | ||
}; | ||
} | ||
exports.memoize3of4 = memoize3of4; | ||
function memoize4(fn) { | ||
@@ -71,0 +102,0 @@ const memoize4Cache = new WeakMap(); |
@@ -63,2 +63,32 @@ export function memoize1(fn) { | ||
} | ||
export function memoize3of4(fn) { | ||
const memoize3Cache = new WeakMap(); | ||
return function memoized(a1, a2, a3, a4) { | ||
let cache2 = memoize3Cache.get(a1); | ||
if (!cache2) { | ||
cache2 = new WeakMap(); | ||
memoize3Cache.set(a1, cache2); | ||
const cache3 = new WeakMap(); | ||
cache2.set(a2, cache3); | ||
const newValue = fn(a1, a2, a3, a4); | ||
cache3.set(a3, newValue); | ||
return newValue; | ||
} | ||
let cache3 = cache2.get(a2); | ||
if (!cache3) { | ||
cache3 = new WeakMap(); | ||
cache2.set(a2, cache3); | ||
const newValue = fn(a1, a2, a3, a4); | ||
cache3.set(a3, newValue); | ||
return newValue; | ||
} | ||
const cachedValue = cache3.get(a3); | ||
if (cachedValue === undefined) { | ||
const newValue = fn(a1, a2, a3, a4); | ||
cache3.set(a3, newValue); | ||
return newValue; | ||
} | ||
return cachedValue; | ||
}; | ||
} | ||
export function memoize4(fn) { | ||
@@ -65,0 +95,0 @@ const memoize4Cache = new WeakMap(); |
{ | ||
"name": "@graphql-tools/utils", | ||
"version": "10.4.0-alpha-20240808024706-13ce91e5925ef720175c2a5f55583f7b34209017", | ||
"version": "10.4.0-alpha-20240809205104-4b5ae769b3963cc742e682b4049d634fc014d5b4", | ||
"description": "Common package containing utils and types for GraphQL tools", | ||
@@ -5,0 +5,0 @@ "sideEffects": false, |
export declare function memoize1<F extends (a1: any) => any>(fn: F): F; | ||
export declare function memoize2<F extends (a1: any, a2: any) => any>(fn: F): F; | ||
export declare function memoize3<F extends (a1: any, a2: any, a3: any) => any>(fn: F): F; | ||
export declare function memoize3of4<F extends (a1: any, a2: any, a3: any, a4: any) => any>(fn: F): F; | ||
export declare function memoize4<F extends (a1: any, a2: any, a3: any, a4: any) => any>(fn: F): F; | ||
@@ -5,0 +6,0 @@ export declare function memoize5<F extends (a1: any, a2: any, a3: any, a4: any, a5: any) => any>(fn: F): F; |
Sorry, the diff of this file is not supported yet
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
513354
11154