New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@types/ref-struct-di

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/ref-struct-di - npm Package Compare versions

Comparing version 1.1.1 to 1.1.2

ref-struct-di/ts4.1/index.d.ts

128

ref-struct-di/index.d.ts

@@ -9,6 +9,47 @@ // Type definitions for ref-struct-di 1.1

declare var StructType: {
new (fields?: Record<string, string | ref.Type>, opt?: { packed?: boolean }): struct.StructType;
new (fields?: Array<[string, string | ref.Type]>, opt?: { packed?: boolean }): struct.StructType;
(fields?: Record<string, string | ref.Type>, opt?: { packed?: boolean }): struct.StructType;
(fields?: Array<[string, string | ref.Type]>, opt?: { packed?: boolean }): struct.StructType;
/**
* Creates a new {@link struct.StructType} for the provided field definitions.
*/
new <TDefinition extends struct.StructTypeObjectDefinitionBase | struct.StructTypeObjectDefinitionInferenceMarker>(
fields: TDefinition,
opt?: { packed?: boolean }
): struct.StructType<struct.StructTypeObjectDefinitionToStructTypeDefinition<TDefinition>>;
/**
* Creates a new {@link struct.StructType} for the provided field definitions.
*/
new <TDefinition extends struct.StructTypeTupleDefinitionBase | struct.StructTypeTupleDefinitionInferenceMarker>(
fields: TDefinition,
opt?: { packed?: boolean }
): struct.StructType<struct.StructTypeTupleDefinitionToStructTypeDefinition<TDefinition>>;
/**
* Creates a new {@link struct.StructType} for the provided field definitions.
*/
new (fields?: Record<string, ref.TypeLike>, opt?: { packed?: boolean }): struct.StructType;
/**
* Creates a new {@link struct.StructType} for the provided field definitions.
*/
new (fields?: Array<[string, ref.TypeLike]>, opt?: { packed?: boolean }): struct.StructType;
/**
* Creates a new {@link struct.StructType} for the provided field definitions.
*/
<TDefinition extends struct.StructTypeObjectDefinitionBase | struct.StructTypeObjectDefinitionInferenceMarker>(
fields: TDefinition,
opt?: { packed?: boolean }
): struct.StructType<struct.StructTypeObjectDefinitionToStructTypeDefinition<TDefinition>>;
/**
* Creates a new {@link struct.StructType} for the provided field definitions.
*/
<TDefinition extends struct.StructTypeTupleDefinitionBase | struct.StructTypeTupleDefinitionInferenceMarker>(
fields: TDefinition,
opt?: { packed?: boolean }
): struct.StructType<struct.StructTypeTupleDefinitionToStructTypeDefinition<TDefinition>>;
/**
* Creates a new {@link struct.StructType} for the provided field definitions.
*/
(fields?: Record<string, ref.TypeLike>, opt?: { packed?: boolean }): struct.StructType;
/**
* Creates a new {@link struct.StructType} for the provided field definitions.
*/
(fields?: Array<[string, ref.TypeLike]>, opt?: { packed?: boolean }): struct.StructType;
};

@@ -20,6 +61,67 @@

declare namespace struct {
interface Field {
type: ref.Type;
/**
* Base constraint for an object-based struct type definition.
*/
type StructTypeObjectDefinitionBase = Record<string, ref.TypeLike>;
/**
* This is a marker type that causes TypeScript to use string literal inference when inferring a generic from {@link StructTypeObjectDefinitionBase}.
* If it is not used, `new StructType({ x: "int" })` will be inferred as `new StructType<{ x: string }>(...)` instead of `new StructType<{ x: "int" }>(...)`.
*/
type StructTypeObjectDefinitionInferenceMarker = Record<string, "void">;
/**
* Converts a {@link StructTypeObjectDefinitionBase} into a consistent subtype of {@link StructTypeDefinitionBase}. If `any` is used, it is passed along
* to be interpreted to use a fallback definition for a struct.
*/
type StructTypeObjectDefinitionToStructTypeDefinition<T extends StructTypeObjectDefinitionBase> =
[T] extends [never] | [0] ? any : // catches T extends never/any (since `0` doesn't overlap with our constraint)
{ [P in keyof T]: ref.Type<ref.UnderlyingType<T[P]>>; };
/**
* Base constraint for an array-based struct type definition.
*/
type StructTypeTupleDefinitionBase = Array<[string, ref.TypeLike]>;
/**
* This is a marker type that causes TypeScript to use tuple-type and string literal inference when inferring a generic from {@link StructTypeTupleDefinitionBase}.
* If it is not used, `new StructType([["x", "int"]])` will be inferred as `new StructType<[string, string][]>(...)` instead of `new StructType<[["x", "int"]]>(...)`.
*/
type StructTypeTupleDefinitionInferenceMarker = [["", "void"]];
/**
* Converts a {@link StructTypeTupleDefinitionBase} into a consistent subtype of {@link StructTypeDefinitionBase}. If `any` is used, it is passed along
* to be interpreted to use a fallback definition for a struct.
*/
type StructTypeTupleDefinitionToStructTypeDefinition<T extends StructTypeTupleDefinitionBase> =
[T] extends [never] | [0] ? any : // catches T extends never/any (since `0` doesn't overlap with our constraint)
{ [P in Extract<keyof T, `${number}`> as Extract<T[P], [string, ref.TypeLike]>[0]]: ref.Type<ref.UnderlyingType<Extract<T[P], [string, ref.TypeLike]>[1]>>; };
/**
* Base constraint for a consistent struct type definition.
*/
type StructTypeDefinitionBase = Record<string, ref.Type>;
/**
* Converts a {@link StructTypeDefinitionBase} into a set of fields for use with {@link StructType.fields}.
*/
type StructFields<T extends StructTypeDefinitionBase> =
[T] extends [never] | [0] ? Record<string, Field> : // catches T extends never/any (since `0` doesn't overlap with our constraint)
{ [P in keyof T]: Field<ref.UnderlyingType<T[P]>>; };
/**
* Converts a {@link StructTypeDefinitionBase} into a an object type representing the runtime shape of a {@link StructType}.
*/
type StructObject<T extends StructTypeDefinitionBase> =
[T] extends [never] | [0] ? Record<string, any> : // catches T extends never/any (since `0` doesn't overlap with our constraint)
{ [P in keyof T]: ref.UnderlyingType<T[P]>; };
/**
* Defines a field in a {@link StructType}.
*/
interface Field<T = any> {
type: ref.Type<T>;
offset: number;
}
/**

@@ -35,12 +137,12 @@ * This is the `constructor` of the Struct type that gets returned.

*/
interface StructType extends ref.Type {
interface StructType<TDefinition extends StructTypeDefinitionBase = any> extends ref.Type<StructObject<TDefinition>> {
/** Pass it an existing Buffer instance to use that as the backing buffer. */
new (arg: Buffer, data?: Record<string, any>): Record<string, any>;
new (data?: Record<string, any>): Record<string, any>;
new (arg: Buffer, data?: Partial<StructObject<TDefinition>>): StructObject<TDefinition>;
new (data?: Partial<StructObject<TDefinition>>): StructObject<TDefinition>;
/** Pass it an existing Buffer instance to use that as the backing buffer. */
(arg: Buffer, data?: Record<string, any>): Record<string, any>;
(data?: Record<string, any>): Record<string, any>;
(arg: Buffer, data?: Partial<StructObject<TDefinition>>): StructObject<TDefinition>;
(data?: Partial<StructObject<TDefinition>>): StructObject<TDefinition>;
fields: Record<string, Field>;
fields: StructFields<TDefinition>;

@@ -53,3 +155,3 @@ /**

*/
defineProperty(name: string, type: string | ref.Type): void;
defineProperty(name: string, type: ref.TypeLike): void;

@@ -56,0 +158,0 @@ /**

{
"name": "@types/ref-struct-di",
"version": "1.1.1",
"version": "1.1.2",
"description": "TypeScript definitions for ref-struct-di",

@@ -20,2 +20,9 @@ "license": "MIT",

"types": "index.d.ts",
"typesVersions": {
"<=4.1": {
"*": [
"ts4.1/*"
]
}
},
"repository": {

@@ -30,4 +37,4 @@ "type": "git",

},
"typesPublisherContentHash": "c96c6000dcae1ee27bae4368b10dc9510e65c5e9f2a3b33d82bfdc40578b85f5",
"typesPublisherContentHash": "cf500678da710191519f26e4d24d8556fac44f9a11da6b0b6836fd4553a538af",
"typeScriptVersion": "3.5"
}

2

ref-struct-di/README.md

@@ -11,3 +11,3 @@ # Installation

### Additional Details
* Last updated: Thu, 27 May 2021 05:31:24 GMT
* Last updated: Thu, 27 May 2021 15:31:27 GMT
* Dependencies: [@types/ref-napi](https://npmjs.com/package/@types/ref-napi)

@@ -14,0 +14,0 @@ * Global values: none

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc