@types/bser
@types/bser
npm i @types/bser
@types/bser

@types/bser

The repository for high quality TypeScript type definitions.

by DefinitelyTyped

2.0.1 (see all)License:MITTypeScript:Built-In
npm i @types/bser
Readme

Installation

npm install --save @types/bser

Summary

This package contains type definitions for bser (https://facebook.github.io/watchman/docs/bser.html).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/bser.

index.d.ts

// Type definitions for bser 2.0
// Project: https://facebook.github.io/watchman/docs/bser.html
// Definitions by: Claas Ahlrichs <https://github.com/claasahl>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.7

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

import { EventEmitter } from "events";
import Int64 = require("node-int64");

export type InputWrapper =
    | Buffer
    | string
    | NodeJS.TypedArray
    | DataView
    | ArrayBuffer
    | SharedArrayBuffer;
export type IntWrapper = number | Int64;
export type AnyWrapper = boolean | IntWrapper | null | string | object;

export class Accumulator {
    buf: Buffer;
    readOffset: number;
    writeOffset: number;

    constructor(initsize?: number);

    append(buf: InputWrapper): void;

    assertReadableSize(size: number): void;

    peekDouble(): number;

    peekInt(size: number): IntWrapper;

    peekString(size: number): string;

    readAdvance(size: number): void;

    readAvail(): number;

    readDouble(): number;

    // replace "IntWrapper" with "number"?
    readInt(bytes: number): IntWrapper;

    readString(size: number): string;

    reserve(size: number): void;

    writeAvail(): number;

    writeByte(value: number): void;

    writeDouble(value: number): void;

    writeInt(value: number, size: number): void;
}

export class BunserBuf extends EventEmitter {
    buf: Accumulator;
    state: 0 | 1;
    // replace "IntWrapper" with "number"?
    pduLen?: false | IntWrapper | undefined;

    constructor();

    append(
        buf: InputWrapper,
        synchronous?: false
    ): AnyWrapper | AnyWrapper[] | undefined;
    append(buf: InputWrapper, synchronous: true): void;

    decodeAny(): AnyWrapper | AnyWrapper[];

    decodeArray(): AnyWrapper[];

    // replace "IntWrapper" with "number"?
    decodeInt(relaxSizeAsserts?: boolean): false | IntWrapper;

    decodeObject(): object;

    decodeString(): string;

    decodeTemplate(): AnyWrapper[];

    expectCode(expected: number): void;

    process(synchronous?: false): AnyWrapper | AnyWrapper[] | undefined;
    process(synchronous: true): void;

    processLater(): void;

    raise(reason: string): void;
}

export function dumpToBuffer(val: any): Buffer;

export function loadFromBuffer(input: InputWrapper): AnyWrapper | AnyWrapper[];

Additional Details

Credits

These definitions were written by Claas Ahlrichs.

Downloads/wk

18.8K

GitHub Stars

40.9K

LAST COMMIT

7mos ago

MAINTAINERS

1

CONTRIBUTORS

17,572

OPEN ISSUES

635

OPEN PRs

201
VersionTagPublished
2.0.1
latest
1yr ago
2.0.1
ts4.7
1yr ago
2.0.1
ts4.6
1yr ago
2.0.1
ts4.8
1yr ago
No alternatives found
No tutorials found
Add a tutorial

Rate & Review

100
No reviews found
Be the first to rate