data-uri-to-buffer
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
The "data-uri-to-buffer" module is a handy JavaScript tool designed to create an ArrayBuffer
instance from a Data URI string. Data URIs are often used in web development to embed media data directly into documents, avoiding the need for external files. This module decode the "data" URI string and output an ArrayBuffer instance with the data. It works on a wide range of JavaScript runtimes, including Node.js and web browsers, making it a versatile tool for many projects.
For utilizing the functionality of the "data-uri-to-buffer" module, you first need to import the module. Following that, you can use the dataUriToBuffer()
function which takes a "data" URI string as its argument and returns a decoded ArrayBuffer instance. For instance:
import { dataUriToBuffer } from 'data-uri-to-buffer';
// Plain-text data
let uri = 'data:,Hello%2C%20World!';
let parsed = dataUriToBuffer(uri);
console.log(new TextDecoder().decode(parsed.buffer));
// Outputs: 'Hello, World!'
// Base64-encoded data
uri = 'data:text/plain;base64,SGVsbG8sIFdvcmxkIQ%3D%3D';
parsed = dataUriToBuffer(uri);
console.log(new TextDecoder().decode(parsed.buffer));
// Outputs: 'Hello, World!'
The suite of data that dataUriToBuffer()
function returns include type
, typeFull
, charset
, and buffer
.
The official documentation for "data-uri-to-buffer" is not specifically mentioned in the provided readme. However, for most npm packages like this, their documentation can usually be found on the package page on npmjs.com or on their GitHub repository. In this case, the GitHub URL for the package is git+https://github.com/TooTallNate/proxy-agents.git. Moreover, the readme content presented often serves as an initial or basic form of documentation.