eyezahhhh / buffer-esm

A cross-platform, partial implementation shim of Node Buffer.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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...

About

A cross-platform, partial implementation shim of Node Buffer.


Languages

Language:TypeScript 100.0%