@domql/utils 2.3.0 → 2.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/object.js +14 -0
  2. package/package.json +2 -2
package/object.js CHANGED
@@ -223,3 +223,17 @@ export const flattenRecursive = (param, prop, stack = []) => {
223
223
 
224
224
  return stack
225
225
  }
226
+
227
+ export const memoize = (fn) => {
228
+ const cache = {}
229
+ return (...args) => {
230
+ const n = args[0]
231
+ if (n in cache) {
232
+ return cache[n]
233
+ } else {
234
+ const result = fn(n)
235
+ cache[n] = result
236
+ return result
237
+ }
238
+ }
239
+ }
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@domql/utils",
3
- "version": "2.3.0",
3
+ "version": "2.3.5",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "dependencies": {
7
7
  "@domql/tags": "latest"
8
8
  },
9
- "gitHead": "02944ad228d2cf5f5727b08e9378d221b2f7205b",
9
+ "gitHead": "9f1a47a59fa1512a593714401583b8286e6f2bff",
10
10
  "source": "index.js"
11
11
  }