multiformats
Advanced tools
Comparing version 10.0.0 to 10.0.1
@@ -0,1 +1,8 @@ | ||
## [10.0.1](https://github.com/multiformats/js-multiformats/compare/v10.0.0...v10.0.1) (2022-10-17) | ||
### Bug Fixes | ||
* convert byteOffset and byteLength to getters ([#215](https://github.com/multiformats/js-multiformats/issues/215)) ([4e09490](https://github.com/multiformats/js-multiformats/commit/4e09490beeba0e0a47432a7bb51112ab5f556e3f)), closes [#208](https://github.com/multiformats/js-multiformats/issues/208) [#210](https://github.com/multiformats/js-multiformats/issues/210) | ||
## [10.0.0](https://github.com/multiformats/js-multiformats/compare/v9.9.0...v10.0.0) (2022-10-12) | ||
@@ -2,0 +9,0 @@ |
@@ -160,7 +160,5 @@ export * from "./link/interface.js"; | ||
/** @readonly */ | ||
readonly byteOffset: number; | ||
/** @readonly */ | ||
readonly byteLength: number; | ||
/** @readonly */ | ||
readonly asCID: CID<Data, Format, Alg, Version>; | ||
get byteOffset(): number; | ||
get byteLength(): number; | ||
/** | ||
@@ -167,0 +165,0 @@ * @returns {CID<Data, API.DAG_PB, API.SHA_256, 0>} |
{ | ||
"name": "multiformats", | ||
"version": "10.0.0", | ||
"version": "10.0.1", | ||
"description": "Interface for multihash, multicodec, multibase and CID", | ||
@@ -5,0 +5,0 @@ "author": "Mikeal Rogers <mikeal.rogers@gmail.com> (https://www.mikealrogers.com/)", |
@@ -81,8 +81,2 @@ import * as varint from './varint.js' | ||
// ArrayBufferView | ||
/** @readonly */ | ||
this.byteOffset = bytes.byteOffset | ||
/** @readonly */ | ||
this.byteLength = bytes.byteLength | ||
// Circular reference | ||
@@ -93,2 +87,12 @@ /** @readonly */ | ||
// ArrayBufferView | ||
get byteOffset () { | ||
return this.bytes.byteOffset | ||
} | ||
// ArrayBufferView | ||
get byteLength () { | ||
return this.bytes.byteLength | ||
} | ||
/** | ||
@@ -279,2 +283,6 @@ * @returns {CID<Data, API.DAG_PB, API.SHA_256, 0>} | ||
if (!(digest.bytes instanceof Uint8Array)) { | ||
throw new Error('Invalid digest') | ||
} | ||
switch (version) { | ||
@@ -281,0 +289,0 @@ case 0: { |
@@ -711,2 +711,32 @@ /* globals describe, it */ | ||
}) | ||
describe('decode', () => { | ||
const tests = { | ||
v0: 'QmTFHZL5CkgNz19MdPnSuyLAi6AVq9fFp81zmPpaL2amED', | ||
v1: 'bafybeif2pall7dybz7vecqka3zo24irdwabwdi4wc55jznaq75q7eaavvu' | ||
} | ||
Object.entries(tests).forEach(([version, cidString]) => { | ||
it(`decode ${version} from bytes`, () => { | ||
const cid1 = CID.parse(cidString) | ||
const cid2 = CID.decode(cid1.bytes) | ||
assert.deepStrictEqual(cid1, cid2) | ||
}) | ||
it(`decode ${version} from subarray`, () => { | ||
const cid1 = CID.parse(cidString) | ||
// a byte array with an extra byte at the start and end | ||
const bytes = new Uint8Array(cid1.bytes.length + 2) | ||
bytes.set(cid1.bytes, 1) | ||
// slice the cid bytes out of the middle to have a subarray with a non-zero .byteOffset | ||
const subarray = bytes.subarray(1, cid1.bytes.length + 1) | ||
const cid2 = CID.decode(subarray) | ||
assert.deepStrictEqual(cid1, cid2) | ||
assert.equal(cid1.byteLength, cid2.byteLength) | ||
assert.equal(typeof cid2.byteOffset, 'number') | ||
}) | ||
}) | ||
}) | ||
}) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
275533
5132