Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

iobuffer

image-js276.2kMIT5.4.0TypeScript support: included

Read and write binary data on ArrayBuffers

readme

iobuffer

Read and write binary data in ArrayBuffers.

Zakodium logo

Maintained by Zakodium

NPM version build status Test coverage npm download

Installation

npm i iobuffer

API

Complete API documentation

Usage example

const { IOBuffer } = require('iobuffer');

const io = new IOBuffer();
// Pointer offset is 0
io.writeChars('Hello world') // Write 11 chars, pointer offset now 11
  .writeUint32(42) // Write 32-bit int (default is little-endian), pointer offset now 15
  .setBigEndian() // Switch to big-endian mode
  .writeUint32(24) // Write another 32-bit int, but big-endian, pointer offset now 19
  .mark() // Bookmark current pointer offset (19)
  .skip(2) // Pointer offset now 21
  .writeBoolean(true) // Write 0xff, pointer offset now 22
  .reset() // Go to bookmarked pointer offset, pointer offset now 19
  .setLittleEndian() // Go back to little endian mode
  .writeUint16(18) // Write 16-bit unsigned integer in the previously skipped 2 bytes, pointer offset now 21
  .rewind() // Pointer offset back to 0
  .toArray(); // Get a Uint8Array over the written part [0-21] of the internal ArrayBuffer

License

MIT

changelog

Changelog

5.4.0 (2025-03-04)

Features

  • add getWrittenByteLength function (#76) (093322c)

5.3.2 (2023-01-30)

Bug Fixes

  • do not crash on initialization if bigint arrays don't exist (#66) (098c845)

5.3.1 (2022-12-05)

Bug Fixes

  • readArray: account for endianness (#62) (2604862)

5.3.0 (2022-11-29)

Features

  • add readArray method to read any typed array (#58) (eda3e91)

5.2.1 (2022-10-07)

Bug Fixes

  • remap browser version of text decoder (4531fa9)

5.2.0 (2022-10-04)

Features

5.1.0 (2021-12-17)

Features

5.0.4 (2021-10-12)

Bug Fixes

  • set TypeScript target to ES2020 (4f4b412)

5.0.3 (2021-02-26)

Bug Fixes

  • add browser field for lib/ version too (#43) (508083f)

5.0.2 (2019-11-12)

Bug Fixes

  • include js file in the build (3be165a)

5.0.1 (2019-11-12)

5.0.0 (2019-11-12)

chore

BREAKING CHANGES

  • Node.js 6 and 8 are no longer supported.

4.0.1 (2019-03-27)

4.0.0 (2018-08-22)

Bug Fixes

  • fix test-travis script (fd74496)
  • remove implied undefined type from InputData (0040962)

Chores

  • remove support for Node 4 (feabb42)

Features

BREAKING CHANGES

  • The getBuffer method has been removed. Use toArray instead.
  • The IOBuffer constructor is now a named export. Access it with require('iobuffer').IOBuffer or import { IOBuffer } from 'iobuffer'.
  • Removed support for Node 4

3.2.0 (2016-12-27)

Features

  • add readUtf8 and writeUtf8 (6118a54), closes #31

3.1.0 (2016-12-15)

Features

3.0.0 (2016-12-13)

Bug Fixes

  • iobuffer: fix an edge case with ensureAvailable (501dc48)

Features

  • iobuffer: add chainability (bbac001)
  • iobuffer: add pushMark and popMark API (a69e228), closes #28

2.1.0 (2016-09-20)

Features

  • add support for offset option (ffedd73)

2.0.0 (2015-11-23)

2.0.0-1 (2015-10-16)

2.0.0-0 (2015-10-16)

1.1.0-0 (2015-10-02)

1.0.4 (2015-09-26)

1.0.3 (2015-09-24)

1.0.2 (2015-09-24)

1.0.1 (2015-09-24)

1.0.0 (2015-09-23)