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

0.0.33 • Public • Published

Installation

npm install --save @types/ref-struct

Summary

This package contains type definitions for ref-struct (https://github.com/TooTallNate/ref-struct).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/ref-struct.

index.d.ts

import ref = require("ref");

/**
 * This is the `constructor` of the Struct type that gets returned.
 *
 * Invoke it with `new` to create a new Buffer instance backing the struct.
 * Pass it an existing Buffer instance to use that as the backing buffer.
 * Pass in an Object containing the struct fields to auto-populate the
 * struct with the data.
 */
interface StructType extends ref.Type {
    /** Pass it an existing Buffer instance to use that as the backing buffer. */
    new(arg: Buffer, data?: {}): any;
    new(data?: {}): any;
    /** Pass it an existing Buffer instance to use that as the backing buffer. */
    (arg: Buffer, data?: {}): any;
    (data?: {}): any;

    fields: { [key: string]: { type: ref.Type } };

    /**
     * Adds a new field to the struct instance with the given name and type.
     * Note that this function will throw an Error if any instances of the struct
     * type have already been created, therefore this function must be called at the
     * beginning, before any instances are created.
     */
    defineProperty(name: string, type: ref.Type): void;

    /**
     * Adds a new field to the struct instance with the given name and type.
     * Note that this function will throw an Error if any instances of the struct
     * type have already been created, therefore this function must be called at the
     * beginning, before any instances are created.
     */
    defineProperty(name: string, type: string): void;

    /**
     * Custom for struct type instances.
     * @override
     */
    toString(): string;
}

/** The struct type meta-constructor. */
declare var StructType: {
    new(fields?: object, opt?: object): StructType;
    new(fields?: any[]): StructType;
    (fields?: object, opt?: object): StructType;
    (fields?: any[]): StructType;
};

export = StructType;

Additional Details

  • Last updated: Tue, 07 Nov 2023 15:11:36 GMT
  • Dependencies: @types/ref

Credits

These definitions were written by Paul Loyd.

Readme

Keywords

none

Package Sidebar

Install

npm i @types/ref-struct

Weekly Downloads

279

Version

0.0.33

License

MIT

Unpacked Size

6.27 kB

Total Files

5

Last publish

Collaborators

  • types