You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+26Lines changed: 26 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,31 @@
1
1
# micro-memoize CHANGELOG
2
2
3
+
## 5.0.0
4
+
5
+
**Smaller, faster, with more features**
6
+
7
+
This is a complete rewrite of the library that improves bundle size and runtime performance while also offering more features. If you are using the simple use case of `memoize(fn)` then you should have no impact. However, if you were making use of specific options, you will be impacted.
8
+
9
+
### Breaking changes
10
+
11
+
-`isPromise` has been renamed to `async`, to more clearly identify the type of function it is vs what the result of calling it will be
12
+
-`isEqual` has been renamed to `isArgEqual`, for better clarity vs `isMatchingKey`
13
+
-`isMatchingKey` has been renamed to `isKeyEqual`, for better clarity vs `isEqual`
14
+
-`onCacheAdd` / `onCacheChange` / `onCacheHit` has been rearchitected entirely into a dynamic event listener on the `memoized.cache` namespace
15
+
-`memoized.cache.snapshot` has renamed to `memoized.cache.entries()` to align with common conventions of `Map`
16
+
- Returns an array of `[Key, value]` pairs instead of `{keys: Key[], size: number, values: any[]}` to align with common JS conventions and allow direct population of `Map` / `WeakMap`
17
+
-`memoized.options` is now a transparent pass-through of the options provided, instead storing the normalized version
18
+
19
+
### Enhancements
20
+
21
+
- Speed improvements
22
+
- Reduction in bundle size
23
+
- Cache manipulation is easier with added methods:
24
+
-`memoized.cache.delete(key)`
25
+
-`memoized.cache.get(key)`
26
+
-`memoized.cache.has(key)`
27
+
-`memoized.cache.set(key, value)`
28
+
3
29
## 4.1.2
4
30
5
31
- Republish of [#102](https://github.com/planttheidea/micro-memoize/pull/102)
Copy file name to clipboardExpand all lines: README.md
+43-43Lines changed: 43 additions & 43 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,8 +12,8 @@ A tiny, crazy [fast](#benchmarks) memoization library for the 95% use-case
12
12
-[Composition](#composition)
13
13
-[Options](#options)
14
14
-[async](#async)
15
-
-[isArgEqual](#matchesarg)
16
-
-[isKeyEqual](#matcheskey)
15
+
-[isArgEqual](#isargequal)
16
+
-[isKeyEqual](#iskeyequal)
17
17
-[maxSize](#maxsize)
18
18
-[transformKey](#transformkey)
19
19
-[Cache](#cache)
@@ -505,7 +505,7 @@ The [`options`](#options) passed when creating the memoized method.
505
505
506
506
All values provided are the number of operations per second (ops/sec) calculated by the [Benchmark suite](https://benchmarkjs.com/). Note that `underscore`, `lodash`, and `ramda` do not support mulitple-parameter memoization (which is where `micro-memoize` really shines), so they are not included in those benchmarks.
507
507
508
-
Benchmarks was performed on an i7 8-core Arch Linux laptop with 16GB of memory using NodeJS version `10.15.0`. The default configuration of each library was tested with a fibonacci calculation based on the following parameters:
508
+
Benchmarks was performed on an i9 16-core Arch Linux laptop with 64GB of memory using NodeJS version `18.19.0`. The default configuration of each library was tested with a fibonacci calculation based on the following parameters:
509
509
510
510
- Single primitive = `35`
511
511
- Single object = `{number: 35}`
@@ -520,67 +520,67 @@ This is usually what benchmarks target for ... its the least-likely use-case, bu
520
520
521
521
|| Operations / second |
522
522
| ----------------- | ------------------- |
523
-
|fast-memoize| 59,069,204 |
524
-
|**micro-memoize**|**48,267,295**|
525
-
|lru-memoize| 46,781,143 |
526
-
|Addy Osmani| 32,372,414 |
527
-
|lodash | 29,297,916|
528
-
|ramda| 25,054,838|
529
-
|mem| 24,848,072|
530
-
|underscore| 24,847,818|
531
-
| memoizee |18,272,987|
532
-
| memoizerific |7,302,835 |
523
+
|**micro-memoize**|**121,740,174**|
524
+
|fast-memoize| 110,892,952 |
525
+
|mem| 104,487,931|
526
+
|lru-memoize | 103,134,780|
527
+
|Addy Osmani| 71,287,174|
528
+
|underscore| 60,782,053|
529
+
|lodash| 56,091,762|
530
+
|ramda| 49,892,367|
531
+
| memoizee |47,142,953|
532
+
| memoizerific |18,708,398|
533
533
534
534
### Single parameter (complex object)
535
535
536
536
This is what most memoization libraries target as the primary use-case, as it removes the complexities of multiple arguments but allows for usage with one to many values.
537
537
538
538
|| Operations / second |
539
539
| ----------------- | ------------------- |
540
-
|**micro-memoize**|**40,360,621**|
541
-
| lodash |30,862,028|
542
-
| lru-memoize |25,740,572|
543
-
| memoizee |12,058,375|
544
-
| memoizerific |6,854,855 |
545
-
| ramda |2,287,030|
546
-
| underscore |2,270,574|
547
-
|Addy Osmani| 2,076,031|
548
-
|mem | 2,001,984|
549
-
| fast-memoize |1,591,019|
540
+
|**micro-memoize**|**59,189,580**|
541
+
| lodash |53,370,488|
542
+
| lru-memoize |43,956,168|
543
+
| memoizee |27,109,412|
544
+
| memoizerific |16,657,400|
545
+
| ramda |4,831,034|
546
+
| underscore |4,596,231|
547
+
|mem | 4,159,677|
548
+
|Addy Osmani| 3,931,473|
549
+
| fast-memoize |2,390,688|
550
550
551
551
### Multiple parameters (primitives only)
552
552
553
553
This is a very common use-case for function calls, but can be more difficult to optimize because you need to account for multiple possibilities ... did the number of arguments change, are there default arguments, etc.
554
554
555
555
|| Operations / second |
556
556
| ----------------- | ------------------- |
557
-
|**micro-memoize**|**33,546,353**|
558
-
| lru-memoize |20,884,669|
559
-
| memoizee |7,831,161 |
560
-
|Addy Osmani| 6,447,448 |
561
-
|memoizerific | 5,587,779|
562
-
| mem |2,620,943|
563
-
|underscore| 1,617,687|
564
-
|ramda| 1,569,167|
565
-
|lodash| 1,512,515|
566
-
|fast-memoize| 1,376,665|
557
+
|**micro-memoize**|**47,199,467**|
558
+
| lru-memoize |39,757,821|
559
+
| memoizee |17,539,760|
560
+
|memoizerific | 11,917,711|
561
+
|Addy Osmani| 9,495,702|
562
+
| mem |6.334.600|
563
+
|ramda| 2,408,712|
564
+
|underscore| 2,359,704|
565
+
|fast-memoize| 2,173,298|
566
+
|lodash| 2,148,902|
567
567
568
568
### Multiple parameters (complex objects)
569
569
570
570
This is the most robust use-case, with the same complexities as multiple primitives but managing bulkier objects with additional edge scenarios (destructured with defaults, for example).
0 commit comments