https://github.com/dy/string-to-arraybuffer
Convert plain/base64/datauri string to ArrayBuffer
https://github.com/dy/string-to-arraybuffer
Last synced: 9 months ago
JSON representation
Convert plain/base64/datauri string to ArrayBuffer
- Host: GitHub
- URL: https://github.com/dy/string-to-arraybuffer
- Owner: dy
- Created: 2017-06-27T19:01:46.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2018-11-09T20:33:07.000Z (over 7 years ago)
- Last Synced: 2025-08-18T05:29:13.639Z (10 months ago)
- Language: JavaScript
- Size: 7.81 KB
- Stars: 10
- Watchers: 2
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# string-to-arraybuffer [](http://github.com/badges/stability-badges) [](https://travis-ci.org/dy/string-to-arraybuffer)
Turn dataURI/base64/plain string into an _ArrayBuffer_.
[](https://npmjs.org/package/string-to-arraybuffer/)
```js
var str2ab = require('string-to-arraybuffer')
// Plain 'Hello World!'
var abuf1 = str2ab('Hello World!')
// Base-64 'Hello World!'
var abuf2 = str2ab('SGVsbG8sIFdvcmxkIQ%3D%3D')
// Barebones data-uri 'Hello World!'
var abuf3 = str2ab('data:,Hello%2C%20World!')
// Base-64 data-uri 'Hello World!'
var abuf4 = str2ab('data:text/plain;base64,SGVsbG8sIFdvcmxkIQ%3D%3D')
```
### Related
* [arraybuffer-to-string](https://github.com/dy/arraybuffer-to-string) − represent binary data in string
* [data-uri-to-buffer](https://www.npmjs.com/package/data-uri-to-buffer) − decode URI string to Buffer.
* [to-array-buffer](https://www.npmjs.com/package/to-array-buffer) − convert anything to ArrayBuffer.