@axelarjs/utils
Advanced tools
Comparing version 0.1.3 to 0.1.4
export { default as throttle } from "lodash.throttle"; | ||
export { default as debounce } from "lodash.debounce"; | ||
type FN<T, R> = (arg: T) => R; | ||
/** | ||
* Memoize a function | ||
* | ||
* memoized function will cache the result of the function call | ||
* | ||
* @param func function to memoize | ||
* @returns memoized function | ||
*/ | ||
export declare function memoize<T, R>(func: FN<T, R>): FN<T, R>; |
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.debounce = exports.throttle = void 0; | ||
exports.memoize = exports.debounce = exports.throttle = void 0; | ||
var lodash_throttle_1 = require("lodash.throttle"); | ||
@@ -12,1 +12,22 @@ Object.defineProperty(exports, "throttle", { enumerable: true, get: function () { return __importDefault(lodash_throttle_1).default; } }); | ||
Object.defineProperty(exports, "debounce", { enumerable: true, get: function () { return __importDefault(lodash_debounce_1).default; } }); | ||
/** | ||
* Memoize a function | ||
* | ||
* memoized function will cache the result of the function call | ||
* | ||
* @param func function to memoize | ||
* @returns memoized function | ||
*/ | ||
function memoize(func) { | ||
const cache = new Map(); | ||
return (arg) => { | ||
const cachedResult = cache.get(arg); | ||
if (cachedResult !== undefined) { | ||
return cachedResult; | ||
} | ||
const result = func(arg); | ||
cache.set(arg, result); | ||
return result; | ||
}; | ||
} | ||
exports.memoize = memoize; |
export { default as throttle } from "lodash.throttle"; | ||
export { default as debounce } from "lodash.debounce"; | ||
type FN<T, R> = (arg: T) => R; | ||
/** | ||
* Memoize a function | ||
* | ||
* memoized function will cache the result of the function call | ||
* | ||
* @param func function to memoize | ||
* @returns memoized function | ||
*/ | ||
export declare function memoize<T, R>(func: FN<T, R>): FN<T, R>; |
export { default as throttle } from "lodash.throttle"; | ||
export { default as debounce } from "lodash.debounce"; | ||
/** | ||
* Memoize a function | ||
* | ||
* memoized function will cache the result of the function call | ||
* | ||
* @param func function to memoize | ||
* @returns memoized function | ||
*/ | ||
export function memoize(func) { | ||
const cache = new Map(); | ||
return (arg) => { | ||
const cachedResult = cache.get(arg); | ||
if (cachedResult !== undefined) { | ||
return cachedResult; | ||
} | ||
const result = func(arg); | ||
cache.set(arg, result); | ||
return result; | ||
}; | ||
} |
export { default as throttle } from "lodash.throttle"; | ||
export { default as debounce } from "lodash.debounce"; | ||
type FN<T, R> = (arg: T) => R; | ||
/** | ||
* Memoize a function | ||
* | ||
* memoized function will cache the result of the function call | ||
* | ||
* @param func function to memoize | ||
* @returns memoized function | ||
*/ | ||
export declare function memoize<T, R>(func: FN<T, R>): FN<T, R>; |
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.debounce = exports.throttle = void 0; | ||
exports.memoize = exports.debounce = exports.throttle = void 0; | ||
var lodash_throttle_1 = require("lodash.throttle"); | ||
@@ -12,1 +12,22 @@ Object.defineProperty(exports, "throttle", { enumerable: true, get: function () { return __importDefault(lodash_throttle_1).default; } }); | ||
Object.defineProperty(exports, "debounce", { enumerable: true, get: function () { return __importDefault(lodash_debounce_1).default; } }); | ||
/** | ||
* Memoize a function | ||
* | ||
* memoized function will cache the result of the function call | ||
* | ||
* @param func function to memoize | ||
* @returns memoized function | ||
*/ | ||
function memoize(func) { | ||
const cache = new Map(); | ||
return (arg) => { | ||
const cachedResult = cache.get(arg); | ||
if (cachedResult !== undefined) { | ||
return cachedResult; | ||
} | ||
const result = func(arg); | ||
cache.set(arg, result); | ||
return result; | ||
}; | ||
} | ||
exports.memoize = memoize; |
{ | ||
"name": "@axelarjs/utils", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"publishConfig": { | ||
@@ -62,4 +62,4 @@ "access": "public" | ||
"@types/ramda": "^0.29.4", | ||
"@types/react": "^18.2.21", | ||
"@types/react-dom": "^18.2.7", | ||
"@types/react": "18.2.21", | ||
"@types/react-dom": "18.2.7", | ||
"@types/testing-library__jest-dom": "^5.14.9", | ||
@@ -76,4 +76,4 @@ "@vitejs/plugin-react": "^4.0.4", | ||
"vite": "4.4.9", | ||
"vitest": "^0.34.4", | ||
"@axelarjs/config": "0.1.3" | ||
"vitest": "^0.34.5", | ||
"@axelarjs/config": "0.1.4" | ||
}, | ||
@@ -80,0 +80,0 @@ "dependencies": { |
99438
2353