JSPM

@web4/encoding

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q15560F
  • License MIT

Encode and decode BIT links

Package Exports

  • @web4/encoding
  • @web4/encoding/index.js

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 (@web4/encoding) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@web4/encoding

BitWeb's way of encoding and decoding bit:// links.

Example

var encoding = require('@web4/encoding')

var link = '6161616161616161616161616161616161616161616161616161616161616161'
var buf = encoding.decode(link)
console.log('%s -> %s', link, buf)
console.log('%s -> %s', buf, encoding.encode(buf))

API

.encode(buf)

.toStr(buf)

Encode buf into a hex string. Throws if buf isn't 32 bytes of length.

If buf is already a string, checks if it's valid and returns it.

.decode(str)

.toBuf(str)

Decode str into its binary representation. Also supports bit:// and bitwebs.org links. Throws if the raw link isn't 64 bytes of base64.

If str is already a buffer, checks if it's valid and returns it.

License

MIT