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
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 goingAPI
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 otherwiseSupported Encodings, see src/constants.js
Installation
In Node.js through npm
> npm install --save multibaseBrowser: 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.