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

@xylabs/object

Package Overview
Dependencies
Maintainers
7
Versions
101
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@xylabs/object - npm Package Compare versions

Comparing version 3.2.0 to 3.3.0

12

dist/browser/asObject.d.ts
import { AnyObject } from './AnyObject';
export declare const asAnyObject: {
<TType extends AnyObject>(value: import("@xylabs/promise").AnyNonPromise, config?: import("./AsTypeFactory").TypeCheckConfig | undefined): TType | undefined;
<TType_1 extends AnyObject>(value: import("@xylabs/promise").AnyNonPromise, assert: import("./AsTypeFactory").StringOrAlertFunction<AnyObject>, config?: import("./AsTypeFactory").TypeCheckConfig | undefined): TType_1;
<TType extends AnyObject>(value: string | number | bigint | boolean | symbol | object | Function | AnyObject | {
[key: string]: import("@xylabs/promise").TypedValue;
[key: number]: import("@xylabs/promise").TypedValue;
[key: symbol]: import("@xylabs/promise").TypedValue;
} | import("@xylabs/promise").TypedArray | null, config?: import("./AsTypeFactory").TypeCheckConfig | undefined): TType | undefined;
<TType_1 extends AnyObject>(value: string | number | bigint | boolean | symbol | object | Function | AnyObject | {
[key: string]: import("@xylabs/promise").TypedValue;
[key: number]: import("@xylabs/promise").TypedValue;
[key: symbol]: import("@xylabs/promise").TypedValue;
} | import("@xylabs/promise").TypedArray | null, assert: import("./AsTypeFactory").StringOrAlertFunction<AnyObject>, config?: import("./AsTypeFactory").TypeCheckConfig | undefined): TType_1;
};
//# sourceMappingURL=asObject.d.ts.map

14

dist/browser/AsObjectFactory.d.ts
import { TypedObject } from '@xylabs/promise';
import { TypeCheck } from './AsTypeFactory';
export declare const AsObjectFactory: {
create: <T extends TypedObject>(typeCheck: TypeCheck<T>) => {
<TType extends T>(value: import("@xylabs/promise").AnyNonPromise, config?: import("./AsTypeFactory").TypeCheckConfig | undefined): TType | undefined;
<TType_1 extends T>(value: import("@xylabs/promise").AnyNonPromise, assert: import("./AsTypeFactory").StringOrAlertFunction<T>, config?: import("./AsTypeFactory").TypeCheckConfig | undefined): TType_1;
create: <T extends TypedObject, E = void>(typeCheck: TypeCheck<T, E>) => {
<TType extends T>(value: T | (E extends void ? Exclude<undefined, E> | Exclude<null, E> | Exclude<string, E> | Exclude<number, E> | Exclude<bigint, E> | Exclude<false, E> | Exclude<true, E> | Exclude<symbol, E> | Exclude<object, E> | Exclude<Function, E> | Exclude<{
[key: string]: import("@xylabs/promise").TypedValue;
[key: number]: import("@xylabs/promise").TypedValue;
[key: symbol]: import("@xylabs/promise").TypedValue;
}, E> | Exclude<import("@xylabs/promise").TypedArray, E> : import("@xylabs/promise").AnyNonPromise), config?: import("./AsTypeFactory").TypeCheckConfig | undefined): TType | undefined;
<TType_1 extends T>(value: T | (E extends void ? Exclude<undefined, E> | Exclude<null, E> | Exclude<string, E> | Exclude<number, E> | Exclude<bigint, E> | Exclude<false, E> | Exclude<true, E> | Exclude<symbol, E> | Exclude<object, E> | Exclude<Function, E> | Exclude<{
[key: string]: import("@xylabs/promise").TypedValue;
[key: number]: import("@xylabs/promise").TypedValue;
[key: symbol]: import("@xylabs/promise").TypedValue;
}, E> | Exclude<import("@xylabs/promise").TypedArray, E> : import("@xylabs/promise").AnyNonPromise), assert: import("./AsTypeFactory").StringOrAlertFunction<T>, config?: import("./AsTypeFactory").TypeCheckConfig | undefined): TType_1;
};
};
//# sourceMappingURL=AsObjectFactory.d.ts.map

@@ -5,12 +5,13 @@ import { AssertExMessageFunc } from '@xylabs/assert';

export interface TypeCheckConfig {
disallowChecks?: ((value: unknown) => unknown)[];
log?: boolean | Logger;
}
export type StringOrAlertFunction<T extends AnyNonPromise> = string | AssertExMessageFunc<T>;
export type TypeCheck<T extends TypedValue> = (obj: AnyNonPromise, config?: TypeCheckConfig) => obj is T;
export type TypeCheck<T extends TypedValue, E = void> = (obj: (E extends void ? Exclude<AnyNonPromise, E> : AnyNonPromise) | T, config?: TypeCheckConfig) => obj is T;
export declare const AsTypeFactory: {
create: <T extends AnyNonPromise>(typeCheck: TypeCheck<T>) => {
<TType extends T>(value: AnyNonPromise, config?: TypeCheckConfig): TType | undefined;
<TType_1 extends T>(value: AnyNonPromise, assert: StringOrAlertFunction<T>, config?: TypeCheckConfig): TType_1;
create: <T extends AnyNonPromise, E = void>(typeCheck: TypeCheck<T, E>) => {
<TType extends T>(value: (E extends void ? Exclude<AnyNonPromise, E> : AnyNonPromise) | T, config?: TypeCheckConfig): TType | undefined;
<TType_1 extends T>(value: (E extends void ? Exclude<AnyNonPromise, E> : AnyNonPromise) | T, assert: StringOrAlertFunction<T>, config?: TypeCheckConfig): TType_1;
};
};
//# sourceMappingURL=AsTypeFactory.d.ts.map

@@ -17,2 +17,7 @@ // src/AsTypeFactory.ts

}
for (const disallowCheck of config?.disallowChecks ?? []) {
if (disallowCheck(value)) {
throw new TypeError("disallowed type");
}
}
const resolvedAssert = typeof assertOrConfig === "object" ? void 0 : assertOrConfig;

@@ -19,0 +24,0 @@ const resolvedConfig = typeof assertOrConfig === "object" ? assertOrConfig : config;

import { AnyObject } from './AnyObject';
export declare const asAnyObject: {
<TType extends AnyObject>(value: import("@xylabs/promise").AnyNonPromise, config?: import("./AsTypeFactory").TypeCheckConfig | undefined): TType | undefined;
<TType_1 extends AnyObject>(value: import("@xylabs/promise").AnyNonPromise, assert: import("./AsTypeFactory").StringOrAlertFunction<AnyObject>, config?: import("./AsTypeFactory").TypeCheckConfig | undefined): TType_1;
<TType extends AnyObject>(value: string | number | bigint | boolean | symbol | object | Function | AnyObject | {
[key: string]: import("@xylabs/promise").TypedValue;
[key: number]: import("@xylabs/promise").TypedValue;
[key: symbol]: import("@xylabs/promise").TypedValue;
} | import("@xylabs/promise").TypedArray | null, config?: import("./AsTypeFactory").TypeCheckConfig | undefined): TType | undefined;
<TType_1 extends AnyObject>(value: string | number | bigint | boolean | symbol | object | Function | AnyObject | {
[key: string]: import("@xylabs/promise").TypedValue;
[key: number]: import("@xylabs/promise").TypedValue;
[key: symbol]: import("@xylabs/promise").TypedValue;
} | import("@xylabs/promise").TypedArray | null, assert: import("./AsTypeFactory").StringOrAlertFunction<AnyObject>, config?: import("./AsTypeFactory").TypeCheckConfig | undefined): TType_1;
};
//# sourceMappingURL=asObject.d.ts.map
import { TypedObject } from '@xylabs/promise';
import { TypeCheck } from './AsTypeFactory';
export declare const AsObjectFactory: {
create: <T extends TypedObject>(typeCheck: TypeCheck<T>) => {
<TType extends T>(value: import("@xylabs/promise").AnyNonPromise, config?: import("./AsTypeFactory").TypeCheckConfig | undefined): TType | undefined;
<TType_1 extends T>(value: import("@xylabs/promise").AnyNonPromise, assert: import("./AsTypeFactory").StringOrAlertFunction<T>, config?: import("./AsTypeFactory").TypeCheckConfig | undefined): TType_1;
create: <T extends TypedObject, E = void>(typeCheck: TypeCheck<T, E>) => {
<TType extends T>(value: T | (E extends void ? Exclude<undefined, E> | Exclude<null, E> | Exclude<string, E> | Exclude<number, E> | Exclude<bigint, E> | Exclude<false, E> | Exclude<true, E> | Exclude<symbol, E> | Exclude<object, E> | Exclude<Function, E> | Exclude<{
[key: string]: import("@xylabs/promise").TypedValue;
[key: number]: import("@xylabs/promise").TypedValue;
[key: symbol]: import("@xylabs/promise").TypedValue;
}, E> | Exclude<import("@xylabs/promise").TypedArray, E> : import("@xylabs/promise").AnyNonPromise), config?: import("./AsTypeFactory").TypeCheckConfig | undefined): TType | undefined;
<TType_1 extends T>(value: T | (E extends void ? Exclude<undefined, E> | Exclude<null, E> | Exclude<string, E> | Exclude<number, E> | Exclude<bigint, E> | Exclude<false, E> | Exclude<true, E> | Exclude<symbol, E> | Exclude<object, E> | Exclude<Function, E> | Exclude<{
[key: string]: import("@xylabs/promise").TypedValue;
[key: number]: import("@xylabs/promise").TypedValue;
[key: symbol]: import("@xylabs/promise").TypedValue;
}, E> | Exclude<import("@xylabs/promise").TypedArray, E> : import("@xylabs/promise").AnyNonPromise), assert: import("./AsTypeFactory").StringOrAlertFunction<T>, config?: import("./AsTypeFactory").TypeCheckConfig | undefined): TType_1;
};
};
//# sourceMappingURL=AsObjectFactory.d.ts.map

@@ -5,12 +5,13 @@ import { AssertExMessageFunc } from '@xylabs/assert';

export interface TypeCheckConfig {
disallowChecks?: ((value: unknown) => unknown)[];
log?: boolean | Logger;
}
export type StringOrAlertFunction<T extends AnyNonPromise> = string | AssertExMessageFunc<T>;
export type TypeCheck<T extends TypedValue> = (obj: AnyNonPromise, config?: TypeCheckConfig) => obj is T;
export type TypeCheck<T extends TypedValue, E = void> = (obj: (E extends void ? Exclude<AnyNonPromise, E> : AnyNonPromise) | T, config?: TypeCheckConfig) => obj is T;
export declare const AsTypeFactory: {
create: <T extends AnyNonPromise>(typeCheck: TypeCheck<T>) => {
<TType extends T>(value: AnyNonPromise, config?: TypeCheckConfig): TType | undefined;
<TType_1 extends T>(value: AnyNonPromise, assert: StringOrAlertFunction<T>, config?: TypeCheckConfig): TType_1;
create: <T extends AnyNonPromise, E = void>(typeCheck: TypeCheck<T, E>) => {
<TType extends T>(value: (E extends void ? Exclude<AnyNonPromise, E> : AnyNonPromise) | T, config?: TypeCheckConfig): TType | undefined;
<TType_1 extends T>(value: (E extends void ? Exclude<AnyNonPromise, E> : AnyNonPromise) | T, assert: StringOrAlertFunction<T>, config?: TypeCheckConfig): TType_1;
};
};
//# sourceMappingURL=AsTypeFactory.d.ts.map

@@ -17,2 +17,7 @@ // src/AsTypeFactory.ts

}
for (const disallowCheck of config?.disallowChecks ?? []) {
if (disallowCheck(value)) {
throw new TypeError("disallowed type");
}
}
const resolvedAssert = typeof assertOrConfig === "object" ? void 0 : assertOrConfig;

@@ -19,0 +24,0 @@ const resolvedConfig = typeof assertOrConfig === "object" ? assertOrConfig : config;

import { AnyObject } from './AnyObject';
export declare const asAnyObject: {
<TType extends AnyObject>(value: import("@xylabs/promise").AnyNonPromise, config?: import("./AsTypeFactory").TypeCheckConfig | undefined): TType | undefined;
<TType_1 extends AnyObject>(value: import("@xylabs/promise").AnyNonPromise, assert: import("./AsTypeFactory").StringOrAlertFunction<AnyObject>, config?: import("./AsTypeFactory").TypeCheckConfig | undefined): TType_1;
<TType extends AnyObject>(value: string | number | bigint | boolean | symbol | object | Function | AnyObject | {
[key: string]: import("@xylabs/promise").TypedValue;
[key: number]: import("@xylabs/promise").TypedValue;
[key: symbol]: import("@xylabs/promise").TypedValue;
} | import("@xylabs/promise").TypedArray | null, config?: import("./AsTypeFactory").TypeCheckConfig | undefined): TType | undefined;
<TType_1 extends AnyObject>(value: string | number | bigint | boolean | symbol | object | Function | AnyObject | {
[key: string]: import("@xylabs/promise").TypedValue;
[key: number]: import("@xylabs/promise").TypedValue;
[key: symbol]: import("@xylabs/promise").TypedValue;
} | import("@xylabs/promise").TypedArray | null, assert: import("./AsTypeFactory").StringOrAlertFunction<AnyObject>, config?: import("./AsTypeFactory").TypeCheckConfig | undefined): TType_1;
};
//# sourceMappingURL=asObject.d.ts.map
import { TypedObject } from '@xylabs/promise';
import { TypeCheck } from './AsTypeFactory';
export declare const AsObjectFactory: {
create: <T extends TypedObject>(typeCheck: TypeCheck<T>) => {
<TType extends T>(value: import("@xylabs/promise").AnyNonPromise, config?: import("./AsTypeFactory").TypeCheckConfig | undefined): TType | undefined;
<TType_1 extends T>(value: import("@xylabs/promise").AnyNonPromise, assert: import("./AsTypeFactory").StringOrAlertFunction<T>, config?: import("./AsTypeFactory").TypeCheckConfig | undefined): TType_1;
create: <T extends TypedObject, E = void>(typeCheck: TypeCheck<T, E>) => {
<TType extends T>(value: T | (E extends void ? Exclude<undefined, E> | Exclude<null, E> | Exclude<string, E> | Exclude<number, E> | Exclude<bigint, E> | Exclude<false, E> | Exclude<true, E> | Exclude<symbol, E> | Exclude<object, E> | Exclude<Function, E> | Exclude<{
[key: string]: import("@xylabs/promise").TypedValue;
[key: number]: import("@xylabs/promise").TypedValue;
[key: symbol]: import("@xylabs/promise").TypedValue;
}, E> | Exclude<import("@xylabs/promise").TypedArray, E> : import("@xylabs/promise").AnyNonPromise), config?: import("./AsTypeFactory").TypeCheckConfig | undefined): TType | undefined;
<TType_1 extends T>(value: T | (E extends void ? Exclude<undefined, E> | Exclude<null, E> | Exclude<string, E> | Exclude<number, E> | Exclude<bigint, E> | Exclude<false, E> | Exclude<true, E> | Exclude<symbol, E> | Exclude<object, E> | Exclude<Function, E> | Exclude<{
[key: string]: import("@xylabs/promise").TypedValue;
[key: number]: import("@xylabs/promise").TypedValue;
[key: symbol]: import("@xylabs/promise").TypedValue;
}, E> | Exclude<import("@xylabs/promise").TypedArray, E> : import("@xylabs/promise").AnyNonPromise), assert: import("./AsTypeFactory").StringOrAlertFunction<T>, config?: import("./AsTypeFactory").TypeCheckConfig | undefined): TType_1;
};
};
//# sourceMappingURL=AsObjectFactory.d.ts.map

@@ -5,12 +5,13 @@ import { AssertExMessageFunc } from '@xylabs/assert';

export interface TypeCheckConfig {
disallowChecks?: ((value: unknown) => unknown)[];
log?: boolean | Logger;
}
export type StringOrAlertFunction<T extends AnyNonPromise> = string | AssertExMessageFunc<T>;
export type TypeCheck<T extends TypedValue> = (obj: AnyNonPromise, config?: TypeCheckConfig) => obj is T;
export type TypeCheck<T extends TypedValue, E = void> = (obj: (E extends void ? Exclude<AnyNonPromise, E> : AnyNonPromise) | T, config?: TypeCheckConfig) => obj is T;
export declare const AsTypeFactory: {
create: <T extends AnyNonPromise>(typeCheck: TypeCheck<T>) => {
<TType extends T>(value: AnyNonPromise, config?: TypeCheckConfig): TType | undefined;
<TType_1 extends T>(value: AnyNonPromise, assert: StringOrAlertFunction<T>, config?: TypeCheckConfig): TType_1;
create: <T extends AnyNonPromise, E = void>(typeCheck: TypeCheck<T, E>) => {
<TType extends T>(value: (E extends void ? Exclude<AnyNonPromise, E> : AnyNonPromise) | T, config?: TypeCheckConfig): TType | undefined;
<TType_1 extends T>(value: (E extends void ? Exclude<AnyNonPromise, E> : AnyNonPromise) | T, assert: StringOrAlertFunction<T>, config?: TypeCheckConfig): TType_1;
};
};
//# sourceMappingURL=AsTypeFactory.d.ts.map

@@ -17,2 +17,7 @@ // src/AsTypeFactory.ts

}
for (const disallowCheck of (config == null ? void 0 : config.disallowChecks) ?? []) {
if (disallowCheck(value)) {
throw new TypeError("disallowed type");
}
}
const resolvedAssert = typeof assertOrConfig === "object" ? void 0 : assertOrConfig;

@@ -19,0 +24,0 @@ const resolvedConfig = typeof assertOrConfig === "object" ? assertOrConfig : config;

@@ -14,5 +14,5 @@ {

"dependencies": {
"@xylabs/assert": "^3.2.0",
"@xylabs/logger": "^3.2.0",
"@xylabs/promise": "^3.2.0"
"@xylabs/assert": "^3.3.0",
"@xylabs/logger": "^3.3.0",
"@xylabs/promise": "^3.3.0"
},

@@ -62,4 +62,4 @@ "devDependencies": {

"sideEffects": false,
"version": "3.2.0",
"version": "3.3.0",
"type": "module"
}

@@ -6,5 +6,5 @@ import { TypedObject } from '@xylabs/promise'

export const AsObjectFactory = {
create: <T extends TypedObject>(typeCheck: TypeCheck<T>) => {
return AsTypeFactory.create<T>(typeCheck)
create: <T extends TypedObject, E = void>(typeCheck: TypeCheck<T, E>) => {
return AsTypeFactory.create<T, E>(typeCheck)
},
}

@@ -6,2 +6,3 @@ import { assertEx, AssertExMessageFunc } from '@xylabs/assert'

export interface TypeCheckConfig {
disallowChecks?: ((value: unknown) => unknown)[]
log?: boolean | Logger

@@ -12,10 +13,13 @@ }

export type TypeCheck<T extends TypedValue> = (obj: AnyNonPromise, config?: TypeCheckConfig) => obj is T
export type TypeCheck<T extends TypedValue, E = void> = (
obj: (E extends void ? Exclude<AnyNonPromise, E> : AnyNonPromise) | T,
config?: TypeCheckConfig,
) => obj is T
export const AsTypeFactory = {
// eslint-disable-next-line @typescript-eslint/ban-types
create: <T extends AnyNonPromise>(typeCheck: TypeCheck<T>) => {
create: <T extends AnyNonPromise, E = void>(typeCheck: TypeCheck<T, E>) => {
function func<TType extends T>(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
value: AnyNonPromise,
value: (E extends void ? Exclude<AnyNonPromise, E> : AnyNonPromise) | T,
config?: TypeCheckConfig,

@@ -25,3 +29,3 @@ ): TType | undefined

// eslint-disable-next-line @typescript-eslint/no-explicit-any
value: AnyNonPromise,
value: (E extends void ? Exclude<AnyNonPromise, E> : AnyNonPromise) | T,
assert: StringOrAlertFunction<T>,

@@ -32,3 +36,3 @@ config?: TypeCheckConfig,

// eslint-disable-next-line @typescript-eslint/no-explicit-any
value: AnyNonPromise,
value: (E extends void ? Exclude<AnyNonPromise, E> : AnyNonPromise) | T,
assertOrConfig?: StringOrAlertFunction<T> | TypeCheckConfig,

@@ -49,2 +53,8 @@ config?: TypeCheckConfig,

for (const disallowCheck of config?.disallowChecks ?? []) {
if (disallowCheck(value)) {
throw new TypeError('disallowed type')
}
}
const resolvedAssert = (typeof assertOrConfig === 'object' ? undefined : assertOrConfig) as StringOrAlertFunction<T> | undefined

@@ -51,0 +61,0 @@ const resolvedConfig = typeof assertOrConfig === 'object' ? assertOrConfig : config

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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