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

utilium

Package Overview
Dependencies
Maintainers
1
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 0.3.2 to 0.3.3

86

dist/struct.d.ts

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

*/
export declare function member(type: ValidPrimitiveType | ClassLike, length?: number): (target: object, context?: ClassMemberDecoratorContext | string | symbol) => void;
export declare function member(type: ValidPrimitiveType | ClassLike, length?: number): (target: object, { name }: ClassMemberDecoratorContext) => void;
/**

@@ -43,85 +43,85 @@ * Serializes a struct into a Uint8Array

int8: {
(length?: number): (target: object, context?: string | symbol | ClassMemberDecoratorContext) => void;
(target: object, context?: string | symbol | ClassMemberDecoratorContext): void;
(length?: number): (target: object, context: ClassMemberDecoratorContext) => void;
(target: object, context: ClassMemberDecoratorContext): void;
};
int16: {
(length?: number): (target: object, context?: string | symbol | ClassMemberDecoratorContext) => void;
(target: object, context?: string | symbol | ClassMemberDecoratorContext): void;
(length?: number): (target: object, context: ClassMemberDecoratorContext) => void;
(target: object, context: ClassMemberDecoratorContext): void;
};
int32: {
(length?: number): (target: object, context?: string | symbol | ClassMemberDecoratorContext) => void;
(target: object, context?: string | symbol | ClassMemberDecoratorContext): void;
(length?: number): (target: object, context: ClassMemberDecoratorContext) => void;
(target: object, context: ClassMemberDecoratorContext): void;
};
int64: {
(length?: number): (target: object, context?: string | symbol | ClassMemberDecoratorContext) => void;
(target: object, context?: string | symbol | ClassMemberDecoratorContext): void;
(length?: number): (target: object, context: ClassMemberDecoratorContext) => void;
(target: object, context: ClassMemberDecoratorContext): void;
};
uint8: {
(length?: number): (target: object, context?: string | symbol | ClassMemberDecoratorContext) => void;
(target: object, context?: string | symbol | ClassMemberDecoratorContext): void;
(length?: number): (target: object, context: ClassMemberDecoratorContext) => void;
(target: object, context: ClassMemberDecoratorContext): void;
};
uint16: {
(length?: number): (target: object, context?: string | symbol | ClassMemberDecoratorContext) => void;
(target: object, context?: string | symbol | ClassMemberDecoratorContext): void;
(length?: number): (target: object, context: ClassMemberDecoratorContext) => void;
(target: object, context: ClassMemberDecoratorContext): void;
};
uint32: {
(length?: number): (target: object, context?: string | symbol | ClassMemberDecoratorContext) => void;
(target: object, context?: string | symbol | ClassMemberDecoratorContext): void;
(length?: number): (target: object, context: ClassMemberDecoratorContext) => void;
(target: object, context: ClassMemberDecoratorContext): void;
};
uint64: {
(length?: number): (target: object, context?: string | symbol | ClassMemberDecoratorContext) => void;
(target: object, context?: string | symbol | ClassMemberDecoratorContext): void;
(length?: number): (target: object, context: ClassMemberDecoratorContext) => void;
(target: object, context: ClassMemberDecoratorContext): void;
};
float32: {
(length?: number): (target: object, context?: string | symbol | ClassMemberDecoratorContext) => void;
(target: object, context?: string | symbol | ClassMemberDecoratorContext): void;
(length?: number): (target: object, context: ClassMemberDecoratorContext) => void;
(target: object, context: ClassMemberDecoratorContext): void;
};
float64: {
(length?: number): (target: object, context?: string | symbol | ClassMemberDecoratorContext) => void;
(target: object, context?: string | symbol | ClassMemberDecoratorContext): void;
(length?: number): (target: object, context: ClassMemberDecoratorContext) => void;
(target: object, context: ClassMemberDecoratorContext): void;
};
Int8: {
(length?: number): (target: object, context?: string | symbol | ClassMemberDecoratorContext) => void;
(target: object, context?: string | symbol | ClassMemberDecoratorContext): void;
(length?: number): (target: object, context: ClassMemberDecoratorContext) => void;
(target: object, context: ClassMemberDecoratorContext): void;
};
Int16: {
(length?: number): (target: object, context?: string | symbol | ClassMemberDecoratorContext) => void;
(target: object, context?: string | symbol | ClassMemberDecoratorContext): void;
(length?: number): (target: object, context: ClassMemberDecoratorContext) => void;
(target: object, context: ClassMemberDecoratorContext): void;
};
Int32: {
(length?: number): (target: object, context?: string | symbol | ClassMemberDecoratorContext) => void;
(target: object, context?: string | symbol | ClassMemberDecoratorContext): void;
(length?: number): (target: object, context: ClassMemberDecoratorContext) => void;
(target: object, context: ClassMemberDecoratorContext): void;
};
Int64: {
(length?: number): (target: object, context?: string | symbol | ClassMemberDecoratorContext) => void;
(target: object, context?: string | symbol | ClassMemberDecoratorContext): void;
(length?: number): (target: object, context: ClassMemberDecoratorContext) => void;
(target: object, context: ClassMemberDecoratorContext): void;
};
Uint8: {
(length?: number): (target: object, context?: string | symbol | ClassMemberDecoratorContext) => void;
(target: object, context?: string | symbol | ClassMemberDecoratorContext): void;
(length?: number): (target: object, context: ClassMemberDecoratorContext) => void;
(target: object, context: ClassMemberDecoratorContext): void;
};
Uint16: {
(length?: number): (target: object, context?: string | symbol | ClassMemberDecoratorContext) => void;
(target: object, context?: string | symbol | ClassMemberDecoratorContext): void;
(length?: number): (target: object, context: ClassMemberDecoratorContext) => void;
(target: object, context: ClassMemberDecoratorContext): void;
};
Uint32: {
(length?: number): (target: object, context?: string | symbol | ClassMemberDecoratorContext) => void;
(target: object, context?: string | symbol | ClassMemberDecoratorContext): void;
(length?: number): (target: object, context: ClassMemberDecoratorContext) => void;
(target: object, context: ClassMemberDecoratorContext): void;
};
Uint64: {
(length?: number): (target: object, context?: string | symbol | ClassMemberDecoratorContext) => void;
(target: object, context?: string | symbol | ClassMemberDecoratorContext): void;
(length?: number): (target: object, context: ClassMemberDecoratorContext) => void;
(target: object, context: ClassMemberDecoratorContext): void;
};
Float32: {
(length?: number): (target: object, context?: string | symbol | ClassMemberDecoratorContext) => void;
(target: object, context?: string | symbol | ClassMemberDecoratorContext): void;
(length?: number): (target: object, context: ClassMemberDecoratorContext) => void;
(target: object, context: ClassMemberDecoratorContext): void;
};
Float64: {
(length?: number): (target: object, context?: string | symbol | ClassMemberDecoratorContext) => void;
(target: object, context?: string | symbol | ClassMemberDecoratorContext): void;
(length?: number): (target: object, context: ClassMemberDecoratorContext) => void;
(target: object, context: ClassMemberDecoratorContext): void;
};
char: {
(length?: number): (target: object, context?: string | symbol | ClassMemberDecoratorContext) => void;
(target: object, context?: string | symbol | ClassMemberDecoratorContext): void;
(length?: number): (target: object, context: ClassMemberDecoratorContext) => void;
(target: object, context: ClassMemberDecoratorContext): void;
};
};

@@ -77,4 +77,3 @@ import { capitalize } from './string.js';

export function member(type, length) {
return function (target, context) {
let name = typeof context == 'object' ? context.name : context;
return function (target, { name }) {
if (typeof name == 'symbol') {

@@ -84,5 +83,8 @@ console.warn('Symbol used for struct member name will be coerced to string: ' + name.toString());

}
if ((typeof target != 'object' || typeof target != 'function') && !('constructor' in target)) {
if (typeof target != 'object' || typeof target != 'function') {
throw new TypeError('Invalid member for struct field');
}
if (!('constructor' in target)) {
throw new TypeError('Invalid member for struct field');
}
target.constructor[init] ||= [];

@@ -171,3 +173,3 @@ target.constructor[init].push({ name, type, length });

function _member(type) {
function _(targetOrLength, context) {
function decorator(targetOrLength, context) {
if (typeof targetOrLength == 'number') {

@@ -178,3 +180,3 @@ return member(type, targetOrLength);

}
return _;
return decorator;
}

@@ -181,0 +183,0 @@ /**

{
"name": "utilium",
"version": "0.3.2",
"version": "0.3.3",
"description": "Typescript utilies",

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

@@ -136,4 +136,3 @@ import { capitalize } from './string.js';

export function member(type: ValidPrimitiveType | ClassLike, length?: number) {
return function (target: object, context?: ClassMemberDecoratorContext | string | symbol) {
let name = typeof context == 'object' ? context.name : context;
return function (target: object, { name }: ClassMemberDecoratorContext) {
if (typeof name == 'symbol') {

@@ -144,6 +143,10 @@ console.warn('Symbol used for struct member name will be coerced to string: ' + name.toString());

if ((typeof target != 'object' || typeof target != 'function') && !('constructor' in target)) {
if (typeof target != 'object' || typeof target != 'function') {
throw new TypeError('Invalid member for struct field');
}
if (!('constructor' in target)) {
throw new TypeError('Invalid member for struct field');
}
target.constructor[init] ||= [];

@@ -253,5 +256,5 @@ target.constructor[init].push({ name, type, length } satisfies MemberInit);

function _member<T extends ValidPrimitiveType>(type: T) {
function _(length?: number): (target: object, context?: string | symbol | ClassMemberDecoratorContext) => void;
function _(target: object, context?: string | symbol | ClassMemberDecoratorContext): void;
function _(targetOrLength: object | number, context?: string | symbol | ClassMemberDecoratorContext) {
function decorator(length?: number): (target: object, context: ClassMemberDecoratorContext) => void;
function decorator(target: object, context: ClassMemberDecoratorContext): void;
function decorator(targetOrLength: object | number, context?: ClassMemberDecoratorContext) {
if (typeof targetOrLength == 'number') {

@@ -263,3 +266,3 @@ return member(type, targetOrLength);

}
return _;
return decorator;
}

@@ -266,0 +269,0 @@

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