paradiego
This commit is contained in:
+1
@@ -0,0 +1 @@
|
||||
export { default } from './memoize';
|
||||
+1
@@ -0,0 +1 @@
|
||||
export { default } from "./memoize.js";
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
export default function memoize<ArgType = any, ReturnType = any>(
|
||||
fn: (arg: ArgType) => ReturnType,
|
||||
): (arg: ArgType) => ReturnType;
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
export default function memoize(fn) {
|
||||
const cache = {};
|
||||
return arg => {
|
||||
if (cache[arg] === undefined) {
|
||||
cache[arg] = fn(arg);
|
||||
}
|
||||
return cache[arg];
|
||||
};
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"sideEffects": false,
|
||||
"module": "./index.js",
|
||||
"main": "../node/memoize/index.js",
|
||||
"types": "./index.d.ts"
|
||||
}
|
||||
Reference in New Issue
Block a user