@thi.ng/memoize
Advanced tools
Comparing version 3.1.61 to 3.1.62
# Change Log | ||
- **Last updated**: 2024-03-01T15:22:50Z | ||
- **Last updated**: 2024-03-02T14:05:53Z | ||
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub) | ||
@@ -5,0 +5,0 @@ |
{ | ||
"name": "@thi.ng/memoize", | ||
"version": "3.1.61", | ||
"version": "3.1.62", | ||
"description": "Function memoization with configurable caching", | ||
@@ -92,3 +92,3 @@ "type": "module", | ||
}, | ||
"gitHead": "d660ae8fd1bf64d919b4334f19509f1f539d70f6\n" | ||
"gitHead": "df9e312af741d87e6b450afcfea6a6e381662b1e\n" | ||
} |
@@ -108,3 +108,6 @@ <!-- This file is generated - DO NOT EDIT! --> | ||
```ts | ||
foo = m.memoize1((x) => (console.log("exec"), x * 10)); | ||
import { memoize1 } from "@thi.ng/memoize"; | ||
foo = memoize1((x) => (console.log("exec"), x * 10)); | ||
foo(1); | ||
@@ -116,5 +119,8 @@ // exec | ||
import { EquivMap } from "@thi.ng/associative"; | ||
// with custom cache | ||
foo = m.memoize1( | ||
foo = memoize1( | ||
(x) => (console.log("exec"), x[0] * 10), | ||
// custom ES6 Map impl which compares by value, not by reference | ||
new EquivMap() | ||
@@ -126,7 +132,11 @@ ); | ||
// 10 | ||
foo([1]); // wouldn't work w/ native ES6 Map as cache | ||
// would be a cache miss w/ native ES6 Map | ||
foo([1]); | ||
// 10 | ||
import { LRUCache } from "@thi.ng/cache"; | ||
// use LRU cache to limit cache size | ||
foo = m.memoize1( | ||
foo = memoize1( | ||
(x) => (console.log("exec"), x[0] * 10), | ||
@@ -140,3 +150,6 @@ new LRUCache(null, { maxlen: 3 }) | ||
```ts | ||
dotProduct = m.memoize( | ||
import { memoize } from "@thi.ng/memoize"; | ||
import { EquivMap } from "@thi.ng/associative"; | ||
const dotProduct = memoize( | ||
(x, y) => (console.log("exec"), x[0] * y[0] + x[1] * y[1]), | ||
@@ -156,9 +169,11 @@ new EquivMap() | ||
```ts | ||
dotProduct = m.memoizeJ( | ||
import { memoizeJ } from "@thi.ng/memoize"; | ||
const dotProduct = memoizeJ( | ||
(x, y) => (console.log("exec"), x[0] * y[0] + x[1] * y[1]) | ||
); | ||
dotProduct([1,2], [3,4]); | ||
dotProduct([1, 2], [3, 4]); | ||
// exec | ||
// 11 | ||
dotProduct([1,2], [3,4]); | ||
dotProduct([1, 2], [3, 4]); | ||
// 11 | ||
@@ -165,0 +180,0 @@ ``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30911
195