Comparing version 3.0.2-rc.0 to 3.1.0
@@ -1,2 +0,2 @@ | ||
## [3.0.2-rc.0](https://github.com/multiformats/js-multibase/compare/v3.0.1...v3.0.2-rc.0) (2020-11-18) | ||
# [3.1.0](https://github.com/multiformats/js-multibase/compare/v3.0.1...v3.1.0) (2020-11-20) | ||
@@ -6,3 +6,3 @@ | ||
* add ts types ([53f0001](https://github.com/multiformats/js-multibase/commit/53f00013b8e61279bc7c0ea223a9a36bc29d3b00)) | ||
* add ts types ([#72](https://github.com/multiformats/js-multibase/issues/72)) ([6e083f0](https://github.com/multiformats/js-multibase/commit/6e083f0353835c3598dfa2e61a86016a8ec85f75)) | ||
@@ -9,0 +9,0 @@ |
export = Base; | ||
/** @typedef {import('./types').CodecFactory} CodecFactory */ | ||
/** @typedef {import("./types").BaseNames} BaseNames */ | ||
/** @typedef {import("./types").BaseCodes} BaseCodes */ | ||
/** @typedef {import("./types").BaseName} BaseName */ | ||
/** @typedef {import("./types").BaseCode} BaseCode */ | ||
/** | ||
* Class | ||
* Class to encode/decode in the supported Bases | ||
* | ||
@@ -11,10 +11,10 @@ */ | ||
/** | ||
* @param {BaseNames} name | ||
* @param {BaseCodes} code | ||
* @param {BaseName} name | ||
* @param {BaseCode} code | ||
* @param {CodecFactory} factory | ||
* @param {string} alphabet | ||
*/ | ||
constructor(name: BaseNames, code: BaseCodes, factory: CodecFactory, alphabet: string); | ||
name: import("./types").BaseNames; | ||
code: import("./types").BaseCodes; | ||
constructor(name: BaseName, code: BaseCode, factory: CodecFactory, alphabet: string); | ||
name: import("./types").BaseName; | ||
code: import("./types").BaseCode; | ||
codeBuf: Uint8Array; | ||
@@ -35,7 +35,7 @@ alphabet: string; | ||
declare namespace Base { | ||
export { CodecFactory, BaseNames, BaseCodes }; | ||
export { CodecFactory, BaseName, BaseCode }; | ||
} | ||
type BaseNames = "identity" | "base2" | "base8" | "base10" | "base16" | "base16upper" | "base32hex" | "base32hexupper" | "base32hexpad" | "base32hexpadupper" | "base32" | "base32upper" | "base32pad" | "base32padupper" | "base32z" | "base36" | "base36upper" | "base58btc" | "base58flickr" | "base64" | "base64pad" | "base64url" | "base64urlpad"; | ||
type BaseCodes = "\0" | "0" | "7" | "9" | "f" | "F" | "v" | "V" | "t" | "T" | "b" | "B" | "c" | "C" | "h" | "k" | "K" | "z" | "Z" | "m" | "M" | "u" | "U"; | ||
type BaseName = "identity" | "base2" | "base8" | "base10" | "base16" | "base16upper" | "base32hex" | "base32hexupper" | "base32hexpad" | "base32hexpadupper" | "base32" | "base32upper" | "base32pad" | "base32padupper" | "base32z" | "base36" | "base36upper" | "base58btc" | "base58flickr" | "base64" | "base64pad" | "base64url" | "base64urlpad"; | ||
type BaseCode = "\0" | "0" | "7" | "9" | "f" | "F" | "v" | "V" | "t" | "T" | "b" | "B" | "c" | "C" | "h" | "k" | "K" | "z" | "Z" | "m" | "M" | "u" | "U"; | ||
type CodecFactory = (input: string) => import("./types").Codec; | ||
//# sourceMappingURL=base.d.ts.map |
@@ -6,8 +6,9 @@ export type CodecFactory = (input: string) => import("./types.js").Codec; | ||
}; | ||
export type BaseNames = "identity" | "base2" | "base8" | "base10" | "base16" | "base16upper" | "base32hex" | "base32hexupper" | "base32hexpad" | "base32hexpadupper" | "base32" | "base32upper" | "base32pad" | "base32padupper" | "base32z" | "base36" | "base36upper" | "base58btc" | "base58flickr" | "base64" | "base64pad" | "base64url" | "base64urlpad"; | ||
export type BaseCodes = "\0" | "0" | "7" | "9" | "f" | "F" | "v" | "V" | "t" | "T" | "b" | "B" | "c" | "C" | "h" | "k" | "K" | "z" | "Z" | "m" | "M" | "u" | "U"; | ||
/** @type {Record<BaseNames,Base>} */ | ||
export const names: Record<BaseNames, import("./base.js")>; | ||
/** @type {Record<BaseCodes,Base>} */ | ||
export const codes: Record<BaseCodes, import("./base.js")>; | ||
export type BaseName = "identity" | "base2" | "base8" | "base10" | "base16" | "base16upper" | "base32hex" | "base32hexupper" | "base32hexpad" | "base32hexpadupper" | "base32" | "base32upper" | "base32pad" | "base32padupper" | "base32z" | "base36" | "base36upper" | "base58btc" | "base58flickr" | "base64" | "base64pad" | "base64url" | "base64urlpad"; | ||
export type BaseCode = "\0" | "0" | "7" | "9" | "f" | "F" | "v" | "V" | "t" | "T" | "b" | "B" | "c" | "C" | "h" | "k" | "K" | "z" | "Z" | "m" | "M" | "u" | "U"; | ||
/** @type {Record<BaseName,Base>} */ | ||
export const names: Record<BaseName, Base>; | ||
/** @type {Record<BaseCode,Base>} */ | ||
export const codes: Record<BaseCode, Base>; | ||
import Base = require("./base.js"); | ||
//# sourceMappingURL=constants.d.ts.map |
export = multibase; | ||
/** @typedef {import('./base')} Base */ | ||
/** @typedef {import("./types").BaseNamesCodes} BaseNamesCodes */ | ||
/** @typedef {import("./types").BaseCodes} BaseCodes */ | ||
/** @typedef {import("./types").BaseNameOrCode} BaseNameOrCode */ | ||
/** @typedef {import("./types").BaseCode} BaseCode */ | ||
/** | ||
* Create a new Uint8Array with the multibase varint+code. | ||
* | ||
* @param {BaseNamesCodes} nameOrCode - The multibase name or code number. | ||
* @param {BaseNameOrCode} nameOrCode - The multibase name or code number. | ||
* @param {Uint8Array} buf - The data to be prefixed with multibase. | ||
@@ -13,11 +13,11 @@ * @returns {Uint8Array} | ||
*/ | ||
declare function multibase(nameOrCode: BaseNamesCodes, buf: Uint8Array): Uint8Array; | ||
declare function multibase(nameOrCode: BaseNameOrCode, buf: Uint8Array): Uint8Array; | ||
declare namespace multibase { | ||
export { encode, decode, isEncoded, encoding, encodingFromData, names, codes, Base, BaseNamesCodes, BaseCodes }; | ||
export { encode, decode, isEncoded, encoding, encodingFromData, names, codes, Base, BaseNameOrCode, BaseCode }; | ||
} | ||
type BaseNamesCodes = "\0" | "0" | "7" | "9" | "f" | "F" | "v" | "V" | "t" | "T" | "b" | "B" | "c" | "C" | "h" | "k" | "K" | "z" | "Z" | "m" | "M" | "u" | "U" | "identity" | "base2" | "base8" | "base10" | "base16" | "base16upper" | "base32hex" | "base32hexupper" | "base32hexpad" | "base32hexpadupper" | "base32" | "base32upper" | "base32pad" | "base32padupper" | "base32z" | "base36" | "base36upper" | "base58btc" | "base58flickr" | "base64" | "base64pad" | "base64url" | "base64urlpad"; | ||
type BaseNameOrCode = "\0" | "0" | "7" | "9" | "f" | "F" | "v" | "V" | "t" | "T" | "b" | "B" | "c" | "C" | "h" | "k" | "K" | "z" | "Z" | "m" | "M" | "u" | "U" | "identity" | "base2" | "base8" | "base10" | "base16" | "base16upper" | "base32hex" | "base32hexupper" | "base32hexpad" | "base32hexpadupper" | "base32" | "base32upper" | "base32pad" | "base32padupper" | "base32z" | "base36" | "base36upper" | "base58btc" | "base58flickr" | "base64" | "base64pad" | "base64url" | "base64urlpad"; | ||
/** | ||
* Encode data with the specified base and add the multibase prefix. | ||
* | ||
* @param {BaseNamesCodes} nameOrCode - The multibase name or code number. | ||
* @param {BaseNameOrCode} nameOrCode - The multibase name or code number. | ||
* @param {Uint8Array} buf - The data to be encoded. | ||
@@ -28,3 +28,3 @@ * @returns {Uint8Array} | ||
*/ | ||
declare function encode(nameOrCode: BaseNamesCodes, buf: Uint8Array): Uint8Array; | ||
declare function encode(nameOrCode: BaseNameOrCode, buf: Uint8Array): Uint8Array; | ||
/** | ||
@@ -44,13 +44,13 @@ * Takes a Uint8Array or string encoded with multibase header, decodes it and | ||
* @param {Uint8Array|string} data | ||
* @returns {boolean | string} | ||
* @returns {false | string} | ||
*/ | ||
declare function isEncoded(data: Uint8Array | string): boolean | string; | ||
declare function isEncoded(data: Uint8Array | string): false | string; | ||
/** | ||
* Get the encoding by name or code | ||
* | ||
* @param {BaseNamesCodes} nameOrCode | ||
* @param {BaseNameOrCode} nameOrCode | ||
* @returns {Base} | ||
* @throws {Error} Will throw if the encoding is not supported | ||
*/ | ||
declare function encoding(nameOrCode: BaseNamesCodes): Base; | ||
declare function encoding(nameOrCode: BaseNameOrCode): Base; | ||
/** | ||
@@ -64,6 +64,6 @@ * Get encoding from data | ||
declare function encodingFromData(data: string | Uint8Array): Base; | ||
declare var names: Readonly<Record<import("./types").BaseNames, import("./base")>>; | ||
declare var codes: Readonly<Record<import("./types").BaseCodes, import("./base")>>; | ||
declare var names: Readonly<Record<import("./types").BaseName, import("./base")>>; | ||
declare var codes: Readonly<Record<import("./types").BaseCode, import("./base")>>; | ||
type Base = import("./base"); | ||
type BaseCodes = "\0" | "0" | "7" | "9" | "f" | "F" | "v" | "V" | "t" | "T" | "b" | "B" | "c" | "C" | "h" | "k" | "K" | "z" | "Z" | "m" | "M" | "u" | "U"; | ||
type BaseCode = "\0" | "0" | "7" | "9" | "f" | "F" | "v" | "V" | "t" | "T" | "b" | "B" | "c" | "C" | "h" | "k" | "K" | "z" | "Z" | "m" | "M" | "u" | "U"; | ||
//# sourceMappingURL=index.d.ts.map |
/** | ||
* - Codes of the supported encodings | ||
*/ | ||
export declare type BaseCodes = '\x00' | '0' | '7' | '9' | 'f' | 'F' | 'v' | 'V' | 't' | 'T' | 'b' | 'B' | 'c' | 'C' | 'h' | 'k' | 'K' | 'z' | 'Z' | 'm' | 'M' | 'u' | 'U'; | ||
export declare type BaseCode = '\x00' | '0' | '7' | '9' | 'f' | 'F' | 'v' | 'V' | 't' | 'T' | 'b' | 'B' | 'c' | 'C' | 'h' | 'k' | 'K' | 'z' | 'Z' | 'm' | 'M' | 'u' | 'U'; | ||
/** | ||
* - Names of the supported encodings | ||
*/ | ||
export declare type BaseNames = 'identity' | 'base2' | 'base8' | 'base10' | 'base16' | 'base16upper' | 'base32hex' | 'base32hexupper' | 'base32hexpad' | 'base32hexpadupper' | 'base32' | 'base32upper' | 'base32pad' | 'base32padupper' | 'base32z' | 'base36' | 'base36upper' | 'base58btc' | 'base58flickr' | 'base64' | 'base64pad' | 'base64url' | 'base64urlpad'; | ||
export declare type BaseNamesCodes = BaseCodes | BaseNames; | ||
export declare type BaseName = 'identity' | 'base2' | 'base8' | 'base10' | 'base16' | 'base16upper' | 'base32hex' | 'base32hexupper' | 'base32hexpad' | 'base32hexpadupper' | 'base32' | 'base32upper' | 'base32pad' | 'base32padupper' | 'base32z' | 'base36' | 'base36upper' | 'base58btc' | 'base58flickr' | 'base64' | 'base64pad' | 'base64url' | 'base64urlpad'; | ||
export declare type BaseNameOrCode = BaseCode | BaseName; | ||
export declare type Codec = { | ||
@@ -11,0 +11,0 @@ encode: (buffer: Uint8Array) => string; |
{ | ||
"name": "multibase", | ||
"version": "3.0.2-rc.0", | ||
"version": "3.1.0", | ||
"description": "JavaScript implementation of the multibase specification", | ||
@@ -41,3 +41,3 @@ "keywords": [ | ||
"devDependencies": { | ||
"aegir": "github:ipfs/aegir#feat/ts-cmd", | ||
"aegir": "^29.0.1", | ||
"benchmark": "^2.1.4" | ||
@@ -52,7 +52,8 @@ }, | ||
}, | ||
"types": "./dist/src/index.d.ts", | ||
"types": "dist/src/index.d.ts", | ||
"typesVersions": { | ||
"*": { | ||
"src/*": [ | ||
"dist/src/*" | ||
"dist/src/*", | ||
"dist/src/*/index" | ||
] | ||
@@ -59,0 +60,0 @@ } |
@@ -37,3 +37,3 @@ js-multibase <!-- omit in toc --> | ||
Loading this module through a script tag will make the ```Multibase``` obj available in the global namespace. | ||
Loading this module through a script tag will make the `Multibase` obj available in the global namespace. | ||
@@ -40,0 +40,0 @@ ```html |
@@ -6,7 +6,7 @@ 'use strict' | ||
/** @typedef {import('./types').CodecFactory} CodecFactory */ | ||
/** @typedef {import("./types").BaseNames} BaseNames */ | ||
/** @typedef {import("./types").BaseCodes} BaseCodes */ | ||
/** @typedef {import("./types").BaseName} BaseName */ | ||
/** @typedef {import("./types").BaseCode} BaseCode */ | ||
/** | ||
* Class | ||
* Class to encode/decode in the supported Bases | ||
* | ||
@@ -16,4 +16,4 @@ */ | ||
/** | ||
* @param {BaseNames} name | ||
* @param {BaseCodes} code | ||
* @param {BaseName} name | ||
* @param {BaseCode} code | ||
* @param {CodecFactory} factory | ||
@@ -20,0 +20,0 @@ * @param {string} alphabet |
@@ -10,4 +10,4 @@ 'use strict' | ||
/** @typedef {import('./types').Codec} Codec */ | ||
/** @typedef {import('./types').BaseNames} BaseNames */ | ||
/** @typedef {import('./types').BaseCodes} BaseCodes */ | ||
/** @typedef {import('./types').BaseName} BaseName */ | ||
/** @typedef {import('./types').BaseCode} BaseCode */ | ||
@@ -26,3 +26,3 @@ /** @type {CodecFactory} */ | ||
* | ||
* @type {Array<[BaseNames, BaseCodes, CodecFactory, string]>} | ||
* @type {Array<[BaseName, BaseCode, CodecFactory, string]>} | ||
*/ | ||
@@ -55,13 +55,13 @@ const constants = [ | ||
/** @type {Record<BaseNames,Base>} */ | ||
/** @type {Record<BaseName,Base>} */ | ||
const names = constants.reduce((prev, tupple) => { | ||
prev[tupple[0]] = new Base(tupple[0], tupple[1], tupple[2], tupple[3]) | ||
return prev | ||
}, /** @type {Record<BaseNames,Base>} */({})) | ||
}, /** @type {Record<BaseName,Base>} */({})) | ||
/** @type {Record<BaseCodes,Base>} */ | ||
/** @type {Record<BaseCode,Base>} */ | ||
const codes = constants.reduce((prev, tupple) => { | ||
prev[tupple[1]] = names[tupple[0]] | ||
return prev | ||
}, /** @type {Record<BaseCodes,Base>} */({})) | ||
}, /** @type {Record<BaseCode,Base>} */({})) | ||
@@ -68,0 +68,0 @@ module.exports = { |
@@ -11,4 +11,4 @@ /** | ||
/** @typedef {import('./base')} Base */ | ||
/** @typedef {import("./types").BaseNamesCodes} BaseNamesCodes */ | ||
/** @typedef {import("./types").BaseCodes} BaseCodes */ | ||
/** @typedef {import("./types").BaseNameOrCode} BaseNameOrCode */ | ||
/** @typedef {import("./types").BaseCode} BaseCode */ | ||
@@ -18,3 +18,3 @@ /** | ||
* | ||
* @param {BaseNamesCodes} nameOrCode - The multibase name or code number. | ||
* @param {BaseNameOrCode} nameOrCode - The multibase name or code number. | ||
* @param {Uint8Array} buf - The data to be prefixed with multibase. | ||
@@ -37,3 +37,3 @@ * @returns {Uint8Array} | ||
* | ||
* @param {BaseNamesCodes} nameOrCode - The multibase name or code number. | ||
* @param {BaseNameOrCode} nameOrCode - The multibase name or code number. | ||
* @param {Uint8Array} buf - The data to be encoded. | ||
@@ -70,3 +70,3 @@ * @returns {Uint8Array} | ||
} | ||
const enc = encoding(/** @type {BaseCodes} */(data[0])) | ||
const enc = encoding(/** @type {BaseCode} */(data[0])) | ||
return enc.decode(data.substring(1)) | ||
@@ -79,3 +79,3 @@ } | ||
* @param {Uint8Array|string} data | ||
* @returns {boolean | string} | ||
* @returns {false | string} | ||
*/ | ||
@@ -93,3 +93,3 @@ function isEncoded (data) { | ||
try { | ||
const enc = encoding(/** @type {BaseCodes} */(data[0])) | ||
const enc = encoding(/** @type {BaseCode} */(data[0])) | ||
return enc.name | ||
@@ -104,3 +104,3 @@ } catch (err) { | ||
* | ||
* @param {BaseNamesCodes} name | ||
* @param {BaseNameOrCode} name | ||
* @param {Uint8Array} buf | ||
@@ -118,3 +118,3 @@ * @returns {void} | ||
* | ||
* @param {BaseNamesCodes} nameOrCode | ||
* @param {BaseNameOrCode} nameOrCode | ||
* @returns {Base} | ||
@@ -145,3 +145,3 @@ * @throws {Error} Will throw if the encoding is not supported | ||
return encoding(/** @type {BaseCodes} */(data[0])) | ||
return encoding(/** @type {BaseCode} */(data[0])) | ||
} | ||
@@ -148,0 +148,0 @@ |
/** | ||
* - Codes of the supported encodings | ||
*/ | ||
export type BaseCodes = | ||
export type BaseCode = | ||
| '\x00' | ||
@@ -32,3 +32,3 @@ | '0' | ||
*/ | ||
export type BaseNames = | ||
export type BaseName = | ||
| 'identity' | ||
@@ -58,3 +58,3 @@ | 'base2' | ||
export type BaseNamesCodes = BaseCodes | BaseNames; | ||
export type BaseNameOrCode = BaseCode | BaseName; | ||
export type Codec = { | ||
@@ -61,0 +61,0 @@ encode: (buffer: Uint8Array) => string; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
591
0
39063
23