OXIESEC PANEL
- Current Dir:
/
/
var
/
www
/
reader
/
API
/
swagger-ui-5.17.14
/
src
/
core
/
utils
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
08/07/2024 04:34:11 AM
rwxr-xr-x
📄
create-html-ready-id.js
444 bytes
08/07/2024 04:33:55 AM
rw-r--r--
📄
get-parameter-schema.js
2.3 KB
08/07/2024 04:33:55 AM
rw-r--r--
📄
index.js
22.91 KB
08/07/2024 04:33:55 AM
rw-r--r--
📄
jsonParse.js
415 bytes
08/07/2024 04:33:55 AM
rw-r--r--
📄
memoizeN.js
1.18 KB
08/07/2024 04:33:55 AM
rw-r--r--
📄
url.js
1.13 KB
08/07/2024 04:33:55 AM
rw-r--r--
Editing: memoizeN.js
Close
import memoize from "lodash/memoize" /** * This function is extension on top of lodash.memoize. * It uses all the arguments of the `fn` as the cache key instead of just the first one. * If resolver is provided, it determines the cache key for * storing the result based on the arguments provided to the memoized function. */ const shallowArrayEquals = (a) => (b) => { return Array.isArray(a) && Array.isArray(b) && a.length === b.length && a.every((val, index) => val === b[index]) } const list = (...args) => args class Cache extends Map { delete(key) { const keys = Array.from(this.keys()) const foundKey = keys.find(shallowArrayEquals(key)) return super.delete(foundKey) } get(key) { const keys = Array.from(this.keys()) const foundKey = keys.find(shallowArrayEquals(key)) return super.get(foundKey) } has(key) { const keys = Array.from(this.keys()) return keys.findIndex(shallowArrayEquals(key)) !== -1 } } const memoizeN = (fn, resolver = list) => { const { Cache: OriginalCache } = memoize memoize.Cache = Cache const memoized = memoize(fn, resolver) memoize.Cache = OriginalCache return memoized } export default memoizeN