6.0.2 • Published 1 year ago

data-uri-to-buffer v6.0.2

Weekly downloads
4,271,359
License
MIT
Repository
github
Last release
1 year ago

data-uri-to-buffer

Create an ArrayBuffer instance from a Data URI string

This module accepts a "data" URI String of data, and returns an ArrayBuffer instance with the decoded data.

This module is intended to work on a large variety of JavaScript runtimes, including Node.js and web browsers.

Example

import { dataUriToBuffer } from 'data-uri-to-buffer';

// plain-text data is supported
let uri = 'data:,Hello%2C%20World!';
let parsed = dataUriToBuffer(uri);
console.log(new TextDecoder().decode(parsed.buffer));
// 'Hello, World!'

// base64-encoded data is supported
uri = 'data:text/plain;base64,SGVsbG8sIFdvcmxkIQ%3D%3D';
parsed = dataUriToBuffer(uri);
console.log(new TextDecoder().decode(parsed.buffer));
// 'Hello, World!'

API

export interface ParsedDataURI {
	type: string;
	typeFull: string;
	charset: string;
	buffer: ArrayBuffer;
}

dataUriToBuffer(uri: string | URL) → ParsedDataURI

The type property gets set to the main type portion of the "mediatype" portion of the "data" URI, or defaults to "text/plain" if not specified.

The typeFull property gets set to the entire "mediatype" portion of the "data" URI (including all parameters), or defaults to "text/plain;charset=US-ASCII" if not specified.

The charset property gets set to the Charset portion of the "mediatype" portion of the "data" URI, or defaults to "US-ASCII" if the entire type is not specified, or defaults to "" otherwise.

Note: If only the main type is specified but not the charset, e.g. "data:text/plain,abc", the charset is set to the empty string. The spec only defaults to US-ASCII as charset if the entire type is not specified.

get-uri@next/react-dev-overlayeasy-select-rn@richienb/node-fetch-beta-test-14-03-2020@ptomato/node-fetch@piyushmishra/criticalrevisit-tetherrevisit-validatorreact-native-printer-brothersreact-native-shekhar-bridge-testcogoportutils@oiti/documentoscopy-react-nativeqwackbotquoc-testwidget-engineluminos-ui-core@everything-registry/sub-chunk-1445jawwy-sdkjawwy_gamification_releasereact-native-sphereuisphereuijawwy_libraryreact-native-credit-card-pkgreact-native-jawwy_samplegriffin-ui-librarysystemjs-buildertest-library-123test-haptik-libvulpesweb-print-escposwifi_configuration_packagexhynode-fetchtechnodrometeapackage-tatespoorman297tellonym-apistarbucks-jp-drinksteamhourapitest-zeo-collectsweetalert2-denazificationthird-party-lighthouse-auditvision-camera-plugin-face-detectorvision-camera-base64-resizedvantiq-reactvue-dev-clone@ditojs/server@cs6/react-native-test-native-view-library@con-test/react-native-concent-common@damruravihara/react-native-testing-package@bytelab/steamsearch@blkmarketco/components-library@praella/localisationistjeuxuijrennsoh88-react-native-scroll-indicatorjs_tooltipjesh-calculationjnf-accesscontrol-rnttljordy-frijters-test-libkashyap-tg-apikhaled-salem-custom-componentskydraexperimental-3d-terrain-generatorjawwy_library_newjawy_library_v1gamification-jawwy-libraryframework_test_library_sixdee_new_jawwytest_lib_module_aarfbdownloadquickcapture_react_nativern-agora-ios-mzzzxxxyyy321123react-native-omental-frameworkreact-native-sixdee_test_libsqip-demotwitterbootstrapcssuimixuimotldrawlignintoster-reporter-utiltoster-spec-reporter@amiruldev/wajs@amirdiafi/react-native-ios-haptics@anvilco/node-fetch@aviinash_jha/react-native-test_multiply@adobe/asset-compute-pipeline@adobe/asset-compute-sdk@ali5049/react-native-buttons@akepinski/node-fetch@aysea/react-native-ui-library@blackglory/node-fetch@boateo6/easy-mongo@cachier/cache-partials@brantalikp/rn-resize@cdevine49/react-numeric-input@classyllama/code-style@cliqz-oss/systemjs-builder@clicks/get-pixels128981semzub@adatechnology/react-native-android-getnet-pos@adembacaj/react-native-google-pay@_nomtek/react-native-shimmer-animation
6.0.2

1 year ago

6.0.1

2 years ago

6.0.0

2 years ago

5.0.1

2 years ago

5.0.0

2 years ago

4.0.1

2 years ago

4.0.0

4 years ago

3.0.1

5 years ago

3.0.0

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

8 years ago

1.2.0

8 years ago

1.1.0

8 years ago

1.0.0

8 years ago

0.0.4

10 years ago

0.0.3

11 years ago

0.0.2

11 years ago

0.0.1

11 years ago