byte-decoder
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

ByteDecoder

JavaScript Style Guide

Decode data. Browser or NodeJS.


Table of Contents


Install

npm i byte-decoder 

Usage

(constructor) ByteDecoder:

Args [encoding: 'utf8' | 'base64' | 'base64url' | 'ascii' | 'binary' | 'utf16le' | 'utf16be' | 'hex' | 'base32' | 'base32hex' | 'base32crockford']

import ByteDecoder from 'byte-decoder'

const base64ByteDecoder = new ByteDecoder('base64')

//...use base64ByteDecoder

(method) ByteDecoder.decode:

Args [data: ArrayBufferLike | ArrayLike | ArrayBufferView]

import ByteDecoder from 'byte-decoder'

const utf8ByteDecoder = new ByteDecoder('utf8')
const result = utf8ByteDecoder.decode([72, 101, 108, 108, 111, 32,  87, 111, 114, 108, 100, 33]) // returns 'Hello World!'

TextDecoder Polyfill:

// TextDecoder-polyfill.js
import ByteDecoder from 'byte-decoder'

if (!globalThis.TextDecoder) {
  globalThis.TextDecoder = ByteDecoder
}

// index.js
import './TextDecoder-polyfill.js'

Package Sidebar

Install

npm i byte-decoder

Weekly Downloads

0

Version

1.0.0

License

none

Unpacked Size

14.6 kB

Total Files

4

Last publish

Collaborators

  • clyng57