0.0.1 • Published 1 year ago

basenone v0.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

BaseNone is a simple dependency free library to encode Uint8Array to strings and back.

BaseNone should work in any modern browser, compliant javascript runtimes and Node.js.

Installation

npm install basenone

Constructor

import BaseNone from 'basenone'

const baseNone = new BaseNone(Uint8Array)

Ascii

// static method
const baseNone = BaseNone.fromAscii('My ascii string');

// raw Uint8Array
const raw = baseNone.getRaw();

// BaseNone to ascii
const ascii: string = baseNone.toAscii();

Binary

// static method
const baseNone = BaseNone.fromBinary('0100100001100101011011000110110001101111');

// raw Uint8Array
const raw = baseNone.getRaw();

// BaseNone to binary
const binary: string = baseNone.toBinary();

Base 16 (Hex)

// static method
const baseNone = BaseNone.fromHex('48656c6c6f2c20576f726c6421');

// raw Uint8Array
const raw = baseNone.getRaw();

// BaseNone to hex
const hex: string = baseNone.toHex();

base64

// static method
const baseNone = BaseNone.fromBase64('SGVsbG8sIFdvcmxkIQ==');

// raw Uint8Array
const raw = baseNone.getRaw();

// BaseNone to base64
const base64: string = baseNone.toBase64();

UTF-8

// static method
const baseNone = BaseNone.fromUTF8('你好世界');

// raw Uint8Array
const raw = baseNone.getRaw();

// BaseNone to utf8
const utf8: string = baseNone.toUTF8();

In Progress

  • Base 32
  • Base 62