# @types/struct

> TypeScript definitions for struct

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

## Install

```sh
npm install @types/struct
pnpm add @types/struct
yarn add @types/struct
bun add @types/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.8 |
| Published | 2023-11-07 |
| First published | 2019-11-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 6.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 51449 |
| Maintainers | types |

## Links

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

## Dependencies (1)

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

## Recent versions

- 0.0.8 (latest) — 2023-11-07
- 0.0.5 (ts4.3) — 2023-08-22
- 0.0.4 (ts4.2) — 2022-12-30
- 0.0.3 (ts3.4) — 2021-01-12
- 0.0.2 (ts3.3) — 2021-01-04
- 0.0.1 (ts3.2) — 2020-10-28
- 0.0.0 (ts2.0) — 2019-11-05
- 0.0.7 — 2023-10-18
- 0.0.6 — 2023-09-25

## README

# Installation
> `npm install --save @types/struct`

# Summary
This package contains type definitions for struct (https://github.com/xdenser/node-struct#readme).

# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/struct.
## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/struct/index.d.ts)
````ts
/// <reference types="node"/>

// eslint-disable-next-line @definitelytyped/no-unnecessary-generics
export default function Factory<T>(): Struct<T>;

export type StructBaseTypes =
    | "word8"
    | "word8Sle"
    | "word8Sbe"
    | "word16Sle"
    | "word16Sbe"
    | "word16Ule"
    | "word16Ube"
    | "word32Sle"
    | "word32Sbe"
    | "word32Ule"
    | "word32Ube"
    | "word64Sle"
    | "word64Sbe"
    | "word64Ule"
    | "word64Ube"
    | "floatle"
    | "floatbe"
    | "doublele"
    | "doublebe";

export type StructCharsTypes = "chars" | "charsnt";

export type StructArrayType = "array";

export type StructTypes =
    | StructBaseTypes
    | StructCharsTypes
    | StructArrayType;

export class Struct<T = any> {
    word8(name: string): Struct<T>;
    word8Sle(name: string): Struct<T>;
    word8Sbe(name: string): Struct<T>;
    word16Sle(name: string): Struct<T>;
    word16Sbe(name: string): Struct<T>;
    word16Ule(name: string): Struct<T>;
    word16Ube(name: string): Struct<T>;
    word32Sle(name: string): Struct<T>;
    word32Sbe(name: string): Struct<T>;
    word32Ule(name: string): Struct<T>;
    word32Ube(name: string): Struct<T>;
    word64Sle(name: string): Struct<T>;
    word64Sbe(name: string): Struct<T>;
    word64Ule(name: string): Struct<T>;
    word64Ube(name: string): Struct<T>;
    floatle(name: string): Struct<T>;
    floatbe(name: string): Struct<T>;
    doublele(name: string): Struct<T>;
    doublebe(name: string): Struct<T>;
    chars(name: string, length: number, encoding?: string): Struct<T>;
    charsnt(name: string, length: number, encoding?: string): Struct<T>;
    array(
        name: string,
        length: number,
        type: StructTypes | Struct,
        ...args: Array<(string | number | Struct)>
    ): Struct<T>;
    struct(name: string, struct: Struct): Struct<T>;
    get(fieldName: string): any;
    set(fieldName: string, value: any): void;
    allocate(): Struct<T>;
    setBuffer(buffer: Buffer, buffLength?: number): void;
    buffer(): Buffer;
    fields: T;
}

````

### Additional Details
 * Last updated: Tue, 07 Nov 2023 15:11:36 GMT
 * Dependencies: [@types/node](https://npmjs.com/package/@types/node)

# Credits
These definitions were written by [Ben Allfree](https://github.com/benallfree).

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