@thi.ng/memoize 3.1.60 → 3.1.62

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 (3) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/README.md +24 -20
  3. package/package.json +3 -3
package/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2024-02-22T11:59:16Z
3
+ - **Last updated**: 2024-03-02T14:05:53Z
4
4
  - **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
5
5
 
6
6
  All notable changes to this project will be documented in this file.
package/README.md CHANGED
@@ -1,16 +1,5 @@
1
1
  <!-- This file is generated - DO NOT EDIT! -->
2
2
  <!-- Please see: https://github.com/thi-ng/umbrella/blob/develop/CONTRIBUTING.md#changes-to-readme-files -->
3
- > [!IMPORTANT]
4
- > ‼️ Announcing the thi.ng user survey 2024 📋
5
- >
6
- > [Please participate in the survey here!](https://forms.gle/XacbSDEmQMPZg8197)\
7
- > (open until end of February)
8
- >
9
- > **To achieve a better sample size, I'd highly appreciate if you could
10
- > circulate the link to this survey in your own networks.**
11
- >
12
- > [Discussion](https://github.com/thi-ng/umbrella/discussions/447)
13
-
14
3
  # ![@thi.ng/memoize](https://media.thi.ng/umbrella/banners-20230807/thing-memoize.svg?c436e528)
15
4
 
16
5
  [![npm version](https://img.shields.io/npm/v/@thi.ng/memoize.svg)](https://www.npmjs.com/package/@thi.ng/memoize)
@@ -22,7 +11,7 @@
22
11
  > of the [@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo
23
12
  > and anti-framework.
24
13
  >
25
- > 🚀 Help me to work full-time on these projects by [sponsoring me on
14
+ > 🚀 Please help me to work full-time on these projects by [sponsoring me on
26
15
  > GitHub](https://github.com/sponsors/postspectacular). Thank you! ❤️
27
16
 
28
17
  - [About](#about)
@@ -116,27 +105,37 @@ import { LRUCache } from "@thi.ng/cache";
116
105
  ### Optimized version for single arg functions
117
106
 
118
107
  ```ts
119
- foo = m.memoize1((x) => (console.log("exec"), x * 10));
108
+ import { memoize1 } from "@thi.ng/memoize";
109
+
110
+ foo = memoize1((x) => (console.log("exec"), x * 10));
111
+
120
112
  foo(1);
121
113
  // exec
122
114
  // 10
123
115
  foo(1);
124
116
  // 10
125
117
 
118
+ import { EquivMap } from "@thi.ng/associative";
119
+
126
120
  // with custom cache
127
- foo = m.memoize1(
121
+ foo = memoize1(
128
122
  (x) => (console.log("exec"), x[0] * 10),
123
+ // custom ES6 Map impl which compares by value, not by reference
129
124
  new EquivMap()
130
125
  );
131
126
 
132
127
  foo([1]);
133
128
  // exec
134
129
  // 10
135
- foo([1]); // wouldn't work w/ native ES6 Map as cache
130
+
131
+ // would be a cache miss w/ native ES6 Map
132
+ foo([1]);
136
133
  // 10
137
134
 
135
+ import { LRUCache } from "@thi.ng/cache";
136
+
138
137
  // use LRU cache to limit cache size
139
- foo = m.memoize1(
138
+ foo = memoize1(
140
139
  (x) => (console.log("exec"), x[0] * 10),
141
140
  new LRUCache(null, { maxlen: 3 })
142
141
  );
@@ -145,7 +144,10 @@ foo = m.memoize1(
145
144
  ### Arbitrary args
146
145
 
147
146
  ```ts
148
- dotProduct = m.memoize(
147
+ import { memoize } from "@thi.ng/memoize";
148
+ import { EquivMap } from "@thi.ng/associative";
149
+
150
+ const dotProduct = memoize(
149
151
  (x, y) => (console.log("exec"), x[0] * y[0] + x[1] * y[1]),
150
152
  new EquivMap()
151
153
  );
@@ -160,13 +162,15 @@ dotProduct([1,2], [3,4]);
160
162
  ### Via JSON.stringify()
161
163
 
162
164
  ```ts
163
- dotProduct = m.memoizeJ(
165
+ import { memoizeJ } from "@thi.ng/memoize";
166
+
167
+ const dotProduct = memoizeJ(
164
168
  (x, y) => (console.log("exec"), x[0] * y[0] + x[1] * y[1])
165
169
  );
166
- dotProduct([1,2], [3,4]);
170
+ dotProduct([1, 2], [3, 4]);
167
171
  // exec
168
172
  // 11
169
- dotProduct([1,2], [3,4]);
173
+ dotProduct([1, 2], [3, 4]);
170
174
  // 11
171
175
  ```
172
176
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/memoize",
3
- "version": "3.1.60",
3
+ "version": "3.1.62",
4
4
  "description": "Function memoization with configurable caching",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -35,7 +35,7 @@
35
35
  "test": "bun test"
36
36
  },
37
37
  "dependencies": {
38
- "@thi.ng/api": "^8.9.26"
38
+ "@thi.ng/api": "^8.9.27"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@microsoft/api-extractor": "^7.40.1",
@@ -89,5 +89,5 @@
89
89
  ],
90
90
  "year": 2018
91
91
  },
92
- "gitHead": "6e20f80dd9df1c8055ffa3c1e4d6f7598add0c0b\n"
92
+ "gitHead": "df9e312af741d87e6b450afcfea6a6e381662b1e\n"
93
93
  }