Package Exports
- str2ab
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 (str2ab) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
str2ab
Convert between string (including base64 and base64url) and ArrayBuffer.
Usage
ESM
import str2ab from 'str2ab';
str2ab.string2arraybuffer('this is sample.');
CommonJS
const str2ab = require('str2ab');
str2ab.string2arraybuffer('this is sample.');
API
From/To | string | ArrayBuffer | base64url | base64 | Buffer |
---|---|---|---|---|---|
string | x | 1.1 | base64url | base64url | base64url |
ArrayBuffer | 1.2 | x | 2.2 | 3.2 | 4.2 |
base64url | base64url | 2.1 | x | base64url | x |
base64 | x | 3.3 | base64url | x | x |
Buffer | x | 4.1 | x | x | x |
String <-> ArrayBuffer
string2arraybuffer(string)
- Returns ArrayBuffer
arraybuffer2string(ArrayBuffer)
- Returns string
base64url <-> ArrayBuffer
base64url2arraybuffer(string)
- Returns ArrayBuffer
arraybuffer2base64url(ArrayBuffer)
- Returns string
base64 <-> ArrayBuffer
base642arraybuffer(string)
- Returns ArrayBuffer
arraybuffer2base64(ArrayBuffer)
- Returns string
Buffer <-> ArrayBuffer
buffer2arraybuffer(Buffer)
- Returns ArrayBuffer
arraybuffer2buffer(ArrayBuffer)
- Returns Buffer
Install
npm install str2ab