Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

utilium

Package Overview
Dependencies
Maintainers
0
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

utilium - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

src/internal/struct-symbols.d.ts

14

dist/internal/struct.d.ts

@@ -8,3 +8,4 @@ import type { ClassLike } from '../types.js';

}
export declare const init: unique symbol;
/** @deprecated */
export declare const init: typeof Symbol.struct_init;
/**

@@ -27,6 +28,7 @@ * Options for struct initialization

}
export declare const metadata: unique symbol;
/** @deprecated */
export declare const metadata: typeof Symbol.struct_metadata;
export interface _DecoratorMetadata<T extends Metadata = Metadata> extends DecoratorMetadata {
[metadata]?: T;
[init]?: MemberInit[];
[Symbol.struct_metadata]?: T;
[Symbol.struct_init]?: MemberInit[];
}

@@ -39,3 +41,3 @@ export interface DecoratorContext<T extends Metadata = Metadata> {

[Symbol.metadata]: DecoratorMetadata & {
[metadata]: T;
[Symbol.struct_metadata]: T;
};

@@ -49,3 +51,3 @@ new (): Instance<T>;

export declare function isValidMetadata<T extends Metadata = Metadata>(arg: unknown): arg is DecoratorMetadata & {
[metadata]: T;
[Symbol.struct_metadata]: T;
};

@@ -52,0 +54,0 @@ /**

@@ -1,5 +0,11 @@

export const init = Symbol('struct_init');
export const metadata = Symbol('struct');
// @ts-expect-error 2322
Symbol.struct_init ||= Symbol('struct_init');
// @ts-expect-error 2322
Symbol.struct_metadata ||= Symbol('struct_metadata');
/** @deprecated */
export const init = Symbol.struct_init;
/** @deprecated */
export const metadata = Symbol.struct_metadata;
export function isValidMetadata(arg) {
return arg != null && typeof arg == 'object' && metadata in arg;
return arg != null && typeof arg == 'object' && Symbol.struct_metadata in arg;
}

@@ -6,0 +12,0 @@ /**

import * as primitive from './internal/primitives.js';
import { checkInstance, checkStruct, init, isStatic, metadata, symbol_metadata } from './internal/struct.js';
import { checkInstance, checkStruct, isStatic, symbol_metadata } from './internal/struct.js';
import { capitalize } from './string.js';

@@ -16,3 +16,3 @@ export * as Struct from './internal/struct.js';

const struct = isStatic(type) ? type : type.constructor;
return struct[symbol_metadata(struct)][metadata].size;
return struct[symbol_metadata(struct)][Symbol.struct_metadata].size;
}

@@ -31,6 +31,6 @@ /**

context.metadata ??= {};
context.metadata[init] ||= [];
context.metadata[Symbol.struct_init] ||= [];
let size = 0;
const members = new Map();
for (const _ of context.metadata[init]) {
for (const _ of context.metadata[Symbol.struct_init]) {
const { name, type, length } = _;

@@ -48,3 +48,3 @@ if (!primitive.isValid(type) && !isStatic(type)) {

}
context.metadata[metadata] = { options, members, size };
context.metadata[Symbol.struct_metadata] = { options, members, size };
return target;

@@ -67,4 +67,4 @@ };

context.metadata ??= {};
context.metadata[init] ||= [];
context.metadata[init].push({ name, type, length });
context.metadata[Symbol.struct_init] ||= [];
context.metadata[Symbol.struct_init].push({ name, type, length });
return value;

@@ -78,3 +78,3 @@ };

checkInstance(instance);
const { options, members } = instance.constructor[symbol_metadata(instance.constructor)][metadata];
const { options, members } = instance.constructor[symbol_metadata(instance.constructor)][Symbol.struct_metadata];
const buffer = new Uint8Array(sizeof(instance));

@@ -114,3 +114,3 @@ const view = new DataView(buffer.buffer);

checkInstance(instance);
const { options, members } = instance.constructor[symbol_metadata(instance.constructor)][metadata];
const { options, members } = instance.constructor[symbol_metadata(instance.constructor)][Symbol.struct_metadata];
const buffer = _buffer instanceof Uint8Array ? _buffer : new Uint8Array('buffer' in _buffer ? _buffer.buffer : _buffer);

@@ -117,0 +117,0 @@ const view = new DataView(buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength));

{
"name": "utilium",
"version": "1.0.0",
"version": "1.0.1",
"description": "Typescript utilities",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

import type { ClassLike } from '../types.js';
import type * as primitive from './primitives.js';
// @ts-expect-error 2322
Symbol.struct_init ||= Symbol('struct_init');
// @ts-expect-error 2322
Symbol.struct_metadata ||= Symbol('struct_metadata');
export interface MemberInit {

@@ -10,3 +16,4 @@ name: string;

export const init: unique symbol = Symbol('struct_init');
/** @deprecated */
export const init: typeof Symbol.struct_init = Symbol.struct_init;

@@ -33,7 +40,8 @@ /**

export const metadata: unique symbol = Symbol('struct');
/** @deprecated */
export const metadata: typeof Symbol.struct_metadata = Symbol.struct_metadata;
export interface _DecoratorMetadata<T extends Metadata = Metadata> extends DecoratorMetadata {
[metadata]?: T;
[init]?: MemberInit[];
[Symbol.struct_metadata]?: T;
[Symbol.struct_init]?: MemberInit[];
}

@@ -49,3 +57,3 @@

[Symbol.metadata]: DecoratorMetadata & {
[metadata]: T;
[Symbol.struct_metadata]: T;
};

@@ -63,5 +71,5 @@ new (): Instance<T>;

): arg is DecoratorMetadata & {
[metadata]: T;
[Symbol.struct_metadata]: T;
} {
return arg != null && typeof arg == 'object' && metadata in arg;
return arg != null && typeof arg == 'object' && Symbol.struct_metadata in arg;
}

@@ -68,0 +76,0 @@

import * as primitive from './internal/primitives.js';
import type { DecoratorContext, InstanceLike, Member, MemberInit, Metadata, Options, Size, StaticLike } from './internal/struct.js';
import { checkInstance, checkStruct, init, isStatic, metadata, symbol_metadata, type MemberContext } from './internal/struct.js';
import { checkInstance, checkStruct, isStatic, symbol_metadata, type MemberContext } from './internal/struct.js';
import { capitalize } from './string.js';

@@ -23,3 +23,3 @@ import type { ClassLike } from './types.js';

return struct[symbol_metadata(struct)][metadata].size as Size<T>;
return struct[symbol_metadata(struct)][Symbol.struct_metadata].size as Size<T>;
}

@@ -40,6 +40,6 @@

context.metadata ??= {};
context.metadata[init] ||= [];
context.metadata[Symbol.struct_init] ||= [];
let size = 0;
const members = new Map<string, Member>();
for (const _ of context.metadata[init]) {
for (const _ of context.metadata[Symbol.struct_init]!) {
const { name, type, length } = _;

@@ -58,3 +58,3 @@ if (!primitive.isValid(type) && !isStatic(type)) {

context.metadata[metadata] = { options, members, size } satisfies Metadata;
context.metadata[Symbol.struct_metadata] = { options, members, size } satisfies Metadata;
return target;

@@ -80,4 +80,4 @@ };

context.metadata ??= {};
context.metadata[init] ||= [];
context.metadata[init].push({ name, type, length } satisfies MemberInit);
context.metadata[Symbol.struct_init] ||= [];
context.metadata[Symbol.struct_init]!.push({ name, type, length } satisfies MemberInit);
return value;

@@ -92,3 +92,3 @@ };

checkInstance(instance);
const { options, members } = instance.constructor[symbol_metadata(instance.constructor)][metadata];
const { options, members } = instance.constructor[symbol_metadata(instance.constructor)][Symbol.struct_metadata];

@@ -137,3 +137,3 @@ const buffer = new Uint8Array(sizeof(instance));

checkInstance(instance);
const { options, members } = instance.constructor[symbol_metadata(instance.constructor)][metadata];
const { options, members } = instance.constructor[symbol_metadata(instance.constructor)][Symbol.struct_metadata];

@@ -140,0 +140,0 @@ const buffer = _buffer instanceof Uint8Array ? _buffer : new Uint8Array('buffer' in _buffer ? _buffer.buffer : _buffer);

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