Implementation of the multibase specification.

multibase

src/index.js
multibase(nameOrCode: any, buf: any)
Parameters
nameOrCode (any)
buf (any)

multibase

src/index.js
multibase(nameOrCode: any, buf: any)
Parameters
nameOrCode (any)
buf (any)

multibase

src/index.js
multibase(nameOrCode: any, buf: any)
Parameters
nameOrCode (any)
buf (any)

multibase

src/index.js
multibase(nameOrCode: any, buf: any)
Parameters
nameOrCode (any)
buf (any)

multibase

src/index.js

Create a new Uint8Array with the multibase varint+code.

multibase(nameOrCode: BaseNameOrCode, buf: Uint8Array): Uint8Array
Parameters
nameOrCode (BaseNameOrCode) The multibase name or code number.
buf (Uint8Array) The data to be prefixed with multibase.
Returns
Uint8Array:
Throws
  • Error: Will throw if the encoding is not supported

Encode data with the specified base and add the multibase prefix.

encode(nameOrCode: BaseNameOrCode, buf: Uint8Array): Uint8Array
Parameters
nameOrCode (BaseNameOrCode) The multibase name or code number.
buf (Uint8Array) The data to be encoded.
Returns
Uint8Array:
Throws
  • Error: Will throw if the encoding is not supported
encode
Parameters
data (Uint8Array)
alphabet (string)
bitsPerChar (number)
Returns
string:
encode(input: Uint8Array): string
Parameters
input (Uint8Array)
Returns
string:

Takes a Uint8Array or string encoded with multibase header, decodes it and returns the decoded buffer

decode(data: (Uint8Array | string)): Uint8Array
Parameters
data ((Uint8Array | string))
Returns
Uint8Array:
Throws
  • Error: Will throw if the encoding is not supported
decode
Parameters
string (any)
alphabet (any)
bitsPerChar (any)
decode
Parameters
string (string)
alphabet (string)
bitsPerChar (number)
Returns
Uint8Array:
decode(input: string): Uint8Array
Parameters
input (string)
Returns
Uint8Array:
data

Type: BaseCode

data

Type: BaseCode

data

Type: BaseCode

isEncoded

src/index.js

Is the given data multibase encoded?

isEncoded(data: (Uint8Array | string))
Parameters
data ((Uint8Array | string))

validEncode

src/index.js

Validate encoded data

validEncode(name: BaseNameOrCode, buf: Uint8Array): void
Parameters
name (BaseNameOrCode)
buf (Uint8Array)
Returns
void:
Throws
  • Error: Will throw if the encoding is not supported

Get the encoding by name or code

encoding(nameOrCode: BaseNameOrCode): Base
Parameters
nameOrCode (BaseNameOrCode)
Returns
Base:
Throws
  • Error: Will throw if the encoding is not supported

Type: BaseName

Type: BaseName

Type: BaseCode

Type: BaseCode

encodingFromData

src/index.js

Get encoding from data

encodingFromData(data: (string | Uint8Array)): Base
Parameters
data ((string | Uint8Array))
Returns
Base:
Throws
  • Error: Will throw if the encoding is not supported
identity
identity
identity
identity
identity

Type: CodecFactory

name, code, implementation, alphabet

constants

Type: Array<[BaseName, BaseCode, CodecFactory, string]>

names

Type: Record<BaseName, Base>

Type: Record<BaseName, Base>

codes

Type: Record<BaseCode, Base>

codes

Type: Record<string, number>

Type: Record<BaseCode, Base>

new Base(name: any, code: any, factory: any, alphabet: any)
Parameters
name (any)
code (any)
factory (any)
alphabet (any)
Instance Members
encode(buf)
decode(string)
new Base(name: any, code: any, factory: any, alphabet: any)
Parameters
name (any)
code (any)
factory (any)
alphabet (any)
Instance Members
encode(buf)
decode(string)
new Base(name: any, code: any, factory: any, alphabet: any)
Parameters
name (any)
code (any)
factory (any)
alphabet (any)
Instance Members
encode(buf)
decode(string)

Class to encode/decode in the supported Bases

new Base(name: BaseName, code: BaseCode, factory: CodecFactory, alphabet: string)
Parameters
name (BaseName)
code (BaseCode)
factory (CodecFactory)
alphabet (string)
Instance Members
encode(buf)
decode(string)

RFC4648 Factory

rfc4648
Parameters
bitsPerChar (number)
Returns
CodecFactory:

decodeText

src/util.js
decodeText
Parameters
bytes ((ArrayBufferView | ArrayBuffer))
Returns
string:

encodeText

src/util.js
encodeText
Parameters
text (string)
Returns
Uint8Array:

Returns a new Uint8Array created by concatenating the passed Arrays

concat(arrs: Array<ArrayLike<number>>, length: number): Uint8Array
Parameters
arrs (Array<ArrayLike<number>>)
length (number)
Returns
Uint8Array: