You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

@xylabs/object-model

Package Overview
Dependencies
Maintainers
5
Versions
117
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@xylabs/object-model

Base functionality used throughout XY Labs TypeScript/JavaScript libraries

latest
Source
npmnpm
Version
5.0.86
Version published
Weekly downloads
12K
-2.51%
Maintainers
5
Weekly downloads
 
Created
Source

@xylabs/object-model

logo

main-build npm-badge npm-downloads-badge jsdelivr-badge npm-license-badge codacy-badge codeclimate-badge snyk-badge socket-badge

Base functionality used throughout XY Labs TypeScript/JavaScript libraries

Reference

@xylabs/object-model

Interfaces

InterfaceDescription
TypeCheckConfigConfiguration options for type check functions, with optional logging.
TypeCheckRequiredConfigType check configuration that marks the value as required, causing assertions on failure.
TypeCheckOptionalConfigType check configuration that marks the value as optional, returning undefined on failure.

Type Aliases

Type AliasDescription
AnyObjectAny object, which means that it does not enforce the set of fields that it has. Extending from AnyObject will result in a type that includes the universal set of field names
AsTypeFunctionA type-narrowing function that attempts to cast a value to T, with optional assertion and configuration overloads.
AsOptionalTypeFunctionA simplified type-narrowing function that returns T or undefined, without assertion support.
CompareA comparator function that returns a negative number if a < b, zero if a == b, and a positive number if a > b.
EmptyObjectAn empty object, which means that it does enforce the set of field names, defaulting to an empty set until extended from, which then adds only those additional fields
StringOrAlertFunctionA string message or function that produces an assertion error message for a failed type check.
TypeCheckA type guard function that checks whether a value conforms to type T, with optional configuration.

interfaces

TypeCheckConfig

@xylabs/object-model

Configuration options for type check functions, with optional logging.

Extended by

Properties

PropertyType
log?boolean | Logger

TypeCheckOptionalConfig

@xylabs/object-model

Type check configuration that marks the value as optional, returning undefined on failure.

Extends

Properties

PropertyTypeInherited from
log?boolean | LoggerTypeCheckConfig.log
requiredfalse-

TypeCheckRequiredConfig

@xylabs/object-model

Type check configuration that marks the value as required, causing assertions on failure.

Extends

Properties

PropertyTypeInherited from
log?boolean | LoggerTypeCheckConfig.log
requiredtrue-

type-aliases

AnyObject

@xylabs/object-model

type AnyObject = EmptyObject & Partial<Record<TypedKey, unknown>>;

Any object, which means that it does not enforce the set of fields that it has. Extending from AnyObject will result in a type that includes the universal set of field names

AsOptionalTypeFunction

@xylabs/object-model

type AsOptionalTypeFunction<T> = <TType>(value: AnyNonPromise) => TType | undefined;

A simplified type-narrowing function that returns T or undefined, without assertion support.

Type Parameters

Type ParameterDefault type
T extends AnyNonPromiseAnyNonPromise

Type Parameters

Type Parameter
TType extends AnyNonPromise

Parameters

ParameterType
valueAnyNonPromise

Returns

TType | undefined

AsTypeFunction

@xylabs/object-model

type AsTypeFunction<T> = {
<TType>  (value: AnyNonPromise): TType | undefined;
<TType>  (value: AnyNonPromise, config: TypeCheckRequiredConfig): TType;
<TType>  (value: AnyNonPromise, config: 
  | TypeCheckConfig
  | TypeCheckOptionalConfig): TType | undefined;
<TType>  (value: AnyNonPromise, assert: StringOrAlertFunction<TType>): TType | undefined;
<TType>  (value: AnyNonPromise, assert: StringOrAlertFunction<TType>, config: TypeCheckRequiredConfig): TType;
<TType>  (value: AnyNonPromise, assert: StringOrAlertFunction<TType>, config: 
  | TypeCheckConfig
  | TypeCheckOptionalConfig): TType | undefined;
};

A type-narrowing function that attempts to cast a value to T, with optional assertion and configuration overloads.

Type Parameters

Type ParameterDefault type
T extends AnyNonPromiseAnyNonPromise

Call Signature

<TType>(value: AnyNonPromise): TType | undefined;

Type Parameters

Type Parameter
TType extends AnyNonPromise

Parameters

ParameterType
valueAnyNonPromise

Returns

TType | undefined

Call Signature

<TType>(value: AnyNonPromise, config: TypeCheckRequiredConfig): TType;

Type Parameters

Type Parameter
TType extends AnyNonPromise

Parameters

ParameterType
valueAnyNonPromise
configTypeCheckRequiredConfig

Returns

TType

Call Signature

<TType>(value: AnyNonPromise, config: 
  | TypeCheckConfig
  | TypeCheckOptionalConfig): TType | undefined;

Type Parameters

Type Parameter
TType extends AnyNonPromise

Parameters

ParameterType
valueAnyNonPromise
config| TypeCheckConfig | TypeCheckOptionalConfig

Returns

TType | undefined

Call Signature

<TType>(value: AnyNonPromise, assert: StringOrAlertFunction<TType>): TType | undefined;

Type Parameters

Type Parameter
TType extends AnyNonPromise

Parameters

ParameterType
valueAnyNonPromise
assertStringOrAlertFunction<TType>

Returns

TType | undefined

Call Signature

<TType>(
   value: AnyNonPromise, 
   assert: StringOrAlertFunction<TType>, 
   config: TypeCheckRequiredConfig): TType;

Type Parameters

Type Parameter
TType extends AnyNonPromise

Parameters

ParameterType
valueAnyNonPromise
assertStringOrAlertFunction<TType>
configTypeCheckRequiredConfig

Returns

TType

Call Signature

<TType>(
   value: AnyNonPromise, 
   assert: StringOrAlertFunction<TType>, 
   config: 
  | TypeCheckConfig
  | TypeCheckOptionalConfig): TType | undefined;

Type Parameters

Type Parameter
TType extends AnyNonPromise

Parameters

ParameterType
valueAnyNonPromise
assertStringOrAlertFunction<TType>
config| TypeCheckConfig | TypeCheckOptionalConfig

Returns

TType | undefined

Compare

@xylabs/object-model

type Compare<T> = (a: T, b: T) => number;

A comparator function that returns a negative number if a < b, zero if a == b, and a positive number if a > b.

Type Parameters

Type Parameter
T

Parameters

ParameterType
aT
bT

Returns

number

EmptyObject

@xylabs/object-model

type EmptyObject<T> = Exclude<{ [K in keyof T]?: never }, unknown[] | (...args: unknown[]) => unknown | null>;

An empty object, which means that it does enforce the set of field names, defaulting to an empty set until extended from, which then adds only those additional fields

Type Parameters

Type ParameterDefault type
T extends objectobject

StringOrAlertFunction

@xylabs/object-model

type StringOrAlertFunction<T> = string | AssertExMessageFunc<T>;

A string message or function that produces an assertion error message for a failed type check.

Type Parameters

Type Parameter
T extends AnyNonPromise

TypeCheck

@xylabs/object-model

type TypeCheck<T> = {
  (obj: AnyNonPromise): obj is T;
  (obj: AnyNonPromise, config: TypeCheckConfig): obj is T;
  (obj: AnyNonPromise, config: 
  | number
  | TypeCheckConfig
  | undefined): obj is T;
};

A type guard function that checks whether a value conforms to type T, with optional configuration.

Type Parameters

Type Parameter
T extends TypedValue

Call Signature

(obj: AnyNonPromise): obj is T;

Parameters

ParameterType
objAnyNonPromise

Returns

obj is T

Call Signature

(obj: AnyNonPromise, config: TypeCheckConfig): obj is T;

Parameters

ParameterType
objAnyNonPromise
configTypeCheckConfig

Returns

obj is T

Call Signature

(obj: AnyNonPromise, config: 
  | number
  | TypeCheckConfig
  | undefined): obj is T;

Parameters

ParameterType
objAnyNonPromise
config| number | TypeCheckConfig | undefined

Returns

obj is T

Part of sdk-js

Maintainers

License

See the LICENSE file for license details

Credits

Made with 🔥 and ❄️ by XYLabs

FAQs

Package last updated on 11 Mar 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts