# @types/ref-struct

> TypeScript definitions for ref-struct

Latest version **0.0.33** (published 2023-11-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install @types/ref-struct
pnpm add @types/ref-struct
yarn add @types/ref-struct
bun add @types/ref-struct
```

## Health

**Score 45/100 (D)** — status: abandoned.

Positive: has types; no vulnerabilities; high maintenance score; popular repo; extremely popular.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.0.33 |
| Published | 2023-11-07 |
| First published | 2016-05-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 6.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 51443 |
| Maintainers | types |

## Links

- npm: https://www.npmjs.com/package/@types/ref-struct
- Repository: https://github.com/DefinitelyTyped/DefinitelyTyped
- Homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/ref-struct
- npm.io page: https://npm.io/package/@types/ref-struct

## Dependencies (1)

- [@types/ref](https://npm.io/package/@types/ref.md) *

## Recent versions

- 0.0.33 (latest) — 2023-11-07
- 0.0.30 (ts4.3) — 2023-04-29
- 0.0.29 (ts2.2) — 2018-01-02
- 0.0.28 (ts2.0) — 2016-09-19
- 0.0.32 — 2023-10-18
- 0.0.31 — 2023-09-27
- 0.0.27 — 2016-07-14
- 0.0.26-alpha — 2016-07-08
- 0.0.25-alpha — 2016-07-04
- 0.0.24-alpha — 2016-07-02
- 0.0.23-alpha — 2016-07-01
- 0.0.22-alpha — 2016-07-01
- 0.0.21-alpha — 2016-05-25
- 0.0.20-alpha — 2016-05-20
- 0.0.15-alpha — 2016-05-19
- … 1 more at https://npm.io/package/@types/ref-struct/versions

## README

# 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](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/ref-struct/index.d.ts)
````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](https://npmjs.com/package/@types/ref)

# Credits
These definitions were written by [Paul Loyd](https://github.com/loyd).

---
_Source: https://npm.io/package/@types/ref-struct · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
