JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 930495
  • Score
    100M100P100Q48304F
  • License MIT

JavaScript implementation of the multibase specification

Package Exports

  • multibase
  • multibase/src/constants

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (multibase) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

js-multibase

Coverage Status Travis CI Circle CI Dependency Status js-standard-style

JavaScript Implementation of the multibase specification

Example

const multibase = require('multibase')

const encodedBuf = multibase.encode('base58btc', new Buffer('hey, how is it going'))

const decodedBuf = multibase.decode(encodedBuf)
console.log(decodedBuf.toString())
// hey, how it going

API

multibase - Prefixes an encoded buffer with its multibase code

const multibased = multibase(<nameOrCode>, encodedBuf)

multibase.encode - Encodes a buffer into one of the supported encodings, prefixing it with the multibase code

const encodedBuf = multibase.encode(<nameOrCode>, <buf>)

multibase.decode - Decodes a buffer or string

const decodedBuf = multibase.decoded(bufOrString)

multibase.isEncoded - Checks if buffer or string is encoded

const value = multibase.isEncoded(bufOrString)
// value is the name of the encoding if it is encoded, false otherwise

Supported Encodings, see src/constants.js

Installation

In Node.js through npm

> npm install --save multibase

Browser: Browserify, Webpack, other bundlers

The code published to npm that gets loaded on require is in fact an ES5 transpiled version with the right shims added. This means that you can require it and use with your favourite bundler without having to adjust asset management process.

const multibase = require('multiubase')

In the Browser through <script> tag

Loading this module through a script tag will make the Multibase obj available in the global namespace.

<script src="https://npmcdn.com/multibase/dist/index.min.js"></script>
<!-- OR -->
<script src="https://npmcdn.com/multibase/dist/index.js"></script>

Gotchas

You will need to use Node.js Buffer API compatible, if you are running inside the browser, you can access it by multibase.Buffer or you can load Feross's Buffer module.

License

[MIT] © Protocol Labs Inc.