Moving '__tests__' To 'test'

This commit is contained in:
Damien Chazoule
2021-10-05 08:50:12 +02:00
parent c8fd5353ba
commit 8bce33d265
2 changed files with 3 additions and 9 deletions

View File

@ -4,24 +4,18 @@
* @returns * @returns
*/ */
export const memoize = (func) => { export const memoize = (func) => {
// eslint-disable-next-line no-console // Initializing new cache
console.log(`Creating cache for function '${func.name}'`)
const cache = {} const cache = {}
return (...args) => { return (...args) => {
const [arg] = args const [arg] = args
if (arg in cache) { if (arg in cache) {
// eslint-disable-next-line no-console // Reading cache by argument
console.log(`Reading cache with argument ${arg}`)
return cache[arg] return cache[arg]
} }
// eslint-disable-next-line no-console // Updating cache by argument
console.log(`Updating cache with argument ${arg}`)
const result = func(arg) const result = func(arg)
cache[arg] = result cache[arg] = result
return result return result