diff --git a/package.json b/package.json index 4be89e4..f9cb37c 100644 --- a/package.json +++ b/package.json @@ -37,15 +37,15 @@ "dependencies": { "class-is": "^1.1.0", "multibase": "~0.6.0", - "multicodec": "~0.5.1", - "multihashes": "~0.4.14" + "multicodec": "^1.0.0", + "multihashes": "~0.4.15" }, "devDependencies": { - "aegir": "^18.2.0", + "aegir": "^20.5.0", "chai": "^4.2.0", "dirty-chai": "^2.0.1", "multihashing": "~0.3.3", - "multihashing-async": "~0.7.0" + "multihashing-async": "~0.8.0" }, "engines": { "node": ">=4.0.0", diff --git a/src/cid-util.js b/src/cid-util.js index 8adfdd7..8a132ab 100644 --- a/src/cid-util.js +++ b/src/cid-util.js @@ -26,10 +26,10 @@ var CIDUtil = { if (other.version === 0) { if (other.codec !== 'dag-pb') { - return `codec must be 'dag-pb' for CIDv0` + return "codec must be 'dag-pb' for CIDv0" } if (other.multibaseName !== 'base58btc') { - return `multibaseName must be 'base58btc' for CIDv0` + return "multibaseName must be 'base58btc' for CIDv0" } } diff --git a/src/index.js b/src/index.js index 58a86fd..71d33bf 100644 --- a/src/index.js +++ b/src/index.js @@ -281,7 +281,7 @@ class CID { * @returns {void} */ static validateCID (other) { - let errorMsg = CIDUtil.checkCIDComponents(other) + const errorMsg = CIDUtil.checkCIDComponents(other) if (errorMsg) { throw new Error(errorMsg) } diff --git a/test/helpers/gen-cid.js b/test/helpers/gen-cid.js index 831baf3..bee8d2c 100644 --- a/test/helpers/gen-cid.js +++ b/test/helpers/gen-cid.js @@ -1,3 +1,4 @@ +/* eslint-disable no-console */ 'use strict' // CID String: diff --git a/test/index.spec.js b/test/index.spec.js index 088259b..3f7ed6c 100644 --- a/test/index.spec.js +++ b/test/index.spec.js @@ -63,13 +63,13 @@ describe('CID', () => { it('throws on trying to create a CIDv0 with a codec other than dag-pb', () => { expect( () => new CID(0, 'dag-cbor', hash) - ).to.throw(`codec must be 'dag-pb' for CIDv0`) + ).to.throw("codec must be 'dag-pb' for CIDv0") }) it('throws on trying to create a CIDv0 with a base other than base58btc', () => { expect( () => new CID(0, 'dag-pb', hash, 'base32') - ).to.throw(`multibaseName must be 'base58btc' for CIDv0`) + ).to.throw("multibaseName must be 'base58btc' for CIDv0") }) it('throws on trying to base encode CIDv0 in other base than base58btc', () => { @@ -345,7 +345,9 @@ describe('CID', () => { const hash = await multihashing(Buffer.from(`TEST${Date.now()}`), 'sha2-256') const cid = new CID(1, 'dag-pb', hash) expect(cid.buffer).to.equal(cid.buffer) - expect(Object.hasOwnProperty('buffer')).to.be.false() + // Make sure custom implementation detail properties don't leak into + // the prototype + expect(Object.prototype.hasOwnProperty.call(cid, 'buffer')).to.be.false() }) it('should cache string representation when it matches the multibaseName it was constructed with', () => { // not string to cache yet @@ -361,7 +363,9 @@ describe('CID', () => { // it cached! expect(cid.string).to.equal(base32String) - expect(Object.hasOwnProperty('_string')).to.be.false() + // Make sure custom implementation detail properties don't leak into + // the prototype + expect(Object.prototype.hasOwnProperty.call(cid, '_string')).to.be.false() expect(cid.toBaseEncodedString()).to.equal(base32String) expect(cid.toBaseEncodedString('base64')).to.equal('mAXASILp4Fr+PAc/qQUFA3l2uIiOwA2Gjlhd6nLQQ/2HyABWt') diff --git a/test/profiling/cidperf-x.js b/test/profiling/cidperf-x.js index bafc48f..340f776 100644 --- a/test/profiling/cidperf-x.js +++ b/test/profiling/cidperf-x.js @@ -1,3 +1,4 @@ +/* eslint-disable no-console */ 'use strict' const multihashing = require('multihashing') @@ -44,7 +45,7 @@ console.log(`Test: Will run "new CID()" ${reps} times.`) // We just give ~1 second for the JS engine to start and 'rest', etc. // before starting new tests. sleep(1000).then(() => { - console.log(`Starting a test...`) + console.log('Starting a test...') console.time('run'); [...Array(reps).keys()].map(i => { cidPerf.run(i) })