buffer-esm
v1.2.0
Published
A cross-platform, partial implementation shim of Node Buffer.
Downloads
8,804
Maintainers
Readme
Buffer-ESM
A cross-platform, partial implementation shim of Node Buffer. Supports encoding and decoding strings.
Usage
Install via NPM and require in your project. There is also an ESM export, for use with browser or Deno.
const { BufferShim } = require('buffer-esm')
const buffer = BufferShim.from('These are the voyages...') // Assumes utf8 when no encoding is passed.
const firstByte = buffer[0] // 84
const base64 = buffer.toString('base64') // VGhlc2UgYXJlIHRoZSB2b3lhZ2VzLi4u
const utf8 = buffer.toString('utf8') // These are the voyages...