multiformats
Advanced tools
Comparing version 8.0.6 to 9.0.0
@@ -185,3 +185,4 @@ 'use strict'; | ||
codec = next(); | ||
} else if (version !== 1) { | ||
} | ||
if (version !== 0 && version !== 1) { | ||
throw new RangeError(`Invalid CID version ${ version }`); | ||
@@ -188,0 +189,0 @@ } |
@@ -180,3 +180,4 @@ import * as varint from './varint.js'; | ||
codec = next(); | ||
} else if (version !== 1) { | ||
} | ||
if (version !== 0 && version !== 1) { | ||
throw new RangeError(`Invalid CID version ${ version }`); | ||
@@ -183,0 +184,0 @@ } |
{ | ||
"name": "multiformats", | ||
"version": "8.0.6", | ||
"version": "9.0.0", | ||
"description": "Interface for multihash, multicodec, multibase and CID", | ||
@@ -5,0 +5,0 @@ "main": "./cjs/src/index.js", |
@@ -9,2 +9,3 @@ import * as varint from './varint.js' | ||
* @typedef {import('./hashes/interface').MultihashDigest} MultihashDigest | ||
* @typedef {0 | 1} CIDVersion | ||
*/ | ||
@@ -24,3 +25,3 @@ | ||
/** | ||
* @param {0|1} version | ||
* @param {CIDVersion} version | ||
* @param {number} code | ||
@@ -223,3 +224,3 @@ * @param {MultihashDigest} multihash | ||
* | ||
* @param {number} version - Version of the CID | ||
* @param {CIDVersion} version - Version of the CID | ||
* @param {number} code - Code of the codec content is encoded in. | ||
@@ -324,3 +325,3 @@ * @param {MultihashDigest} digest - (Multi)hash of the of the content. | ||
* @param {Uint8Array} initialBytes | ||
* @returns {{ version:number, codec:number, multihashCode:number, digestSize:number, multihashSize:number, size:number }} | ||
* @returns {{ version:CIDVersion, codec:number, multihashCode:number, digestSize:number, multihashSize:number, size:number }} | ||
*/ | ||
@@ -342,3 +343,5 @@ static inspectBytes (initialBytes) { | ||
codec = next() | ||
} else if (version !== 1) { | ||
} | ||
if (version !== 0 && version !== 1) { | ||
throw new RangeError(`Invalid CID version ${version}`) | ||
@@ -452,4 +455,3 @@ } | ||
/** | ||
* | ||
* @param {number} version | ||
* @param {CIDVersion} version | ||
* @param {number} code | ||
@@ -456,0 +458,0 @@ * @param {Uint8Array} multihash |
/** | ||
* @typedef {import('./hashes/interface').MultihashDigest} MultihashDigest | ||
* @typedef {0 | 1} CIDVersion | ||
*/ | ||
@@ -33,3 +34,3 @@ /** | ||
* | ||
* @param {number} version - Version of the CID | ||
* @param {CIDVersion} version - Version of the CID | ||
* @param {number} code - Code of the codec content is encoded in. | ||
@@ -39,3 +40,3 @@ * @param {MultihashDigest} digest - (Multi)hash of the of the content. | ||
*/ | ||
static create(version: number, code: number, digest: MultihashDigest): CID; | ||
static create(version: CIDVersion, code: number, digest: MultihashDigest): CID; | ||
/** | ||
@@ -88,6 +89,6 @@ * Simplified version of `create` for CIDv0. | ||
* @param {Uint8Array} initialBytes | ||
* @returns {{ version:number, codec:number, multihashCode:number, digestSize:number, multihashSize:number, size:number }} | ||
* @returns {{ version:CIDVersion, codec:number, multihashCode:number, digestSize:number, multihashSize:number, size:number }} | ||
*/ | ||
static inspectBytes(initialBytes: Uint8Array): { | ||
version: number; | ||
version: CIDVersion; | ||
codec: number; | ||
@@ -111,3 +112,3 @@ multihashCode: number; | ||
/** | ||
* @param {0|1} version | ||
* @param {CIDVersion} version | ||
* @param {number} code | ||
@@ -118,5 +119,5 @@ * @param {MultihashDigest} multihash | ||
*/ | ||
constructor(version: 0 | 1, code: number, multihash: MultihashDigest, bytes: Uint8Array); | ||
constructor(version: CIDVersion, code: number, multihash: MultihashDigest, bytes: Uint8Array); | ||
code: number; | ||
version: 0 | 1; | ||
version: CIDVersion; | ||
multihash: import("./hashes/interface").MultihashDigest; | ||
@@ -152,3 +153,3 @@ bytes: Uint8Array; | ||
code: number; | ||
version: 0 | 1; | ||
version: CIDVersion; | ||
hash: Uint8Array; | ||
@@ -164,4 +165,5 @@ }; | ||
export type MultihashDigest = import('./hashes/interface').MultihashDigest; | ||
export type CIDVersion = 0 | 1; | ||
export type MultibaseEncoder<Prefix> = import('./bases/interface').MultibaseEncoder<Prefix>; | ||
export type MultibaseDecoder<Prefix> = import('./bases/interface').MultibaseDecoder<Prefix>; | ||
//# sourceMappingURL=cid.d.ts.map |
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
374167
10901