Skip to content
This repository was archived by the owner on Sep 9, 2021. It is now read-only.

fix: remove node globals #35

Merged
merged 2 commits into from
Apr 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion src/key.js
Original file line number Diff line number Diff line change
@@ -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 = '/'
Expand Down
9 changes: 5 additions & 4 deletions src/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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()
Expand Down
8 changes: 2 additions & 6 deletions src/utils.js
Original file line number Diff line number Diff line change
@@ -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 * () {
Expand Down Expand Up @@ -50,6 +48,4 @@ exports.replaceStartWith = function (s, r) {
return s.replace(matcher, '')
}

exports.tmpdir = () => {
return path.join(os.tmpdir(), uuid())
}
exports.tmpdir = tempdir