
Research
Namastex.ai npm Packages Hit with TeamPCP-Style CanisterWorm Malware
Malicious Namastex.ai npm packages appear to replicate TeamPCP-style Canister Worm tradecraft, including exfiltration and self-propagation.
@xylabs/typeof
Advanced tools
Base functionality used throughout XY Labs TypeScript/JavaScript libraries
Base functionality used throughout XY Labs TypeScript/JavaScript libraries
Using npm:
npm install {{name}}
Using yarn:
yarn add {{name}}
Using pnpm:
pnpm add {{name}}
Using bun:
bun add {{name}}
See the LICENSE file for license rights and limitations (LGPL-3.0-only).
### .temp-typedoc
### functions
### <a id="ifDefined"></a>ifDefined
function ifDefined<T>(value, func): T | undefined;
Invokes the callback only if the value is neither null nor undefined.
T
T
The value to check.
(value) => void
The callback to invoke with the value if it is defined.
T | undefined
The value if defined, or undefined otherwise.
### <a id="ifTypeOf"></a>ifTypeOf
function ifTypeOf<T, R>(
typeName,
value,
trueFunc,
isFunc?): R | undefined;
Invokes the callback if the value matches the specified type, with an optional additional predicate.
T
R
The expected type name to match against.
unknown
The value to check.
(value) => R
The callback to invoke if the type matches.
(value) => boolean
Optional additional predicate that must also return true.
R | undefined
The result of trueFunc if the type matches (and isFunc passes), or undefined.
### <a id="isArray"></a>isArray
function isArray(value): value is readonly unknown[];
Type guard that checks whether a value is an array.
unknown
value is readonly unknown[]
function isArray<T>(value): value is Extract<T, readonly unknown[]>;
Type guard that checks whether a value is an array.
T
T
value is Extract<T, readonly unknown[]>
### <a id="isArrayBufferView"></a>isArrayBufferView
function isArrayBufferView(value): value is ArrayBufferView<ArrayBufferLike>;
Type guard that checks whether a value is an ArrayBufferView (e.g., TypedArray or DataView).
unknown
value is ArrayBufferView<ArrayBufferLike>
function isArrayBufferView<T>(value): value is Extract<T, ArrayBufferView<ArrayBufferLike>>;
Type guard that checks whether a value is an ArrayBufferView (e.g., TypedArray or DataView).
T extends ArrayBufferView<ArrayBufferLike>
T
value is Extract<T, ArrayBufferView<ArrayBufferLike>>
### <a id="isBigInt"></a>isBigInt
function isBigInt(value): value is bigint;
Type guard that checks whether a value is a bigint.
unknown
value is bigint
function isBigInt<T>(value): value is Extract<T, bigint>;
Type guard that checks whether a value is a bigint.
T extends bigint
T
value is Extract<T, bigint>
### <a id="isBlob"></a>isBlob
function isBlob(value): value is Blob;
Type guard that checks whether a value is a Blob instance.
unknown
value is Blob
function isBlob<T>(value): value is Extract<T, Blob>;
Type guard that checks whether a value is a Blob instance.
T extends Blob
T
value is Extract<T, Blob>
### <a id="isBoolean"></a>isBoolean
function isBoolean(value): value is boolean;
Type guard that checks whether a value is a boolean.
unknown
value is boolean
function isBoolean<T>(value): value is Extract<T, boolean>;
Type guard that checks whether a value is a boolean.
T extends boolean
T
value is Extract<T, boolean>
### <a id="isDataView"></a>isDataView
function isDataView(value): value is DataView<ArrayBufferLike>;
Type guard that checks whether a value is a DataView instance.
unknown
value is DataView<ArrayBufferLike>
function isDataView<T>(value): value is Extract<T, DataView<ArrayBufferLike>>;
Type guard that checks whether a value is a DataView instance.
T
T
value is Extract<T, DataView<ArrayBufferLike>>
### <a id="isDate"></a>isDate
function isDate(value): value is Date;
Type guard that checks whether a value is a Date instance.
unknown
value is Date
function isDate<T>(value): value is Extract<T, Date>;
Type guard that checks whether a value is a Date instance.
T
T
value is Extract<T, Date>
### <a id="isDateString"></a>isDateString
function isDateString(value): value is string;
Type guard that checks whether a value is a string that can be parsed as a valid date.
unknown
value is string
function isDateString<T>(value): value is Extract<T, string>;
Type guard that checks whether a value is a string that can be parsed as a valid date.
T
T
value is Extract<T, string>
### <a id="isDefined"></a>isDefined
function isDefined<T>(value): value is Exclude<T, undefined>;
Type guard that checks whether a value is not undefined.
T
T
value is Exclude<T, undefined>
### <a id="isDefinedNotNull"></a>isDefinedNotNull
function isDefinedNotNull<T>(value): value is Exclude<T, null | undefined>;
Type guard that checks whether a value is neither undefined nor null.
T
T
value is Exclude<T, null | undefined>
### <a id="isEmpty"></a>isEmpty
function isEmpty<T>(value): value is T;
Type guard that checks whether a value is empty (empty string, empty array, or empty object).
T
unknown
value is T
function isEmpty<K, V, T>(value): value is Extract<T, Record<K, never>>;
Type guard that checks whether a value is empty (empty string, empty array, or empty object).
K extends RecordKey
V
T extends Record<K, V>
T
value is Extract<T, Record<K, never>>
function isEmpty<T>(value): value is Extract<T, never[]>;
Type guard that checks whether a value is empty (empty string, empty array, or empty object).
T extends unknown[]
T
value is Extract<T, never[]>
### <a id="isEmptyArray"></a>isEmptyArray
function isEmptyArray(value): value is [];
Type guard that checks whether a value is an empty array.
unknown
value is []
function isEmptyArray<T>(value): value is Extract<T, unknown[]>;
Type guard that checks whether a value is an empty array.
T extends unknown[]
T
value is Extract<T, unknown[]>
### <a id="isEmptyObject"></a>isEmptyObject
function isEmptyObject(value): value is {};
Type guard that checks whether a value is an object with no own keys.
unknown
value is {}
function isEmptyObject<K, V, T>(value): value is Extract<T, Record<K, never>>;
Type guard that checks whether a value is an object with no own keys.
K extends RecordKey
V
T extends Record<K, V>
T
value is Extract<T, Record<K, never>>
### <a id="isEmptyString"></a>isEmptyString
function isEmptyString(value): value is "";
Type guard that checks whether a value is an empty string.
unknown
value is ""
function isEmptyString<T>(value): value is Extract<T, "">;
Type guard that checks whether a value is an empty string.
T extends string
T
value is Extract<T, "">
### <a id="isError"></a>isError
function isError(value): value is Error;
Type guard that checks whether a value is an Error instance.
unknown
value is Error
function isError<T>(value): value is Extract<T, Error>;
Type guard that checks whether a value is an Error instance.
T
T
value is Extract<T, Error>
### <a id="isFalsy"></a>isFalsy
function isFalsy<T>(value): value is Extract<T, false | "" | 0 | 0n | null | undefined>;
Type guard that checks whether a value is falsy (0, null, undefined, false, '', or 0n).
T
T
value is Extract<T, false | "" | 0 | 0n | null | undefined>
function isFalsy<T>(value): value is Extract<T, false>;
Type guard that checks whether a value is falsy (0, null, undefined, false, '', or 0n).
T extends boolean
T
value is Extract<T, false>
function isFalsy<T>(value): value is Extract<T, 0>;
Type guard that checks whether a value is falsy (0, null, undefined, false, '', or 0n).
T extends number
T
value is Extract<T, 0>
function isFalsy<T>(value): value is Extract<T, 0n>;
Type guard that checks whether a value is falsy (0, null, undefined, false, '', or 0n).
T extends bigint
T
value is Extract<T, 0n>
function isFalsy<T>(value): value is Extract<T, null>;
Type guard that checks whether a value is falsy (0, null, undefined, false, '', or 0n).
T extends null
T
value is Extract<T, null>
function isFalsy<T>(value): value is Extract<T, undefined>;
Type guard that checks whether a value is falsy (0, null, undefined, false, '', or 0n).
T extends undefined
T
value is Extract<T, undefined>
function isFalsy<T>(value): value is Extract<T, "">;
Type guard that checks whether a value is falsy (0, null, undefined, false, '', or 0n).
T extends string
T
value is Extract<T, "">
### <a id="isFile"></a>isFile
function isFile(value): value is File;
Type guard that checks whether a value is a File instance.
unknown
value is File
function isFile<T>(value): value is Extract<T, File>;
Type guard that checks whether a value is a File instance.
T extends File
T
value is Extract<T, File>
### <a id="isFunction"></a>isFunction
function isFunction(value): value is AnyFunction;
Type guard that checks whether a value is a function.
unknown
value is AnyFunction
function isFunction<T>(value): value is Extract<T, AnyFunction>;
Type guard that checks whether a value is a function.
T extends AnyFunction
T
value is Extract<T, AnyFunction>
### <a id="isMap"></a>isMap
function isMap(value): value is Map<unknown, unknown>;
Type guard that checks whether a value is a Map instance.
unknown
value is Map<unknown, unknown>
function isMap<K, V, T>(value): value is Extract<T, Map<K, V>>;
Type guard that checks whether a value is a Map instance.
K
V
T extends Map<K, V>
T
value is Extract<T, Map<K, V>>
### <a id="isNull"></a>isNull
function isNull(value): value is null;
Type guard that checks whether a value is null.
unknown
value is null
function isNull<T>(value): value is Extract<T, null>;
Type guard that checks whether a value is null.
T
T
value is Extract<T, null>
### <a id="isNumber"></a>isNumber
function isNumber(value): value is number;
Type guard that checks whether a value is a number.
unknown
value is number
function isNumber<T>(value): value is Extract<T, number>;
Type guard that checks whether a value is a number.
T extends number
T
value is Extract<T, number>
### <a id="isObject"></a>isObject
function isObject(value): value is object;
Type guard that checks whether a value is a plain object (not null and not an array).
unknown
value is object
function isObject<T>(value): value is Extract<T, object>;
Type guard that checks whether a value is a plain object (not null and not an array).
T extends object
T
value is Extract<T, object>
### <a id="isPopulatedArray"></a>isPopulatedArray
function isPopulatedArray(value): value is readonly unknown[];
Type guard that checks whether a value is a non-empty array.
unknown
value is readonly unknown[]
function isPopulatedArray<T>(value): value is Extract<T, readonly unknown[]>;
Type guard that checks whether a value is a non-empty array.
T extends unknown[]
T
value is Extract<T, readonly unknown[]>
### <a id="isPromise"></a>isPromise
function isPromise(value): value is Promise<unknown>;
Type guard that checks whether a value is a Promise instance.
unknown
value is Promise<unknown>
function isPromise<T>(value): value is Extract<T, Promise<unknown>>;
Type guard that checks whether a value is a Promise instance.
T
T
value is Extract<T, Promise<unknown>>
### <a id="isPromiseLike"></a>isPromiseLike
function isPromiseLike(value): value is Promise<unknown>;
Type guard that checks whether a value is promise-like (has a then method).
unknown
value is Promise<unknown>
function isPromiseLike<T>(value): value is Extract<T, Promise<unknown>>;
Type guard that checks whether a value is promise-like (has a then method).
T
T
value is Extract<T, Promise<unknown>>
### <a id="isRegExp"></a>isRegExp
function isRegExp(value): value is RegExp;
Type guard that checks whether a value is a RegExp instance.
unknown
value is RegExp
function isRegExp<T>(value): value is Extract<T, RegExp>;
Type guard that checks whether a value is a RegExp instance.
T extends RegExp
T
value is Extract<T, RegExp>
### <a id="isSet"></a>isSet
function isSet(value): value is Set<unknown>;
Type guard that checks whether a value is a Set instance.
unknown
value is Set<unknown>
function isSet<T>(value): value is Extract<T, Set<unknown>>;
Type guard that checks whether a value is a Set instance.
T extends Set<unknown>
unknown
value is Extract<T, Set<unknown>>
### <a id="isString"></a>isString
function isString(value): value is string;
Type guard that checks whether a value is a string.
unknown
value is string
function isString<T>(value): value is Extract<T, string>;
Type guard that checks whether a value is a string.
T extends string
T
value is Extract<T, string>
### <a id="isSymbol"></a>isSymbol
function isSymbol(value): value is symbol;
Type guard that checks whether a value is a symbol.
unknown
value is symbol
function isSymbol<T>(value): value is Extract<T, symbol>;
Type guard that checks whether a value is a symbol.
T extends symbol
T
value is Extract<T, symbol>
### <a id="isTruthy"></a>isTruthy
function isTruthy<T>(value): 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).
T
T
value is Exclude<T, false | "" | 0 | 0n | null | undefined>
function isTruthy<T>(value): value is Extract<T, true>;
Type guard that checks whether a value is truthy (not 0, null, undefined, false, '', or 0n).
T extends boolean
T
value is Extract<T, true>
function isTruthy<T>(value): value is Extract<T, number>;
Type guard that checks whether a value is truthy (not 0, null, undefined, false, '', or 0n).
T extends number
T
value is Extract<T, number>
function isTruthy<T>(value): value is Extract<T, bigint>;
Type guard that checks whether a value is truthy (not 0, null, undefined, false, '', or 0n).
T extends bigint
T
value is Extract<T, bigint>
function isTruthy<T>(value): value is Extract<T, null>;
Type guard that checks whether a value is truthy (not 0, null, undefined, false, '', or 0n).
T extends null
T
value is Extract<T, null>
function isTruthy<T>(value): value is Extract<T, undefined>;
Type guard that checks whether a value is truthy (not 0, null, undefined, false, '', or 0n).
T extends undefined
T
value is Extract<T, undefined>
function isTruthy<T>(value): value is Extract<T, string>;
Type guard that checks whether a value is truthy (not 0, null, undefined, false, '', or 0n).
T extends string
T
value is Extract<T, string>
### <a id="isType"></a>isType
function isType(value, expectedType): boolean;
Checks whether a value matches the expected field type, with correct handling for arrays and nulls.
unknown
The value to check.
The expected type string.
boolean
True if the value matches the expected type.
### <a id="isTypedArray"></a>isTypedArray
function isTypedArray(value): value is TypedArray;
Type guard that checks whether a value is a TypedArray (an array where every element is a TypedValue).
unknown
The value to check.
value is TypedArray
True if the value is an array of TypedValue elements.
### <a id="isTypedKey"></a>isTypedKey
function isTypedKey(value): value is string | number | symbol;
Type guard that checks whether a value is a valid TypedKey (string, bigint, number, or symbol).
unknown
The value to check.
value is string | number | symbol
True if the value is a valid TypedKey.
### <a id="isTypedObject"></a>isTypedObject
function isTypedObject(value): value is TypedObject;
Type guard that checks whether a value is a TypedObject (an object with TypedKey keys and TypedValue values).
unknown
The value to check.
value is TypedObject
True if the value is a valid TypedObject.
### <a id="isTypedValue"></a>isTypedValue
function isTypedValue(value): value is TypedValue;
Type guard that checks whether a value is a valid TypedValue.
unknown
The value to check.
value is TypedValue
True if the value is a string, number, boolean, null, TypedObject, or TypedArray.
### <a id="isUndefined"></a>isUndefined
function isUndefined(value): value is undefined;
Type guard that checks whether a value is undefined.
unknown
value is undefined
function isUndefined<T>(value): value is Extract<T, undefined>;
Type guard that checks whether a value is undefined.
T
T
value is Extract<T, undefined>
### <a id="isUndefinedOrNull"></a>isUndefinedOrNull
function isUndefinedOrNull(value): value is null | undefined;
Type guard that checks whether a value is undefined or null.
unknown
value is null | undefined
function isUndefinedOrNull<T>(value): value is Extract<T, null | undefined>;
Type guard that checks whether a value is undefined or null.
T
T
value is Extract<T, null | undefined>
### <a id="isValidTypedFieldPair"></a>isValidTypedFieldPair
function isValidTypedFieldPair(pair): pair is [key: string | number | symbol, value: TypedValue];
Type guard that checks whether a key-value pair has a valid TypedKey and TypedValue.
[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.
### <a id="isWeakMap"></a>isWeakMap
function isWeakMap(value): value is WeakMap<WeakKey, unknown>;
Type guard that checks whether a value is a WeakMap instance.
unknown
value is WeakMap<WeakKey, unknown>
function isWeakMap<K, V, T>(value): value is Extract<T, WeakMap<K, V>>;
Type guard that checks whether a value is a WeakMap instance.
K extends WeakKey
V
T extends WeakMap<K, V>
T
value is Extract<T, WeakMap<K, V>>
### <a id="isWeakSet"></a>isWeakSet
function isWeakSet(value): value is WeakSet<WeakKey>;
Type guard that checks whether a value is a WeakSet instance.
unknown
value is WeakSet<WeakKey>
function isWeakSet<K, T>(value): value is Extract<T, WeakSet<K>>;
Type guard that checks whether a value is a WeakSet instance.
K extends WeakKey
T extends WeakSet<K>
T
value is Extract<T, WeakSet<K>>
### <a id="typeOf"></a>typeOf
function typeOf<T>(item): TypeOfTypes;
Extended typeof that distinguishes arrays from objects (unlike native typeof).
T
T
The value to check.
The type of the item as a TypeOfTypes string.
### <a id="validateType"></a>validateType
function validateType<T>(
typeName,
value,
optional?): [T | undefined, Error[]];
Validates that a value matches the expected type, returning the value and any errors.
T
The expected type name.
T
The value to validate.
boolean = false
If true, undefined values are accepted without error.
[T | undefined, Error[]]
A tuple of [value or undefined, array of errors].
### type-aliases
### <a id="AnyFunction"></a>AnyFunction
type AnyFunction = (...args) => unknown;
A function type that accepts any arguments and returns unknown.
...unknown[]
unknown
### <a id="Brand"></a>Brand
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.
T
B
### <a id="FieldType"></a>FieldType
type FieldType =
| "string"
| "number"
| "object"
| "symbol"
| "undefined"
| "null"
| "array"
| "function";
Union of string literals representing the possible types of an object field.
### <a id="IdentityFunction"></a>IdentityFunction
type IdentityFunction<T> = (value) => value is T;
A type guard function that narrows an unknown value to type T.
T
unknown
value is T
### <a id="ObjectTypeShape"></a>ObjectTypeShape
type ObjectTypeShape = Record<string | number | symbol, FieldType>;
Describes the expected shape of an object by mapping each key to its expected field type.
### <a id="RecordKey"></a>RecordKey
type RecordKey = string | number | symbol;
A union of valid object key types.
### <a id="TypeOfTypes"></a>TypeOfTypes
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.
### <a id="TypedArray"></a>TypedArray
type TypedArray = TypedValue[];
An array of TypedValue elements.
### <a id="TypedKey"></a>TypedKey
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.
T extends string | void = void
### <a id="TypedObject"></a>TypedObject
type TypedObject =
| {
[key: string | number | symbol]: TypedValue;
}
| object;
An object whose keys are TypedKey and whose values are TypedValue.
### <a id="TypedValue"></a>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).
FAQs
Base functionality used throughout XY Labs TypeScript/JavaScript libraries
The npm package @xylabs/typeof receives a total of 4,128 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.

Research
Malicious Namastex.ai npm packages appear to replicate TeamPCP-style Canister Worm tradecraft, including exfiltration and self-propagation.

Product
Explore exportable charts for vulnerabilities, dependencies, and usage with Reports, Socket’s new extensible reporting framework.

Product
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.