
Security News
TC39 Advances Temporal to Stage 4 Alongside Several ECMAScript Proposals
TC39’s March 2026 meeting advanced eight ECMAScript proposals, including Temporal reaching Stage 4 and securing its place in the ECMAScript 2026 specification.
@xylabs/typeof
Advanced tools
Base functionality used throughout XY Labs TypeScript/JavaScript libraries
Base functionality used throughout XY Labs TypeScript/JavaScript libraries
@xylabs/typeof
| Type Alias | Description |
|---|---|
| Brand | Creates a branded type by intersecting base type T with brand type B, enabling nominal typing in TypeScript. |
| IdentityFunction | A type guard function that narrows an unknown value to type T. |
| FieldType | Union of string literals representing the possible types of an object field. |
| ObjectTypeShape | Describes the expected shape of an object by mapping each key to its expected field type. |
| TypeOfTypes | Union of string literals representing the possible results of the extended typeOf function. |
| TypedValue | A value that can appear in a typed object tree (primitives, objects, arrays, functions, and symbols). |
| TypedKey | A valid key for a typed object. Defaults to string |
| TypedObject | An object whose keys are TypedKey and whose values are TypedValue. |
| TypedArray | An array of TypedValue elements. |
| AnyFunction | A function type that accepts any arguments and returns unknown. |
| RecordKey | A union of valid object key types. |
| Function | Description |
|---|---|
| isTypedKey | Type guard that checks whether a value is a valid TypedKey (string, bigint, number, or symbol). |
| isTypedValue | Type guard that checks whether a value is a valid TypedValue. |
| isTypedArray | Type guard that checks whether a value is a TypedArray (an array where every element is a TypedValue). |
| isValidTypedFieldPair | Type guard that checks whether a key-value pair has a valid TypedKey and TypedValue. |
| isTypedObject | Type guard that checks whether a value is a TypedObject (an object with TypedKey keys and TypedValue values). |
| ifDefined | Invokes the callback only if the value is neither null nor undefined. |
| ifTypeOf | Invokes the callback if the value matches the specified type, with an optional additional predicate. |
| isUndefined | Type guard that checks whether a value is undefined. |
| isDefined | Type guard that checks whether a value is not undefined. |
| isNull | Type guard that checks whether a value is null. |
| isDefinedNotNull | Type guard that checks whether a value is neither undefined nor null. |
| isUndefinedOrNull | Type guard that checks whether a value is undefined or null. |
| isBigInt | Type guard that checks whether a value is a bigint. |
| isString | Type guard that checks whether a value is a string. |
| isNumber | Type guard that checks whether a value is a number. |
| isObject | Type guard that checks whether a value is a plain object (not null and not an array). |
| isArray | Type guard that checks whether a value is an array. |
| isFunction | Type guard that checks whether a value is a function. |
| isSymbol | Type guard that checks whether a value is a symbol. |
| isEmptyObject | Type guard that checks whether a value is an object with no own keys. |
| isEmptyString | Type guard that checks whether a value is an empty string. |
| isEmptyArray | Type guard that checks whether a value is an empty array. |
| isPopulatedArray | Type guard that checks whether a value is a non-empty array. |
| isEmpty | Type guard that checks whether a value is empty (empty string, empty array, or empty object). |
| isFalsy | Type guard that checks whether a value is falsy (0, null, undefined, false, '', or 0n). |
| isTruthy | Type guard that checks whether a value is truthy (not 0, null, undefined, false, '', or 0n). |
| isBoolean | Type guard that checks whether a value is a boolean. |
| isDateString | Type guard that checks whether a value is a string that can be parsed as a valid date. |
| isDate | Type guard that checks whether a value is a Date instance. |
| isRegExp | Type guard that checks whether a value is a RegExp instance. |
| isError | Type guard that checks whether a value is an Error instance. |
| isPromise | Type guard that checks whether a value is a Promise instance. |
| isPromiseLike | Type guard that checks whether a value is promise-like (has a then method). |
| isMap | Type guard that checks whether a value is a Map instance. |
| isArrayBufferView | Type guard that checks whether a value is an ArrayBufferView (e.g., TypedArray or DataView). |
| isSet | Type guard that checks whether a value is a Set instance. |
| isWeakMap | Type guard that checks whether a value is a WeakMap instance. |
| isWeakSet | Type guard that checks whether a value is a WeakSet instance. |
| isDataView | Type guard that checks whether a value is a DataView instance. |
| isBlob | Type guard that checks whether a value is a Blob instance. |
| isFile | Type guard that checks whether a value is a File instance. |
| isType | Checks whether a value matches the expected field type, with correct handling for arrays and nulls. |
| typeOf | Extended typeof that distinguishes arrays from objects (unlike native typeof). |
| validateType | Validates that a value matches the expected type, returning the value and any errors. |
function ifDefined<T>(value: T, func: (value: T) => void): T | undefined;
Invokes the callback only if the value is neither null nor undefined.
| Type Parameter |
|---|
T |
| Parameter | Type | Description |
|---|---|---|
value | T | The value to check. |
func | (value: T) => void | The callback to invoke with the value if it is defined. |
T | undefined
The value if defined, or undefined otherwise.
function ifTypeOf<T, R>(
typeName: TypeOfTypes,
value: unknown,
trueFunc: (value: T) => R,
isFunc?: (value: T) => boolean): R | undefined;
Invokes the callback if the value matches the specified type, with an optional additional predicate.
| Type Parameter |
|---|
T |
R |
| Parameter | Type | Description |
|---|---|---|
typeName | TypeOfTypes | The expected type name to match against. |
value | unknown | The value to check. |
trueFunc | (value: T) => R | The callback to invoke if the type matches. |
isFunc? | (value: T) => boolean | Optional additional predicate that must also return true. |
R | undefined
The result of trueFunc if the type matches (and isFunc passes), or undefined.
function isArray(value: unknown): value is readonly unknown[];
Type guard that checks whether a value is an array.
| Parameter | Type |
|---|---|
value | unknown |
value is readonly unknown[]
function isArray<T>(value: T): value is Extract<T, readonly unknown[]>;
Type guard that checks whether a value is an array.
| Type Parameter |
|---|
T |
| Parameter | Type |
|---|---|
value | T |
value is Extract<T, readonly unknown[]>
function isArrayBufferView(value: unknown): value is ArrayBufferView<ArrayBufferLike>;
Type guard that checks whether a value is an ArrayBufferView (e.g., TypedArray or DataView).
| Parameter | Type |
|---|---|
value | unknown |
value is ArrayBufferView<ArrayBufferLike>
function isArrayBufferView<T>(value: T): value is Extract<T, ArrayBufferView<ArrayBufferLike>>;
Type guard that checks whether a value is an ArrayBufferView (e.g., TypedArray or DataView).
| Type Parameter |
|---|
T extends ArrayBufferView<ArrayBufferLike> |
| Parameter | Type |
|---|---|
value | T |
value is Extract<T, ArrayBufferView<ArrayBufferLike>>
function isBigInt(value: unknown): value is bigint;
Type guard that checks whether a value is a bigint.
| Parameter | Type |
|---|---|
value | unknown |
value is bigint
function isBigInt<T>(value: T): value is Extract<T, bigint>;
Type guard that checks whether a value is a bigint.
| Type Parameter |
|---|
T extends bigint |
| Parameter | Type |
|---|---|
value | T |
value is Extract<T, bigint>
function isBlob(value: unknown): value is Blob;
Type guard that checks whether a value is a Blob instance.
| Parameter | Type |
|---|---|
value | unknown |
value is Blob
function isBlob<T>(value: T): value is Extract<T, Blob>;
Type guard that checks whether a value is a Blob instance.
| Type Parameter |
|---|
T extends Blob |
| Parameter | Type |
|---|---|
value | T |
value is Extract<T, Blob>
function isBoolean(value: unknown): value is boolean;
Type guard that checks whether a value is a boolean.
| Parameter | Type |
|---|---|
value | unknown |
value is boolean
function isBoolean<T>(value: T): value is Extract<T, boolean>;
Type guard that checks whether a value is a boolean.
| Type Parameter |
|---|
T extends boolean |
| Parameter | Type |
|---|---|
value | T |
value is Extract<T, boolean>
function isDataView(value: unknown): value is DataView<ArrayBufferLike>;
Type guard that checks whether a value is a DataView instance.
| Parameter | Type |
|---|---|
value | unknown |
value is DataView<ArrayBufferLike>
function isDataView<T>(value: T): value is Extract<T, DataView<ArrayBufferLike>>;
Type guard that checks whether a value is a DataView instance.
| Type Parameter |
|---|
T |
| Parameter | Type |
|---|---|
value | T |
value is Extract<T, DataView<ArrayBufferLike>>
function isDate(value: unknown): value is Date;
Type guard that checks whether a value is a Date instance.
| Parameter | Type |
|---|---|
value | unknown |
value is Date
function isDate<T>(value: T): value is Extract<T, Date>;
Type guard that checks whether a value is a Date instance.
| Type Parameter |
|---|
T |
| Parameter | Type |
|---|---|
value | T |
value is Extract<T, Date>
function isDateString(value: unknown): value is string;
Type guard that checks whether a value is a string that can be parsed as a valid date.
| Parameter | Type |
|---|---|
value | unknown |
value is string
function isDateString<T>(value: T): value is Extract<T, string>;
Type guard that checks whether a value is a string that can be parsed as a valid date.
| Type Parameter |
|---|
T |
| Parameter | Type |
|---|---|
value | T |
value is Extract<T, string>
function isDefined<T>(value: T): value is Exclude<T, undefined>;
Type guard that checks whether a value is not undefined.
| Type Parameter |
|---|
T |
| Parameter | Type |
|---|---|
value | T |
value is Exclude<T, undefined>
function isDefinedNotNull<T>(value: T): value is Exclude<T, null | undefined>;
Type guard that checks whether a value is neither undefined nor null.
| Type Parameter |
|---|
T |
| Parameter | Type |
|---|---|
value | T |
value is Exclude<T, null | undefined>
function isEmpty<T>(value: unknown): value is T;
Type guard that checks whether a value is empty (empty string, empty array, or empty object).
| Type Parameter |
|---|
T |
| Parameter | Type |
|---|---|
value | unknown |
value is T
function isEmpty<K, V, T>(value: T): value is Extract<T, Record<K, never>>;
Type guard that checks whether a value is empty (empty string, empty array, or empty object).
| Type Parameter |
|---|
K extends RecordKey |
V |
T extends Record<K, V> |
| Parameter | Type |
|---|---|
value | T |
value is Extract<T, Record<K, never>>
function isEmpty<T>(value: T): value is Extract<T, never[]>;
Type guard that checks whether a value is empty (empty string, empty array, or empty object).
| Type Parameter |
|---|
T extends unknown[] |
| Parameter | Type |
|---|---|
value | T |
value is Extract<T, never[]>
function isEmptyArray(value: unknown): value is [];
Type guard that checks whether a value is an empty array.
| Parameter | Type |
|---|---|
value | unknown |
value is []
function isEmptyArray<T>(value: T): value is Extract<T, unknown[]>;
Type guard that checks whether a value is an empty array.
| Type Parameter |
|---|
T extends unknown[] |
| Parameter | Type |
|---|---|
value | T |
value is Extract<T, unknown[]>
function isEmptyObject(value: unknown): value is {};
Type guard that checks whether a value is an object with no own keys.
| Parameter | Type |
|---|---|
value | unknown |
value is {}
function isEmptyObject<K, V, T>(value: T): value is Extract<T, Record<K, never>>;
Type guard that checks whether a value is an object with no own keys.
| Type Parameter |
|---|
K extends RecordKey |
V |
T extends Record<K, V> |
| Parameter | Type |
|---|---|
value | T |
value is Extract<T, Record<K, never>>
function isEmptyString(value: unknown): value is "";
Type guard that checks whether a value is an empty string.
| Parameter | Type |
|---|---|
value | unknown |
value is ""
function isEmptyString<T>(value: T): value is Extract<T, "">;
Type guard that checks whether a value is an empty string.
| Type Parameter |
|---|
T extends string |
| Parameter | Type |
|---|---|
value | T |
value is Extract<T, "">
function isError(value: unknown): value is Error;
Type guard that checks whether a value is an Error instance.
| Parameter | Type |
|---|---|
value | unknown |
value is Error
function isError<T>(value: T): value is Extract<T, Error>;
Type guard that checks whether a value is an Error instance.
| Type Parameter |
|---|
T |
| Parameter | Type |
|---|---|
value | T |
value is Extract<T, Error>
function isFalsy<T>(value: T): value is Extract<T, false | "" | 0 | 0n | null | undefined>;
Type guard that checks whether a value is falsy (0, null, undefined, false, '', or 0n).
| Type Parameter |
|---|
T |
| Parameter | Type |
|---|---|
value | T |
value is Extract<T, false | "" | 0 | 0n | null | undefined>
function isFalsy<T>(value: T): value is Extract<T, false>;
Type guard that checks whether a value is falsy (0, null, undefined, false, '', or 0n).
| Type Parameter |
|---|
T extends boolean |
| Parameter | Type |
|---|---|
value | T |
value is Extract<T, false>
function isFalsy<T>(value: T): value is Extract<T, 0>;
Type guard that checks whether a value is falsy (0, null, undefined, false, '', or 0n).
| Type Parameter |
|---|
T extends number |
| Parameter | Type |
|---|---|
value | T |
value is Extract<T, 0>
function isFalsy<T>(value: T): value is Extract<T, 0n>;
Type guard that checks whether a value is falsy (0, null, undefined, false, '', or 0n).
| Type Parameter |
|---|
T extends bigint |
| Parameter | Type |
|---|---|
value | T |
value is Extract<T, 0n>
function isFalsy<T>(value: T): value is Extract<T, null>;
Type guard that checks whether a value is falsy (0, null, undefined, false, '', or 0n).
| Type Parameter |
|---|
T extends null |
| Parameter | Type |
|---|---|
value | T |
value is Extract<T, null>
function isFalsy<T>(value: T): value is Extract<T, undefined>;
Type guard that checks whether a value is falsy (0, null, undefined, false, '', or 0n).
| Type Parameter |
|---|
T extends undefined |
| Parameter | Type |
|---|---|
value | T |
value is Extract<T, undefined>
function isFalsy<T>(value: T): value is Extract<T, "">;
Type guard that checks whether a value is falsy (0, null, undefined, false, '', or 0n).
| Type Parameter |
|---|
T extends string |
| Parameter | Type |
|---|---|
value | T |
value is Extract<T, "">
function isFile(value: unknown): value is File;
Type guard that checks whether a value is a File instance.
| Parameter | Type |
|---|---|
value | unknown |
value is File
function isFile<T>(value: T): value is Extract<T, File>;
Type guard that checks whether a value is a File instance.
| Type Parameter |
|---|
T extends File |
| Parameter | Type |
|---|---|
value | T |
value is Extract<T, File>
function isFunction(value: unknown): value is AnyFunction;
Type guard that checks whether a value is a function.
| Parameter | Type |
|---|---|
value | unknown |
value is AnyFunction
function isFunction<T>(value: T): value is Extract<T, AnyFunction>;
Type guard that checks whether a value is a function.
| Type Parameter |
|---|
T extends AnyFunction |
| Parameter | Type |
|---|---|
value | T |
value is Extract<T, AnyFunction>
function isMap(value: unknown): value is Map<unknown, unknown>;
Type guard that checks whether a value is a Map instance.
| Parameter | Type |
|---|---|
value | unknown |
value is Map<unknown, unknown>
function isMap<K, V, T>(value: T): value is Extract<T, Map<K, V>>;
Type guard that checks whether a value is a Map instance.
| Type Parameter |
|---|
K |
V |
T extends Map<K, V> |
| Parameter | Type |
|---|---|
value | T |
value is Extract<T, Map<K, V>>
function isNull(value: unknown): value is null;
Type guard that checks whether a value is null.
| Parameter | Type |
|---|---|
value | unknown |
value is null
function isNull<T>(value: T): value is Extract<T, null>;
Type guard that checks whether a value is null.
| Type Parameter |
|---|
T |
| Parameter | Type |
|---|---|
value | T |
value is Extract<T, null>
function isNumber(value: unknown): value is number;
Type guard that checks whether a value is a number.
| Parameter | Type |
|---|---|
value | unknown |
value is number
function isNumber<T>(value: T): value is Extract<T, number>;
Type guard that checks whether a value is a number.
| Type Parameter |
|---|
T extends number |
| Parameter | Type |
|---|---|
value | T |
value is Extract<T, number>
function isObject(value: unknown): value is object;
Type guard that checks whether a value is a plain object (not null and not an array).
| Parameter | Type |
|---|---|
value | unknown |
value is object
function isObject<T>(value: T): value is Extract<T, object>;
Type guard that checks whether a value is a plain object (not null and not an array).
| Type Parameter |
|---|
T extends object |
| Parameter | Type |
|---|---|
value | T |
value is Extract<T, object>
function isPopulatedArray(value: unknown): value is readonly unknown[];
Type guard that checks whether a value is a non-empty array.
| Parameter | Type |
|---|---|
value | unknown |
value is readonly unknown[]
function isPopulatedArray<T>(value: T): value is Extract<T, readonly unknown[]>;
Type guard that checks whether a value is a non-empty array.
| Type Parameter |
|---|
T extends unknown[] |
| Parameter | Type |
|---|---|
value | T |
value is Extract<T, readonly unknown[]>
function isPromise(value: unknown): value is Promise<unknown>;
Type guard that checks whether a value is a Promise instance.
| Parameter | Type |
|---|---|
value | unknown |
value is Promise<unknown>
function isPromise<T>(value: T): value is Extract<T, Promise<unknown>>;
Type guard that checks whether a value is a Promise instance.
| Type Parameter |
|---|
T |
| Parameter | Type |
|---|---|
value | T |
value is Extract<T, Promise<unknown>>
function isPromiseLike(value: unknown): value is Promise<unknown>;
Type guard that checks whether a value is promise-like (has a then method).
| Parameter | Type |
|---|---|
value | unknown |
value is Promise<unknown>
function isPromiseLike<T>(value: T): value is Extract<T, Promise<unknown>>;
Type guard that checks whether a value is promise-like (has a then method).
| Type Parameter |
|---|
T |
| Parameter | Type |
|---|---|
value | T |
value is Extract<T, Promise<unknown>>
function isRegExp(value: unknown): value is RegExp;
Type guard that checks whether a value is a RegExp instance.
| Parameter | Type |
|---|---|
value | unknown |
value is RegExp
function isRegExp<T>(value: T): value is Extract<T, RegExp>;
Type guard that checks whether a value is a RegExp instance.
| Type Parameter |
|---|
T extends RegExp |
| Parameter | Type |
|---|---|
value | T |
value is Extract<T, RegExp>
function isSet(value: unknown): value is Set<unknown>;
Type guard that checks whether a value is a Set instance.
| Parameter | Type |
|---|---|
value | unknown |
value is Set<unknown>
function isSet<T>(value: unknown): value is Extract<T, Set<unknown>>;
Type guard that checks whether a value is a Set instance.
| Type Parameter |
|---|
T extends Set<unknown> |
| Parameter | Type |
|---|---|
value | unknown |
value is Extract<T, Set<unknown>>
function isString(value: unknown): value is string;
Type guard that checks whether a value is a string.
| Parameter | Type |
|---|---|
value | unknown |
value is string
function isString<T>(value: T): value is Extract<T, string>;
Type guard that checks whether a value is a string.
| Type Parameter |
|---|
T extends string |
| Parameter | Type |
|---|---|
value | T |
value is Extract<T, string>
function isSymbol(value: unknown): value is symbol;
Type guard that checks whether a value is a symbol.
| Parameter | Type |
|---|---|
value | unknown |
value is symbol
function isSymbol<T>(value: T): value is Extract<T, symbol>;
Type guard that checks whether a value is a symbol.
| Type Parameter |
|---|
T extends symbol |
| Parameter | Type |
|---|---|
value | T |
value is Extract<T, symbol>
function isTruthy<T>(value: T): value is Exclude<T, false | "" | 0 | 0n | null | undefined>;
Type guard that checks whether a value is truthy (not 0, null, undefined, false, '', or 0n).
| Type Parameter |
|---|
T |
| Parameter | Type |
|---|---|
value | T |
value is Exclude<T, false | "" | 0 | 0n | null | undefined>
function isTruthy<T>(value: T): value is Extract<T, true>;
Type guard that checks whether a value is truthy (not 0, null, undefined, false, '', or 0n).
| Type Parameter |
|---|
T extends boolean |
| Parameter | Type |
|---|---|
value | T |
value is Extract<T, true>
function isTruthy<T>(value: T): value is Extract<T, number>;
Type guard that checks whether a value is truthy (not 0, null, undefined, false, '', or 0n).
| Type Parameter |
|---|
T extends number |
| Parameter | Type |
|---|---|
value | T |
value is Extract<T, number>
function isTruthy<T>(value: T): value is Extract<T, bigint>;
Type guard that checks whether a value is truthy (not 0, null, undefined, false, '', or 0n).
| Type Parameter |
|---|
T extends bigint |
| Parameter | Type |
|---|---|
value | T |
value is Extract<T, bigint>
function isTruthy<T>(value: T): value is Extract<T, null>;
Type guard that checks whether a value is truthy (not 0, null, undefined, false, '', or 0n).
| Type Parameter |
|---|
T extends null |
| Parameter | Type |
|---|---|
value | T |
value is Extract<T, null>
function isTruthy<T>(value: T): value is Extract<T, undefined>;
Type guard that checks whether a value is truthy (not 0, null, undefined, false, '', or 0n).
| Type Parameter |
|---|
T extends undefined |
| Parameter | Type |
|---|---|
value | T |
value is Extract<T, undefined>
function isTruthy<T>(value: T): value is Extract<T, string>;
Type guard that checks whether a value is truthy (not 0, null, undefined, false, '', or 0n).
| Type Parameter |
|---|
T extends string |
| Parameter | Type |
|---|---|
value | T |
value is Extract<T, string>
function isType(value: unknown, expectedType: FieldType): boolean;
Checks whether a value matches the expected field type, with correct handling for arrays and nulls.
| Parameter | Type | Description |
|---|---|---|
value | unknown | The value to check. |
expectedType | FieldType | The expected type string. |
boolean
True if the value matches the expected type.
function isTypedArray(value: unknown): value is TypedArray;
Type guard that checks whether a value is a TypedArray (an array where every element is a TypedValue).
| Parameter | Type | Description |
|---|---|---|
value | unknown | The value to check. |
value is TypedArray
True if the value is an array of TypedValue elements.
function isTypedKey(value: unknown): value is string | number | symbol;
Type guard that checks whether a value is a valid TypedKey (string, bigint, number, or symbol).
| Parameter | Type | Description |
|---|---|---|
value | unknown | The value to check. |
value is string | number | symbol
True if the value is a valid TypedKey.
function isTypedObject(value: unknown): value is TypedObject;
Type guard that checks whether a value is a TypedObject (an object with TypedKey keys and TypedValue values).
| Parameter | Type | Description |
|---|---|---|
value | unknown | The value to check. |
value is TypedObject
True if the value is a valid TypedObject.
function isTypedValue(value: unknown): value is TypedValue;
Type guard that checks whether a value is a valid TypedValue.
| Parameter | Type | Description |
|---|---|---|
value | unknown | The value to check. |
value is TypedValue
True if the value is a string, number, boolean, null, TypedObject, or TypedArray.
function isUndefined(value: unknown): value is undefined;
Type guard that checks whether a value is undefined.
| Parameter | Type |
|---|---|
value | unknown |
value is undefined
function isUndefined<T>(value: T): value is Extract<T, undefined>;
Type guard that checks whether a value is undefined.
| Type Parameter |
|---|
T |
| Parameter | Type |
|---|---|
value | T |
value is Extract<T, undefined>
function isUndefinedOrNull(value: unknown): value is null | undefined;
Type guard that checks whether a value is undefined or null.
| Parameter | Type |
|---|---|
value | unknown |
value is null | undefined
function isUndefinedOrNull<T>(value: T): value is Extract<T, null | undefined>;
Type guard that checks whether a value is undefined or null.
| Type Parameter |
|---|
T |
| Parameter | Type |
|---|---|
value | T |
value is Extract<T, null | undefined>
function isValidTypedFieldPair(pair: [unknown, unknown]): pair is [key: string | number | symbol, value: TypedValue];
Type guard that checks whether a key-value pair has a valid TypedKey and TypedValue.
| Parameter | Type | Description |
|---|---|---|
pair | [unknown, unknown] | A tuple of [key, value] to validate. |
pair is [key: string | number | symbol, value: TypedValue]
True if the key is a TypedKey and the value is a TypedValue.
function isWeakMap(value: unknown): value is WeakMap<WeakKey, unknown>;
Type guard that checks whether a value is a WeakMap instance.
| Parameter | Type |
|---|---|
value | unknown |
value is WeakMap<WeakKey, unknown>
function isWeakMap<K, V, T>(value: T): value is Extract<T, WeakMap<K, V>>;
Type guard that checks whether a value is a WeakMap instance.
| Type Parameter |
|---|
K extends WeakKey |
V |
T extends WeakMap<K, V> |
| Parameter | Type |
|---|---|
value | T |
value is Extract<T, WeakMap<K, V>>
function isWeakSet(value: unknown): value is WeakSet<WeakKey>;
Type guard that checks whether a value is a WeakSet instance.
| Parameter | Type |
|---|---|
value | unknown |
value is WeakSet<WeakKey>
function isWeakSet<K, T>(value: T): value is Extract<T, WeakSet<K>>;
Type guard that checks whether a value is a WeakSet instance.
| Type Parameter |
|---|
K extends WeakKey |
T extends WeakSet<K> |
| Parameter | Type |
|---|---|
value | T |
value is Extract<T, WeakSet<K>>
function typeOf<T>(item: T): TypeOfTypes;
Extended typeof that distinguishes arrays from objects (unlike native typeof).
| Type Parameter |
|---|
T |
| Parameter | Type | Description |
|---|---|---|
item | T | The value to check. |
The type of the item as a TypeOfTypes string.
function validateType<T>(
typeName: TypeOfTypes,
value: T,
optional?: boolean): [T | undefined, Error[]];
Validates that a value matches the expected type, returning the value and any errors.
| Type Parameter |
|---|
T |
| Parameter | Type | Default value | Description |
|---|---|---|---|
typeName | TypeOfTypes | undefined | The expected type name. |
value | T | undefined | The value to validate. |
optional | boolean | false | If true, undefined values are accepted without error. |
[T | undefined, Error[]]
A tuple of [value or undefined, array of errors].
type AnyFunction = (...args: unknown[]) => unknown;
A function type that accepts any arguments and returns unknown.
| Parameter | Type |
|---|---|
...args | unknown[] |
unknown
type Brand<T, B> = T & { [K in keyof B]: B[K] };
Creates a branded type by intersecting base type T with brand type B, enabling nominal typing in TypeScript.
| Type Parameter |
|---|
T |
B |
type FieldType =
| "string"
| "number"
| "object"
| "symbol"
| "undefined"
| "null"
| "array"
| "function";
Union of string literals representing the possible types of an object field.
type IdentityFunction<T> = (value: unknown) => value is T;
A type guard function that narrows an unknown value to type T.
| Type Parameter |
|---|
T |
| Parameter | Type |
|---|---|
value | unknown |
value is T
type ObjectTypeShape = Record<string | number | symbol, FieldType>;
Describes the expected shape of an object by mapping each key to its expected field type.
type RecordKey = string | number | symbol;
A union of valid object key types.
type TypeOfTypes =
| "string"
| "number"
| "object"
| "array"
| "buffer"
| "null"
| "undefined"
| "bigint"
| "boolean"
| "function"
| "symbol";
Union of string literals representing the possible results of the extended typeOf function.
type TypedArray = TypedValue[];
An array of TypedValue elements.
type TypedKey<T> = T extends string ? T : string | number | symbol;
A valid key for a typed object. Defaults to string | number | symbol unless narrowed by T.
| Type Parameter | Default type |
|---|---|
T extends string | void | void |
type TypedObject =
| {
[key: string | number | symbol]: TypedValue;
}
| object;
An object whose keys are TypedKey and whose values are TypedValue.
type TypedValue =
| bigint
| string
| number
| boolean
| null
| TypedObject
| TypedArray
| Function
| symbol
| undefined;
A value that can appear in a typed object tree (primitives, objects, arrays, functions, and symbols).
Part of sdk-js
See the LICENSE file for license details
FAQs
Base functionality used throughout XY Labs TypeScript/JavaScript libraries
The npm package @xylabs/typeof receives a total of 2,292 weekly downloads. As such, @xylabs/typeof popularity was classified as popular.
We found that @xylabs/typeof demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?

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.

Security News
TC39’s March 2026 meeting advanced eight ECMAScript proposals, including Temporal reaching Stage 4 and securing its place in the ECMAScript 2026 specification.

Research
/Security News
Since January 31, 2026, we identified at least 72 additional malicious Open VSX extensions, including transitive GlassWorm loader extensions targeting developers.

Research
Six malicious Packagist packages posing as OphimCMS themes contain trojanized jQuery that exfiltrates URLs, injects ads, and loads FUNNULL-linked redirects.