0.3.0 • Published 2 years ago

as-buffers v0.3.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

as-buffers

as-buffers provides some Buffer types for reading/writing string/bytes efficiently and simply.

Usage

There are 2 useful buffer classes here: BytesBuffer and StringBuffer.

  • BytesBuffer provides bytes related/endian related methods.
  • StringBuffer(is forked from MaxGraey) provides string (UTF16) related methods.

Write/Read bytes

let buf = BytesBuffer.wrap(new ArrayBuffer(0));
let val = 0x11 as i8;
buf.writeNumberBE<i8>(val);
let res = buf.readNumberBE<i8>(0);
expect(res).toBe(val);

Write/Read string

let buf = new StringBuffer();
buf.write("hello");
expect(buf.toString()).toBe("hello");

More usages

In addition to some safe methods, they also have some unsafe methods to improve performance. You need to pay attention to the buffer capacity and read/write offset.

See unit tests and source comments.

0.3.0

2 years ago

0.1.3

2 years ago

0.1.2

3 years ago

0.1.0

3 years ago

0.1.1

3 years ago

0.0.9

3 years ago

0.0.7

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.6

3 years ago

0.0.3

3 years ago