npm.io
0.2.0 • Published 3 years ago

json-data-uri

Licence
ISC
Version
0.2.0
Deps
0
Size
6 kB
Vulns
0
Weekly
0

json-data-uri

Parse and encode (plain or Base64) data URIs with JSON content and correct MIME type.

API

This module exports an object that holds these functions:

parse(uri)

Try to parse JSON data from a data URI given as string uri. Returns decoded data, or undefined if there was an error.

toPlainUri(data)

Convert JSON-able data to a plain text data: URI. Returns a URI as a string. With bad input, the content part of the URI will be broken.

toBase64Uri(data)

Convert JSON-able data to a base64-encoded data: URI. Returns a URI as a string. With bad input, the content part of the URI will be broken.

Usage

see test/usage.mjs.

Known issues

  • Needs more/better tests and docs.

 

License

ISC

Keywords