@types/bitfield-rle
TypeScript icon, indicating that this package has built-in type declarations

2.2.2 • Public • Published

Installation

npm install --save @types/bitfield-rle

Summary

This package contains type definitions for bitfield-rle (https://github.com/mafintosh/bitfield-rle).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/bitfield-rle.

index.d.ts

/// <reference types="node" />

export function align(n: number): {
    encode: typeof encode;
    decode: typeof decode;
    encodingLength: typeof encodingLength;
    decodingLength: typeof decodingLength;
};

/**
 * Run-length-encode a bitfield.
 *
 * @param bitfield The bitfield to encode.
 * @param buffer The buffer to write the encoded bitfield into.
 * @param [offset=0] The offset in byte into the `buffer` to start writing the encoded `bitfield`.
 *
 * @example
 * import * as rle from 'bitfield-rle'
 * import Bitfield from 'bitfield'
 *
 * const bits = new Bitfield(1024)
 *
 * bits.set(400, true) // set bit 400
 *
 * const enc = rle.encode(Buffer.from(bits.buffer)) // rle encode the bitfield
 * console.log(enc.length) // 6 bytes
 */
export function encode(bitfield: Buffer, buffer?: Buffer, offset?: number): Buffer;
export namespace encode {
    const bytes: number;
}

/**
 * Decode an encoded bitfield.
 *
 * @param buffer The buffer with an encoded bitfield.
 * @param [offset=0] The offset in `buffer`in bytes where to start decoding
 *
 * @example
 * import * as rle from 'bitfield-rle'
 * import Bitfield from 'bitfield'
 *
 * const bits = new Bitfield(1024)
 *
 * bits.set(400, true) // set bit 400
 *
 * const enc = rle.encode(Buffer.from(bits.buffer))
 * const dec = rle.decode(enc) // decode the rle encoded buffer
 * console.log(dec.length) // 128 bytes (like the old bitfield)
 *
 * const decodedBits = new Bitfield(dec)
 * console.log(decodedBits.get(400)) // still returns true
 */
export function decode(buffer: Buffer, offset?: number): Buffer;
export namespace decode {
    const bytes: number;
}

/**
 * @returns How many bytes are needed to encode the bitfield.
 */
export function encodingLength(bitfield: Buffer): number;

/**
 * @returns How many bytes a decoded bitfield will use.
 */
export function decodingLength(buffer: Buffer, offset?: number): number;

Additional Details

  • Last updated: Mon, 06 Nov 2023 22:41:04 GMT
  • Dependencies: @types/node

Credits

These definitions were written by BendingBender.

Readme

Keywords

none

Package Sidebar

Install

npm i @types/bitfield-rle

Weekly Downloads

2

Version

2.2.2

License

MIT

Unpacked Size

6.46 kB

Total Files

5

Last publish

Collaborators

  • types