Skip to content

Commit c0621a9

Browse files
committed
Add memize package and migrate from fast-memoize
fast-memoize doesn't support ES modules so this switches to a comparable package that does
1 parent 38e99aa commit c0621a9

File tree

8 files changed

+17
-20
lines changed

8 files changed

+17
-20
lines changed

packages/auth/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"eventemitter3": "^5.0.1",
3131
"fast-memoize": "^2.5.2",
3232
"lodash-es": "^4.17.21",
33+
"memize": "^2.1.0",
3334
"xstate": "4.26"
3435
},
3536
"publishConfig": {

packages/auth/src/util/memoize.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,9 @@
1-
import _memoize from 'fast-memoize'
2-
import { type MemoizeFunc } from 'fast-memoize/typings/fast-memoize'
1+
import memize from 'memize'
32

43
// ignore file coverage
54

65
const BYPASS = false
76

87
const passthrough = <T>(f: T) => f
98

10-
export const memoize = (BYPASS ? passthrough : _memoize) as Memoize
11-
12-
// Types that are not exported from fast-memoize
13-
14-
type Memoize = {
15-
strategies: {
16-
variadic: MemoizeFunc
17-
monadic: MemoizeFunc
18-
}
19-
} & MemoizeFunc
9+
export const memoize = (BYPASS ? passthrough : memize) as typeof memize

packages/crdx/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
"debug": "4",
2929
"events": "3",
3030
"fast-memoize": "2",
31-
"lodash-es": "^4.17.21"
31+
"lodash-es": "^4.17.21",
32+
"memize": "^2.1.0"
3233
},
3334
"publishConfig": {
3435
"access": "public"

packages/crdx/src/graph/concurrency.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import memoize from 'fast-memoize'
1+
import memize from 'memize'
22
import { getHashes, getLink } from './graph.js'
33
import { isPredecessorHash } from './predecessors.js'
44
import { isSuccessorHash } from './successors.js'
@@ -28,7 +28,7 @@ export const getConcurrentHashes = (graph: Graph<any, any>, hash: Hash): Hash[]
2828
* }
2929
* ```
3030
*/
31-
export const calculateConcurrency = memoize(<A extends Action, C>(graph: Graph<A, C>) => {
31+
export const calculateConcurrency = memize(<A extends Action, C>(graph: Graph<A, C>) => {
3232
const concurrencyLookup: Record<Hash, Hash[]> = {}
3333

3434
// for each link, find all links that are concurrent with it

packages/crdx/src/util/memoize.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
// ignore file coverage
2-
import _memoize from 'fast-memoize'
3-
import type { MemoizeFunc } from 'fast-memoize'
2+
import memize from 'memize'
43

54
const BYPASS = false
65

76
const passthrough = <T>(f: T) => f
87

9-
export const memoize = (BYPASS ? passthrough : _memoize) as MemoizeFunc
8+
export const memoize = (BYPASS ? passthrough : memize) as typeof memize

packages/crypto/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"@herbcaudill/base-x": "^4.0.6",
2929
"fast-memoize": "^2.5.2",
3030
"libsodium-wrappers-sumo": "^0.7.13",
31+
"memize": "^2.1.0",
3132
"msgpackr": "^1.8.5"
3233
},
3334
"publishConfig": {

packages/crypto/src/stretch.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import process from 'node:process'
2-
import memoize from 'fast-memoize'
2+
import memize from 'memize'
33
import sodium from 'libsodium-wrappers-sumo'
44
import { type Base58 } from './types.js'
55
import { base58, keyToBytes } from './util/index.js'
66

77
/** Derives a key from a low-entropy input, such as a password. Current version of libsodium
88
* uses the Argon2id algorithm, although that may change in later versions. */
99

10-
export const stretch = memoize((password: string) => {
10+
export const stretch = memize((password: string) => {
1111
const passwordBytes = keyToBytes(password, base58.detect(password) ? 'base58' : 'utf8')
1212
const salt = base58.decode('H5B4DLSXw5xwNYFdz1Wr6e' as Base58)
1313
if (passwordBytes.length >= 16) {

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6618,6 +6618,11 @@ [email protected]:
66186618
resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748"
66196619
integrity sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==
66206620

6621+
memize@^2.1.0:
6622+
version "2.1.0"
6623+
resolved "https://registry.yarnpkg.com/memize/-/memize-2.1.0.tgz#6ddd4717887d94825748149ece00d04cf868ce0d"
6624+
integrity sha512-yywVJy8ctVlN5lNPxsep5urnZ6TTclwPEyigM9M3Bi8vseJBOfqNrGWN/r8NzuIt3PovM323W04blJfGQfQSVg==
6625+
66216626
memory-fs@^0.2.0:
66226627
version "0.2.0"
66236628
resolved "https://registry.yarnpkg.com/memory-fs/-/memory-fs-0.2.0.tgz#f2bb25368bc121e391c2520de92969caee0a0290"

0 commit comments

Comments
 (0)