4.1.0 • Published 6 years ago

fluent-binary-converter v4.1.0

Weekly downloads
36
License
MIT
Repository
github
Last release
6 years ago

fluent-binary-converter

Dependency Status devDependency Status Build Status: Linux Build Status: Windows npm version Downloads gzip size

A Fluent Binary Converter to Convert between ArrayBuffer with number

install

npm i fluent-binary-converter

usage

import { BinaryDecoder, BinaryEncoder } from "fluent-binary-converter";
// <script src="fluent-binary-converter/fluent-binary-converter.min.js"></script>
// const { BinaryDecoder, BinaryEncoder } = FluentBinaryConverter;

const source = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]);
const binaryDecoder = new BinaryDecoder(source.buffer);

const a = binaryDecoder.getUint32(); // 67305985
const b = binaryDecoder.getUint32(); // 134678021

const aBinary = BinaryEncoder.fromUint32(a); // [1, 2, 3, 4]
const bBinary = BinaryEncoder.fromUint32(b); // [5, 6, 7, 8]

const target = new Uint8Array(8); // [0, 0, 0, 0, 0, 0, 0, 0]
new BinaryEncoder(target).setBinary(aBinary, bBinary);// [1, 2, 3, 4, 5, 6, 7, 8]

dependencies

  • TypedArray, or polyfill like core-js

change logs

// v4
const uint8Array2 = BinaryEncoder.concat(aBinary, bBinary, cBinary);

// v3
const uint8Array2 = new Uint8Array(aBinary.length + bBinary.length + cBinary.length);
const binaryEncoder = new BinaryEncoder(uint8Array2);
binaryEncoder.setBinary(aBinary, bBinary, cBinary);
// v3
BinaryEncoder.fromUint32(true, 123);

// v2
BinaryEncoder.fromUint32(123);
// v2
import { BinaryDecoder, BinaryEncoder } from "fluent-binary-converter/browser";
import { BinaryDecoder, BinaryEncoder } from "fluent-binary-converter/nodejs";

// v1
import { BinaryDecoder, BinaryEncoder } from "fluent-binary-converter";
4.1.0

6 years ago

4.0.2

6 years ago

4.0.1

6 years ago

4.0.0

7 years ago

3.0.2

7 years ago

3.0.1

7 years ago

3.0.0

7 years ago

2.0.2

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago