Skip to content

Commit

Permalink
fix: remove nanoid (#283)
Browse files Browse the repository at this point in the history
The `Key.random` function isn't used anywhere in libp2p/helia so
use a simpler key generation function that works with react-native.
  • Loading branch information
achingbrain committed Dec 8, 2023
1 parent 33f9197 commit da03ee2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
1 change: 0 additions & 1 deletion packages/interface-datastore/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@
},
"dependencies": {
"interface-store": "^5.0.0",
"nanoid": "^5.0.3",
"uint8arrays": "^5.0.0"
},
"devDependencies": {
Expand Down
5 changes: 2 additions & 3 deletions packages/interface-datastore/src/key.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { nanoid } from 'nanoid'
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
import { type SupportedEncodings, toString as uint8ArrayToString } from 'uint8arrays/to-string'

Expand Down Expand Up @@ -103,11 +102,11 @@ export class Key {
* @example
* ```js
* Key.random()
* // => Key('/f98719ea086343f7b71f32ea9d9d521d')
* // => Key('/344502982398')
* ```
*/
static random (): Key {
return new Key(nanoid().replace(/-/g, ''))
return new Key(Math.random().toString().substring(2))
}

/**
Expand Down

0 comments on commit da03ee2

Please sign in to comment.