diff --git a/package.json b/package.json index a40bb6e..2741685 100644 --- a/package.json +++ b/package.json @@ -33,14 +33,17 @@ }, "homepage": "https://github.com/ipfs/interface-datastore#readme", "devDependencies": { - "aegir": "^20.0.0", + "aegir": "^21.4.5", "chai": "^4.1.2", "dirty-chai": "^2.0.1" }, "dependencies": { + "buffer": "^5.5.0", "class-is": "^1.1.0", "err-code": "^2.0.0", - "uuid": "^3.2.2" + "ipfs-utils": "^1.1.0", + "iso-random-stream": "^1.1.1", + "nanoid": "^2.1.11" }, "engines": { "node": ">=8.0.0", diff --git a/src/key.js b/src/key.js index c82a84b..9c08eb4 100644 --- a/src/key.js +++ b/src/key.js @@ -1,6 +1,7 @@ 'use strict' -const uuid = require('uuid/v4') +const { Buffer } = require('buffer') +const uuid = require('nanoid') const withIs = require('class-is') const pathSepS = '/' diff --git a/src/tests.js b/src/tests.js index 21a8fcf..5087533 100644 --- a/src/tests.js +++ b/src/tests.js @@ -2,10 +2,11 @@ /* eslint max-nested-callbacks: ["error", 8] */ 'use strict' +const { Buffer } = require('buffer') +const randomBytes = require('iso-random-stream/src/random') const chai = require('chai') chai.use(require('dirty-chai')) const expect = chai.expect -const crypto = require('crypto') const Key = require('../src').Key @@ -145,9 +146,9 @@ module.exports = (test) => { const b = store.batch() const count = 400 for (let i = 0; i < count; i++) { - b.put(new Key(`/a/hello${i}`), crypto.randomBytes(32)) - b.put(new Key(`/q/hello${i}`), crypto.randomBytes(64)) - b.put(new Key(`/z/hello${i}`), crypto.randomBytes(128)) + b.put(new Key(`/a/hello${i}`), randomBytes(32)) + b.put(new Key(`/q/hello${i}`), randomBytes(64)) + b.put(new Key(`/z/hello${i}`), randomBytes(128)) } await b.commit() diff --git a/src/utils.js b/src/utils.js index daab6bf..ea5459a 100644 --- a/src/utils.js +++ b/src/utils.js @@ -1,8 +1,6 @@ 'use strict' -const path = require('path') -const os = require('os') -const uuid = require('uuid/v4') +const tempdir = require('ipfs-utils/src/temp-dir') exports.filter = (iterable, filterer) => { return (async function * () { @@ -50,6 +48,4 @@ exports.replaceStartWith = function (s, r) { return s.replace(matcher, '') } -exports.tmpdir = () => { - return path.join(os.tmpdir(), uuid()) -} +exports.tmpdir = tempdir