Skip to content

Commit da03ee2

Browse files
authored
fix: remove nanoid (#283)
The `Key.random` function isn't used anywhere in libp2p/helia so use a simpler key generation function that works with react-native.
1 parent 33f9197 commit da03ee2

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

packages/interface-datastore/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@
158158
},
159159
"dependencies": {
160160
"interface-store": "^5.0.0",
161-
"nanoid": "^5.0.3",
162161
"uint8arrays": "^5.0.0"
163162
},
164163
"devDependencies": {

packages/interface-datastore/src/key.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { nanoid } from 'nanoid'
21
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
32
import { type SupportedEncodings, toString as uint8ArrayToString } from 'uint8arrays/to-string'
43

@@ -103,11 +102,11 @@ export class Key {
103102
* @example
104103
* ```js
105104
* Key.random()
106-
* // => Key('/f98719ea086343f7b71f32ea9d9d521d')
105+
* // => Key('/344502982398')
107106
* ```
108107
*/
109108
static random (): Key {
110-
return new Key(nanoid().replace(/-/g, ''))
109+
return new Key(Math.random().toString().substring(2))
111110
}
112111

113112
/**

0 commit comments

Comments
 (0)