New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@tool-belt/type-predicates

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tool-belt/type-predicates - npm Package Compare versions

Comparing version 1.2.2 to 1.3.0

dist/index.mjs

1106

dist/index.d.ts

@@ -1,83 +0,1023 @@

export * from './assertions/assertIsAnyArrayBuffer';
export * from './assertions/assertIsArray';
export * from './assertions/assertIsArrayBuffer';
export * from './assertions/assertIsAsyncFunction';
export * from './assertions/assertIsAsyncGenerator';
export * from './assertions/assertIsAsyncGeneratorFunction';
export * from './assertions/assertIsAsyncIterable';
export * from './assertions/assertIsBigInt';
export * from './assertions/assertIsBoolean';
export * from './assertions/assertIsBooleanObject';
export * from './assertions/assertIsBuffer';
export * from './assertions/assertIsDataView';
export * from './assertions/assertIsDate';
export * from './assertions/assertIsDefined';
export * from './assertions/assertIsError';
export * from './assertions/assertIsFunction';
export * from './assertions/assertIsGenerator';
export * from './assertions/assertIsGeneratorFunction';
export * from './assertions/assertIsIterable';
export * from './assertions/assertIsIterator';
export * from './assertions/assertIsMap';
export * from './assertions/assertIsNotNull';
export * from './assertions/assertIsNotNullish';
export * from './assertions/assertIsNull';
export * from './assertions/assertIsNullish';
export * from './assertions/assertIsNumber';
export * from './assertions/assertIsNumberObject';
export * from './assertions/assertIsObject';
export * from './assertions/assertIsPromise';
export * from './assertions/assertIsRecord';
export * from './assertions/assertIsRegExp';
export * from './assertions/assertIsSet';
export * from './assertions/assertIsSharedArrayBuffer';
export * from './assertions/assertIsString';
export * from './assertions/assertIsStringObject';
export * from './assertions/assertIsSymbol';
export * from './assertions/assertIsTypedArray';
export * from './assertions/assertIsUndefined';
export * from './assertions/assertIsWeakMap';
export * from './assertions/assertIsWeakSet';
export * from './guards/isAnyArrayBuffer';
export * from './guards/isArray';
export * from './guards/isArrayBuffer';
export * from './guards/isAsyncFunction';
export * from './guards/isAsyncGenerator';
export * from './guards/isAsyncGeneratorFunction';
export * from './guards/isAsyncIterable';
export * from './guards/isBigInt';
export * from './guards/isBoolean';
export * from './guards/isBooleanObject';
export * from './guards/isBuffer';
export * from './guards/isDataView';
export * from './guards/isDate';
export * from './guards/isDefined';
export * from './guards/isError';
export * from './guards/isFunction';
export * from './guards/isGenerator';
export * from './guards/isGeneratorFunction';
export * from './guards/isIterable';
export * from './guards/isIterator';
export * from './guards/isMap';
export * from './guards/isNotNull';
export * from './guards/isNotNullish';
export * from './guards/isNull';
export * from './guards/isNullish';
export * from './guards/isNumber';
export * from './guards/isNumberObject';
export * from './guards/isObject';
export * from './guards/isPromise';
export * from './guards/isRecord';
export * from './guards/isRegExp';
export * from './guards/isSet';
export * from './guards/isSharedArrayBuffer';
export * from './guards/isString';
export * from './guards/isStringObject';
export * from './guards/isSymbol';
export * from './guards/isTypedArray';
export * from './guards/isUndefined';
export * from './guards/isWeakMap';
export * from './guards/isWeakSet';
export * from './types';
export { createTypeAssertion, createTypeGuard } from './utils';
export { isUnion } from './utils';
/**
* @category Type Assertion
* @throws TypeError
*/
export declare const assertIsAnyArrayBuffer: TypeAssertion<ArrayBuffer | SharedArrayBuffer, ErrorMessage>;
/**
* @category Type Assertion
* @example
*
* ```typescript
* // doesn't throw, value is typed as any[]
* assertIsArray(['xyz']);
*
* // doesn't throw, value is typed as string[]
* assertIsArray<string>(['xyz'], { valueValidator: isString });
*
* // throws
* assertIsArray<string>(['xyz', 1], { valueValidator: isString });
* ```
*
* @throws TypeError
*/
export declare function assertIsArray(input: unknown): asserts input is any[];
export declare function assertIsArray(input: unknown, options?: ErrorMessage): asserts input is any[];
export declare function assertIsArray<T>(input: unknown, options: ValueValidator): asserts input is T[];
export declare function assertIsArray<T>(input: unknown, options: ValueValidator & ErrorMessage): asserts input is T[];
/**
* @category Type Assertion
* @throws TypeError
*/
export declare const assertIsArrayBuffer: TypeAssertion<ArrayBuffer, ErrorMessage>;
/**
* @remarks
* This assertion works only in ES2018 and above
* @category Type Assertion
* @throws TypeError
*/
export declare function assertIsAsyncFunction<T = unknown>(input: unknown, options?: ErrorMessage): asserts input is AsyncFunction<T>;
/**
* @remarks
* This assertion works only in ES2018 and above
* @category Type Assertion
* @throws TypeError
*/
export declare function assertIsAsyncGenerator<Y = unknown, R = unknown, N = unknown>(input: unknown, options?: ErrorMessage): asserts input is AsyncGenerator<Y, R, N>;
/**
* @category Type Assertion
* @throws TypeError
*/
export declare function assertIsAsyncGeneratorFunction<Y = unknown, R = unknown, N = unknown>(input: unknown, options?: ErrorMessage): asserts input is TypedAsyncGeneratorFunction<Y, R, N>;
/**
* @remarks
* This guard tests for Symbol.asyncIterator. See:
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/asyncIterator}
* @category Type Assertion
* @throws TypeError
*/
export declare function assertIsAsyncIterable<T = unknown>(input: unknown, options?: ErrorMessage): asserts input is AsyncIterable<T>;
/**
* @category Type Assertion
* @example
*
* ```typescript
* // does not throw
* assertIsBigInt(BigInt(9007199254740991));
*
* // throws
* assertIsBigInt(9007199254740991n);
* ```
*
* @throws TypeError
*/
export declare const assertIsBigInt: TypeAssertion<bigint, ErrorMessage>;
/**
* @category Type Assertion
* @throws TypeError
*/
export declare const assertIsBigInt64Array: TypeAssertion<BigInt64Array, ErrorMessage>;
/**
* @category Type Assertion
* @throws TypeError
*/
export declare const assertIsBigUint64Array: TypeAssertion<BigUint64Array, ErrorMessage>;
/**
* @category Type Assertion
* @throws TypeError
*/
export declare const assertIsBoolean: TypeAssertion<boolean, ErrorMessage>;
/**
* @category Type Assertion
* @throws TypeError
*/
export declare const assertIsBooleanObject: TypeAssertion<Boolean, ErrorMessage>;
/**
* @category Type Assertion
* @throws TypeError
*/
export declare const assertIsBuffer: TypeAssertion<Buffer, ErrorMessage>;
/**
* @category Type Assertion
* @throws TypeError
*/
export declare const assertIsDataView: TypeAssertion<DataView, ErrorMessage>;
/**
* @category Type Assertion
* @throws TypeError
*/
export declare const assertIsDate: TypeAssertion<Date, ErrorMessage>;
/**
* @remarks
* This assertion asserts that the value is not null, use assertIsNotNullish to
* also exclude undefined
* @category Type Assertion
* @throws TypeError
*/
export declare function assertIsDefined<T>(input: T | undefined, options?: ErrorMessage): asserts input is T;
/**
* @category Type Assertion
* @example
*
* ```typescript
* // does not throw, value is typed as Error
* assertIsError(new Error());
*
* // does not throw, value is typed as Error
* assertIsError<TypeError>(new TypeError());
*
* // does not throw, value is typed as TypeError
* assertIsError<TypeError>(new TypeError());
*
* // does not throw, value is typed as MyError - if MyError inherits from Error or its sub-classes
* assertIsError<MyError>(new MyError());
* ```
*
* @throws TypeError
*/
export declare function assertIsError<T extends Error = Error>(input: unknown, options?: ErrorMessage): asserts input is T;
/**
* @category Type Assertion
* @throws TypeError
*/
export declare const assertIsFloat32Array: TypeAssertion<Float32Array, ErrorMessage>;
/**
* @category Type Assertion
* @throws TypeError
*/
export declare const assertIsFloat64Array: TypeAssertion<Float64Array, ErrorMessage>;
/**
* @remarks
* This guard works only in ES2018 and above
* @category Type Assertion
* @example
*
* ```typescript
* // does not throw, value is typed as Function
* assertIsFunction(() => true);
*
* // does not throw, value is typed as () => boolean
* assertIsFunction<() => boolean>(() => true);
*
* // throws
* assertIsFunction(async () => Promise.resolve(null));
*
* // throws
* assertIsFunction(function* () {});
*
* // throws
* assertIsFunction(async function* () {});
*
* // throws
* assertIsFunction(MyClass);
* ```
*
* @throws TypeError
*/
export declare function assertIsFunction<T extends Function = Function>(input: unknown, options?: ErrorMessage): asserts input is T;
/**
* @remarks
* This assertion works only in ES2018 and above
* @category Type Assertion
* @throws TypeError
*/
export declare function assertIsGenerator<Y = unknown, R = unknown, N = unknown>(input: unknown, options?: ErrorMessage): asserts input is Generator<Y, R, N>;
/**
* @remarks
* This assertion works only in ES2018 and above
* @category Type Assertion
* @throws TypeError
*/
export declare function assertIsGeneratorFunction<Y = unknown, R = unknown, N = unknown>(input: unknown, options?: ErrorMessage): asserts input is TypedGeneratorFunction<Y, R, N>;
/**
* @category Type Assertion
* @throws TypeError
*/
export declare const assertIsInt16Array: TypeAssertion<Int16Array, ErrorMessage>;
/**
* @category Type Assertion
* @throws TypeError
*/
export declare const assertIsInt32Array: TypeAssertion<Int32Array, ErrorMessage>;
/**
* @category Type Assertion
* @throws TypeError
*/
export declare const assertIsInt8Array: TypeAssertion<Int8Array, ErrorMessage>;
/**
* @remarks
* This guard tests for Symbol.iterator, which defines the Iterable protocol.
* See:
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols}
* @category Type Assertion
* @throws TypeError
*/
export declare function assertIsIterable<T = unknown>(input: unknown, options?: ErrorMessage): asserts input is Iterable<T>;
/**
* @remarks
* This assertion works only in ES2018 and above
* @category Type Assertion
* @throws TypeError
*/
export declare function assertIsIterator<Y = unknown, R = unknown, N = unknown>(input: unknown, options?: ErrorMessage): asserts input is Iterator<Y, R, N>;
/**
* @category Type Assertion
* @example
*
* ```typescript
* // does not throw, value is typed as Map<unknown, unknown>
* assertIsMap(new Map([['xyz', 'abc']]));
*
* // does not throw, value is typed as Map<string, string | number>
* assertIsMap<string, string>(
* new Map([
* ['abc', 'def'],
* ['xyz', 100],
* ]),
* {
* keyValidator: isString,
* valueValidator: isUnion(isString, isNumber),
* },
* );
* ```
*
* @throws TypeError
*/
export declare function assertIsMap(input: unknown): asserts input is Map<unknown, unknown>;
export declare function assertIsMap(input: unknown, options?: ErrorMessage): asserts input is Map<unknown, unknown>;
export declare function assertIsMap<K>(input: unknown, options: KeyValidator): asserts input is Map<K, unknown>;
export declare function assertIsMap<K>(input: unknown, options: KeyValidator & ErrorMessage): asserts input is Map<K, unknown>;
export declare function assertIsMap<V>(input: unknown, options: ValueValidator): asserts input is Map<string, V>;
export declare function assertIsMap<V>(input: unknown, options: ValueValidator & ErrorMessage): asserts input is Map<string, V>;
export declare function assertIsMap<K, V>(input: unknown, options: ValueValidator & KeyValidator): asserts input is Map<K, V>;
export declare function assertIsMap<K, V>(input: unknown, options: ValueValidator & KeyValidator & ErrorMessage): asserts input is Map<K, V>;
/**
* @remarks
* This assertion asserts that the value is not null, use assertIsNotNullish to
* also exclude undefined
* @category Type Assertion
* @throws TypeError
*/
export declare function assertIsNotNull<T>(input: T | null, options?: ErrorMessage): asserts input is T;
/**
* @remarks
* Tests false for undefined and null, true for all other values
* @category Type Assertion
* @throws TypeError
*/
export declare function assertIsNotNullish<T>(input: T | undefined | null, options?: ErrorMessage): asserts input is T;
/**
* @category Type Assertion
* @throws TypeError
*/
export declare const assertIsNull: TypeAssertion<null, ErrorMessage>;
/**
* @category Type Assertion
* @throws TypeError
*/
export declare const assertIsNullish: TypeAssertion<null | undefined, ErrorMessage>;
/**
* @category Type Assertion
* @example
*
* ```typescript
* // does not throw
* assertIsNumber(1);
*
* // throws
* assertIsNumber(new Number(1));
* ```
*
* @throws TypeError
*/
export declare const assertIsNumber: TypeAssertion<number, ErrorMessage>;
/**
* @category Type Assertion
* @example
*
* ```typescript
* // does not throw
* assertIsNumberObject(new Number(1));
*
* // throws
* assertIsNumberObject(1);
* ```
*
* @throws TypeError
*/
export declare const assertIsNumberObject: TypeAssertion<Number, ErrorMessage>;
/**
* @remarks
* Tests true for all objects that have a typeof 'object' excluding null
* @category Type Assertion
* @example
*
* ```typescript
* // does not throw, value is typed as object
* assertIsObject({});
*
* // does not throw, value is typed as object
* assertIsObject([]);
*
* // throws
* assertIsObject(null);
* ```
*
* @throws TypeError
*/
export declare const assertIsObject: TypeAssertion<object, ErrorMessage>;
/**
* @remarks
* Works with custom promises as well, e.g. AxiosPromise or BlueBird
* @category Type Assertion
* @throws TypeError
*/
export declare function assertIsPromise<T = unknown>(input: unknown, options?: ErrorMessage): asserts input is Promise<T>;
/**
* @category Type Assertion
* @example
*
* ```typescript
* // does not throw, value is typed as Record<string | symbol, any>
* assertIsRecord({ key1: 'aaa', key2: 123 });
*
* // does not throw, value is typed as Record<string, string | number>
* assertIsRecord<string, string | number>(
* { key1: 'aaa', key2: 123 },
* {
* keyValidator: isString,
* valueValidator: isUnion(isString, isNumber),
* },
* );
* ```
*
* @throws TypeError
*/
export declare function assertIsRecord(input: unknown): asserts input is Record<string | symbol, unknown>;
export declare function assertIsRecord(input: unknown, options?: ErrorMessage): asserts input is Record<string | symbol, unknown>;
export declare function assertIsRecord<K extends string | symbol>(input: unknown, options: KeyValidator): asserts input is Record<K, unknown>;
export declare function assertIsRecord<K extends string | symbol>(input: unknown, options: KeyValidator & ErrorMessage): asserts input is Record<K, unknown>;
export declare function assertIsRecord<V>(input: unknown, options: ValueValidator): asserts input is Record<string, V>;
export declare function assertIsRecord<V>(input: unknown, options: ValueValidator & ErrorMessage): asserts input is Record<string, V>;
export declare function assertIsRecord<K extends string | symbol, V>(input: unknown, options: ValueValidator & KeyValidator): asserts input is Record<K, V>;
export declare function assertIsRecord<K extends string | symbol, V>(input: unknown, options: ValueValidator & KeyValidator & ErrorMessage): asserts input is Record<K, V>;
/**
* @category Type Assertion
* @example
*
* ```typescript
* // does not throw
* assertIsRegExp(new RegExp('abc'));
*
* // does not throw
* assertIsRegExp(/'abc'/);
* ```
*
* @throws TypeError
*/
export declare const assertIsRegExp: TypeAssertion<RegExp, ErrorMessage>;
/**
* @category Type Assertion
* @example
*
* ```typescript
* // doesn't throw, value is typed as Set<any>
* assertIsSet(new Set(['xyz']));
*
* // doesn't throw, value is typed as Set<string>
* assertIsSet<string>(new Set(['xyz']), { valueValidator: isString });
* ```
*
* @throws TypeError
*/
export declare function assertIsSet(input: unknown): asserts input is Set<any>;
export declare function assertIsSet(input: unknown, options: ErrorMessage): asserts input is Set<any>;
export declare function assertIsSet<T>(input: unknown, options: ValueValidator): asserts input is Set<T>;
/**
* @category Type Assertion
* @throws TypeError
*/
export declare const assertIsSharedArrayBuffer: TypeAssertion<SharedArrayBuffer, ErrorMessage>;
/**
* @category Type Assertion
* @throws TypeError
*/
export declare const assertIsString: TypeAssertion<string, ErrorMessage>;
/**
* @category Type Assertion
* @throws TypeError
*/
export declare const assertIsStringObject: TypeAssertion<String, ErrorMessage>;
/**
* @category Type Assertion
* @throws TypeError
*/
export declare const assertIsSymbol: TypeAssertion<symbol, ErrorMessage>;
/**
* @category Type Assertion
* @throws TypeError
*/
export declare const assertIsTypedArray: TypeAssertion<TypedArray, ErrorMessage>;
/**
* @category Type Assertion
* @throws TypeError
*/
export declare const assertIsUint16Array: TypeAssertion<Uint16Array, ErrorMessage>;
/**
* @category Type Assertion
* @throws TypeError
*/
export declare const assertIsUint32Array: TypeAssertion<Uint32Array, ErrorMessage>;
/**
* @category Type Assertion
* @throws TypeError
*/
export declare const assertIsUint8Array: TypeAssertion<Uint8Array, ErrorMessage>;
/**
* @category Type Assertion
* @throws TypeError
*/
export declare const assertIsUint8ClampedArray: TypeAssertion<Uint8ClampedArray, ErrorMessage>;
/**
* @category Type Assertion
* @throws TypeError
*/
export declare const assertIsUndefined: TypeAssertion<undefined, ErrorMessage>;
/**
* @category Type Assertion
* @throws TypeError
*/
export declare function assertIsWeakMap<K extends object = any, V = unknown>(input: unknown, options?: ErrorMessage): asserts input is WeakMap<K, V>;
/**
* @category Type Assertion
* @throws TypeError
*/
export declare function assertIsWeakSet<T extends object = any>(input: unknown, options?: ErrorMessage): asserts input is WeakSet<T>;
export declare type AsyncFunction<T = unknown> = (...args: any[]) => Promise<T>;
/**
* @category Utility
* @example
*
* ```typescript
* // myTypeAssertion === (input: unknown) => asserts input is MyClass
* const myTypeAssertion = createTypeAssertion<MyClass>(guard: TypeGuard<MyClass>)
* ```
*/
export declare function createTypeAssertion<T, O extends TypeAssertionOptions | undefined = ErrorMessage>(guard: TypeGuard<T, any>): TypeAssertion<T, O>;
/**
* @category Utility
* @example
*
* ```typescript
* // myTypeGuard === (input: unknown, { throwError: boolean }) => input is MyClass
* const myTypeGuard = createTypeGuard<MyClass>(
* (value) => isObject(value) && Reflect.get(value, 'myProp'),
* MyClass.name,
* );
* ```
*/
export declare function createTypeGuard<T, O extends TypeGuardOptions | undefined = undefined>(validator: TypeValidator, options?: O): TypeGuard<T, O>;
export declare interface ErrorMessage {
message: string | undefined;
}
/** @category Type Guard */
export declare const isAnyArrayBuffer: TypeGuard<ArrayBuffer | SharedArrayBuffer>;
/**
* @category Type Guard
* @example
*
* ```typescript
* // true, typed as any[]
* isArray(['xyz']);
*
* // true, typed as string[]
* isArray<string>(['xyz'], { valueValidator: isString });
* ```
*/
export declare function isArray(input: unknown): input is any[];
export declare function isArray<T>(input: unknown, options: ValueValidator): input is T[];
/** @category Type Guard */
export declare const isArrayBuffer: TypeGuard<ArrayBuffer, undefined>;
/**
* @remarks
* This guard works only in ES2018 and above
* @category Type Guard
*/
export declare function isAsyncFunction<T = unknown>(input: unknown): input is AsyncFunction<T>;
/**
* @remarks
* This guard works only in ES2018 and above
* @category Type Guard
*/
export declare function isAsyncGenerator<Y = unknown, R = unknown, N = unknown>(input: unknown): input is AsyncGenerator<Y, R, N>;
/**
* @remarks
* This guard works only in ES2018 and above
* @category Type Guard
*/
export declare function isAsyncGeneratorFunction<Y = unknown, R = unknown, N = unknown>(input: unknown): input is TypedAsyncGeneratorFunction<Y, R, N>;
/**
* @remarks
* This guard tests for Symbol.asyncIterator. See:
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/asyncIterator}
* @category Type Guard
*/
export declare function isAsyncIterable<T = unknown>(input: unknown): input is AsyncIterable<T>;
/**
* @category Type Guard
* @example
*
* ```typescript
* // true
* isBigInt(BigInt(9007199254740991));
*
* // true
* isBigInt(9007199254740991n);
* ```
*/
export declare const isBigInt: TypeGuard<bigint, undefined>;
/** @category Type Guard */
export declare const isBigInt64Array: (input: unknown) => input is BigInt64Array;
/** @category Type Guard */
export declare const isBigUint64Array: (input: unknown) => input is BigUint64Array;
/**
* @category Type Guard
* @example
*
* ```typescript
* // true
* isBoolean(false);
*
* // false
* isBoolean(new Boolean(false));
* ```
*/
export declare const isBoolean: TypeGuard<boolean, undefined>;
/**
* @category Type Guard
* @example
*
* ```typescript
* // true
* isBooleanObject(new Boolean(true));
*
* // false
* isBooleanObject(true);
* ```
*/
export declare const isBooleanObject: TypeGuard<Boolean, undefined>;
/** @category Type Guard */
export declare const isBuffer: TypeGuard<Buffer, undefined>;
/** @category Type Guard */
export declare const isDataView: TypeGuard<DataView, undefined>;
/** @category Type Guard */
export declare const isDate: TypeGuard<Date, undefined>;
/** @category Type Guard */
export declare function isDefined<T>(input: T | undefined): input is T;
/**
* @category Type Guard
* @example
*
* ```typescript
* // true
* isError(new Error());
*
* // true, value is typed as Error
* isError(new TypeError());
*
* // true, value is typed as TypeError
* isError<TypeError>(new TypeError());
*
* // true, as long as MyCustomError inherits Error
* isError<MyCustomError>(new MyCustomError());
* ```
*/
export declare function isError<T extends Error = Error>(input: unknown): input is T;
/** @category Type Guard */
export declare const isFloat32Array: (input: unknown) => input is Float32Array;
/** @category Type Guard */
export declare const isFloat64Array: (input: unknown) => input is Float64Array;
/**
* @remarks
* This guard works only in ES2018 and above
* @category Type Guard
* @example
*
* ```typescript
* // true, value is typed as Function
* isFunction(() => null);
*
* // true, value is typed as () => null
* isFunction<() => null>(() => null);
*
* // false
* isFunction(async () => Promise.resolve(null));
*
* // false
* isFunction(function* () {});
*
* // false
* isFunction(async function* () {});
*
* // false
* isFunction(MyClass);
* ```
*/
export declare function isFunction<T extends Function = Function>(input: unknown): input is T;
/** @category Type Guard */
export declare function isGenerator<Y = unknown, R = unknown, N = unknown>(input: unknown): input is Generator<Y, R, N>;
/** @category Type Guard */
export declare function isGeneratorFunction<Y = unknown, R = unknown, N = unknown>(input: unknown): input is TypedGeneratorFunction<Y, R, N>;
/** @category Type Guard */
export declare const isInt16Array: (input: unknown) => input is Int16Array;
/** @category Type Guard */
export declare const isInt32Array: (input: unknown) => input is Int32Array;
/** @category Type Guard */
export declare const isInt8Array: (input: unknown) => input is Int8Array;
/**
* @remarks
* This guard tests for Symbol.iterator, which defines the Iterable protocol.
* See:
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols}
* @category Type Guard
*/
export declare function isIterable<T = unknown>(input: unknown): input is Iterable<T>;
/**
* @remarks
* This guard tests for the presence of a '.next' method on the object, which
* defines the Iteration protocol. See:
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols}.
*
* At present it is not possible to distinguish between Iterator and
* AsyncIterator using reflection.
* @category Type Guard
*/
export declare function isIterator<Y = unknown, R = unknown, N = unknown>(input: unknown): input is Iterator<Y, R, N>;
/**
* @category Type Guard
* @example
*
* ```typescript
* // true, value is typed as Map<unknown, unknown>
* isMap(new Map([['xyz', 'abc']]));
*
* // true, value is typed as Map<string, string | number>
* isMap<string, string>(
* new Map([
* ['abc', 'def'],
* ['xyz', 100],
* ]),
* {
* keyValidator: isString,
* valueValidator: isUnion(isString, isNumber),
* },
* );
* ```
*/
export declare function isMap(input: unknown): input is Map<any, any>;
export declare function isMap<K>(input: unknown, options: KeyValidator): input is Map<K, unknown>;
export declare function isMap<V>(input: unknown, options: ValueValidator): input is Map<unknown, V>;
export declare function isMap<K, V>(input: unknown, options: ValueValidator & KeyValidator): input is Map<K, V>;
/**
* @remarks
* This guard checks that the value is not null, use isNotNullish to also
* exclude undefined
* @category Type Guard
*/
export declare function isNotNull<T>(input: T | null): input is T;
/**
* @remarks
* Tests false for undefined and null, true for all other values
* @category Type Guard
*/
export declare function isNotNullish<T>(input: T | undefined | null): input is NonNullable<T>;
/** @category Type Guard */
export declare const isNull: TypeGuard<null, undefined>;
/**
* @remarks
* Tests true for undefined and null, false for all other falsy values
* @category Type Guard
*/
export declare const isNullish: TypeGuard<null | undefined>;
/**
* @category Type Guard
* @example
*
* ```typescript
* // true
* isNumber(1);
*
* // false
* isNumber(new Number(1));
*
* // false
* isNumber(new BigInt(9007199254740991n));
* ```
*/
export declare const isNumber: TypeGuard<number, undefined>;
/**
* @category Type Guard
* @example
*
* ```typescript
* // true
* isNumberObject(new Number(1));
*
* // false
* isNumberObject(1);
* ```
*/
export declare const isNumberObject: TypeGuard<Number, undefined>;
/**
* @remarks
* Tests true for all objects that have a typeof 'object' excluding null
* @category Type Guard
* @example
*
* ```typescript
* // true
* isObject({});
*
* // true
* isObject([]);
*
* // false
* isObject(null);
* ```
*/
export declare const isObject: TypeGuard<object, undefined>;
/**
* @remarks
* Works with custom promises as well, e.g. AxiosPromise or Bluebird
* @category Type Guard
*/
export declare function isPromise<T = unknown>(input: unknown): input is Promise<T>;
/**
* @category Type Guard
* @example
*
* ```typescript
* * // true, value is typed as Record<string | symbol, any>
* isRecord(
* { key1: 'aaa', key2: 123 },
* );
*
* // true, value is typed as Record<string, string | number>
* isRecord<string, string | number>(
* { key1: 'aaa', key2: 123 },
* {
* keyValidator: isString,
* valueValidator: isUnion(isString, isNumber),
* },
* );
* ```
*/
export declare function isRecord(input: unknown): input is Record<string | symbol, any>;
export declare function isRecord<K extends string | symbol>(input: unknown, options: KeyValidator): input is Record<K, unknown>;
export declare function isRecord<V>(input: unknown, options: ValueValidator): input is Record<string, V>;
export declare function isRecord<K extends string | symbol, V>(input: unknown, options: ValueValidator & KeyValidator): input is Record<K, V>;
/**
* @category Type Guard
* @example
*
* ```typescript
* // true
* isRegExp(new RegExp('somePattern'));
*
* // true
* isRegExp(/somePattern/);
* ```
*/
export declare const isRegExp: TypeGuard<RegExp, undefined>;
/**
* @category Type Guard
* @example
*
* ```typescript
* // true, value is typed as Set<any>
* isSet(new Set(['xyz']));
*
* // true, value is typed as Set<string>
* isSet<string>(new Set(['xyz']), { valueValidator: isString });
* ```
*/
export declare function isSet(input: unknown): input is Set<any>;
export declare function isSet<T>(input: unknown, options: ValueValidator): input is Set<T>;
/** @category Type Guard */
export declare const isSharedArrayBuffer: TypeGuard<SharedArrayBuffer, undefined>;
/**
* @category Type Guard
* @example
*
* ```typescript
* // true
* isString('xyz');
*
* // false
* isString(new String('xyz'));
* ```
*/
export declare const isString: TypeGuard<string, undefined>;
/**
* @category Type Guard
* @example
*
* ```typescript
* // true
* isStringObject(new String('xyz'));
*
* // false
* isStringObject('xyz');
* ```
*/
export declare const isStringObject: TypeGuard<String, undefined>;
/** @category Type Guard */
export declare const isSymbol: TypeGuard<symbol, undefined>;
/** @category Type Guard */
export declare const isTypedArray: TypeGuard<TypedArray, undefined>;
/** @category Type Guard */
export declare const isUint16Array: (input: unknown) => input is Uint16Array;
/** @category Type Guard */
export declare const isUint32Array: (input: unknown) => input is Uint32Array;
/** @category Type Guard */
export declare const isUint8Array: (input: unknown) => input is Uint8Array;
/** @category Type Guard */
export declare const isUint8ClampedArray: (input: unknown) => input is Uint8ClampedArray;
/** @category Type Guard */
export declare const isUndefined: TypeGuard<undefined, undefined>;
/**
* @category Utility
* @example
*
* ```typescript
* // unionTypeGuard === <T>(input: unknown, ...args: any[]) => input is T
* const unionTypeGuard = isUnion<string | number | symbol>(
* isString,
* isNumber,
* isSymbol,
* );
* ```
*/
export declare function isUnion<T>(...guards: TypeGuard<T>[]): TypeGuard<T>;
/** @category Type Guard */
export declare function isWeakMap<K extends object = any, V = unknown>(input: unknown): input is WeakMap<K, V>;
/** @category Type Guard */
export declare function isWeakSet<T extends object = any>(input: unknown): input is WeakSet<T>;
export declare interface KeyValidator {
keyValidator: TypeValidator;
}
export declare type TypeAssertion<T, O extends TypeAssertionOptions | undefined = undefined> = (input: unknown, options?: O) => asserts input is T;
export declare type TypeAssertionOptions = TypeGuardOptions & Partial<ErrorMessage>;
export declare type TypedArray = Uint8Array | Uint8ClampedArray | Uint16Array | Uint32Array | Int8Array | Int16Array | Int32Array | BigUint64Array | BigInt64Array | Float32Array | Float64Array;
export declare type TypedAsyncGeneratorFunction<Y, R, N> = (...args: any[]) => AsyncGenerator<Y, R, N>;
export declare type TypedGeneratorFunction<Y, R, N> = (...args: any[]) => Generator<Y, R, N>;
export declare type TypeGuard<T, O extends TypeGuardOptions | undefined = undefined> = (input: unknown, options?: O) => input is T;
export declare type TypeGuardOptions = Partial<ValueValidator & KeyValidator>;
export declare type TypeValidator = (input: unknown, ...args: any[]) => boolean;
export declare interface ValueValidator {
valueValidator: TypeValidator;
}
export { }

3

dist/index.js

@@ -1,2 +0,1 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const t=t=>Object.prototype.toString.call(t);function r(t,r){return r?e=>t(e,r):r=>t(r)}function e(t){return(r,e)=>{if(!t(r,e))throw new TypeError(e?.message)}}function s(...t){return function(r,...e){for(const s of t)if(s(r,...e))return!0;return!1}}const o=r((t=>"object"==typeof t&&null!==t)),n=r((r=>o(r)&&("[object ArrayBuffer]"===t(r)||r instanceof ArrayBuffer))),a=r((r=>o(r)&&("[object SharedArrayBuffer]"===t(r)||r instanceof SharedArrayBuffer))),i=s(n,a),u=e(i);function c(t,e){return r((t=>Array.isArray(t)&&(!e?.valueValidator||t.every(e.valueValidator))))(t)}const p=e(n);function f(e){return r((r=>"function"==typeof r&&"[object AsyncFunction]"===t(r)))(e)}function y(e){return r((r=>o(r)&&"[object AsyncGenerator]"===t(r)))(e)}function x(e){return r((r=>"function"==typeof r&&"[object AsyncGeneratorFunction]"===t(r)))(e)}function l(t){return r((t=>o(t)&&"function"==typeof Reflect.get(t,Symbol.asyncIterator)))(t)}const I=r((t=>"bigint"==typeof t)),b=e(I),A=r((t=>"boolean"==typeof t)),g=e(A),S=r((r=>o(r)&&("[object Boolean]"===t(r)||r instanceof Boolean))),d=e(S),j=r((t=>"undefined"!=typeof Buffer&&t instanceof Buffer)),m=e(j),B=r((r=>o(r)&&("[object DataView]"===t(r)||r instanceof DataView))),v=e(B),T=r((r=>o(r)&&("[object Date]"===t(r)||r instanceof Date))),U=e(T),F=r((t=>void 0===t));function N(e){return r((r=>o(r)&&("[object Error]"===t(r)||r instanceof Error)))(e)}function O(e){return r((r=>"function"==typeof r&&"[object Function]"===t(r)))(e)}function V(e){return r((r=>o(r)&&"[object Generator]"===t(r)))(e)}function k(e){return r((r=>"function"==typeof r&&"[object GeneratorFunction]"===t(r)))(e)}const h=r((t=>"string"==typeof t));function G(t){return r((t=>o(t)&&"function"==typeof Reflect.get(t,Symbol.iterator)||h(t)))(t)}function E(t){return r((t=>o(t)&&"function"==typeof Reflect.get(t,"next")))(t)}function D(e,s){return r((r=>(r instanceof Map||o(r)&&"[object Map]"===t(r))&&(!s?.valueValidator||[...r.values()].every(s.valueValidator))&&(!s?.keyValidator||[...r.keys()].every(s.keyValidator))))(e)}const R=r((t=>null===t));const w=e(R),M=s(R,F),W=e(M),P=r((t=>"number"==typeof t)),C=e(P),_=r((r=>o(r)&&("[object Number]"===t(r)||r instanceof Number))),q=e(_),z=e(o);function H(t){return r((t=>t instanceof Promise||o(t)&&"function"==typeof Reflect.get(t,"then")))(t)}function J(e,s){return r((r=>o(r)&&"[object Object]"===t(r)&&(!s?.valueValidator||Object.values(r).every(s.valueValidator))&&(!s?.keyValidator||Object.keys(r).every(s.keyValidator))))(e)}const K=r((r=>o(r)&&("[object RegExp]"===t(r)||r instanceof RegExp))),L=e(K);function Q(e,s){return r((r=>o(r)&&("[object Set]"===t(r)||r instanceof Set)&&(!s?.valueValidator||[...r].every(s.valueValidator))))(e)}const X=e(a),Y=e(h),Z=r((r=>o(r)&&("[object String]"===t(r)||r instanceof String))),$=e(Z),tt=r((t=>"symbol"==typeof t)),rt=e(tt),et=r((t=>t instanceof Object.getPrototypeOf(Int8Array)||t instanceof Object.getPrototypeOf(Uint8Array))),st=t=>r((t=>et(t)&&"Int8Array"===t[Symbol.toStringTag]))(t),ot=t=>r((t=>et(t)&&"Uint8Array"===t[Symbol.toStringTag]))(t),nt=t=>r((t=>et(t)&&"Uint8ClampedArray"===t[Symbol.toStringTag]))(t),at=t=>r((t=>et(t)&&"Int16Array"===t[Symbol.toStringTag]))(t),it=t=>r((t=>et(t)&&"Uint16Array"===t[Symbol.toStringTag]))(t),ut=t=>r((t=>et(t)&&"Int32Array"===t[Symbol.toStringTag]))(t),ct=t=>r((t=>et(t)&&"Uint32Array"===t[Symbol.toStringTag]))(t),pt=t=>r((t=>et(t)&&"Float32Array"===t[Symbol.toStringTag]))(t),ft=t=>r((t=>et(t)&&"Float64Array"===t[Symbol.toStringTag]))(t),yt=t=>r((t=>et(t)&&"BigInt64Array"===t[Symbol.toStringTag]))(t),xt=t=>r((t=>et(t)&&"BigUint64Array"===t[Symbol.toStringTag]))(t),lt=e(et),It=e(st),bt=e(ot),At=e(nt),gt=e(at),St=e(it),dt=e(ut),jt=e(ct),mt=e(pt),Bt=e(ft),vt=e(yt),Tt=e(xt),Ut=e(F);function Ft(e){return r((r=>r instanceof WeakMap||o(r)&&"[object WeakMap]"===t(r)))(e)}function Nt(e){return r((r=>r instanceof WeakSet||o(r)&&"[object WeakSet]"===t(r)))(e)}function Ot(t){return void 0!==t}function Vt(t){return null!==t}exports.assertIsAnyArrayBuffer=u,exports.assertIsArray=function(t,r){return e(c)(t,r)},exports.assertIsArrayBuffer=p,exports.assertIsAsyncFunction=function(t,r){return e(f)(t,r)},exports.assertIsAsyncGenerator=function(t,r){return e(y)(t,r)},exports.assertIsAsyncGeneratorFunction=function(t,r){return e(x)(t,r)},exports.assertIsAsyncIterable=function(t,r){return e(l)(t,r)},exports.assertIsBigInt=b,exports.assertIsBigInt64Array=vt,exports.assertIsBigUint64Array=Tt,exports.assertIsBoolean=g,exports.assertIsBooleanObject=d,exports.assertIsBuffer=m,exports.assertIsDataView=v,exports.assertIsDate=U,exports.assertIsDefined=function(t,r){if(F(t))throw TypeError(r?.message)},exports.assertIsError=function(t,r){return e(N)(t,r)},exports.assertIsFloat32Array=mt,exports.assertIsFloat64Array=Bt,exports.assertIsFunction=function(t,r){return e(O)(t,r)},exports.assertIsGenerator=function(t,r){return e(V)(t,r)},exports.assertIsGeneratorFunction=function(t,r){return e(k)(t,r)},exports.assertIsInt16Array=gt,exports.assertIsInt32Array=dt,exports.assertIsInt8Array=It,exports.assertIsIterable=function(t,r){return e(G)(t,r)},exports.assertIsIterator=function(t,r){return e(E)(t,r)},exports.assertIsMap=function(t,r){return e(D)(t,r)},exports.assertIsNotNull=function(t,r){if(R(t))throw TypeError(r?.message)},exports.assertIsNotNullish=function(t,r){if(F(t)||R(t))throw TypeError(r?.message)},exports.assertIsNull=w,exports.assertIsNullish=W,exports.assertIsNumber=C,exports.assertIsNumberObject=q,exports.assertIsObject=z,exports.assertIsPromise=function(t,r){return e(H)(t,r)},exports.assertIsRecord=function(t,r){return e(J)(t,r)},exports.assertIsRegExp=L,exports.assertIsSet=function(t,r){return e(Q)(t,r)},exports.assertIsSharedArrayBuffer=X,exports.assertIsString=Y,exports.assertIsStringObject=$,exports.assertIsSymbol=rt,exports.assertIsTypedArray=lt,exports.assertIsUint16Array=St,exports.assertIsUint32Array=jt,exports.assertIsUint8Array=bt,exports.assertIsUint8ClampedArray=At,exports.assertIsUndefined=Ut,exports.assertIsWeakMap=function(t,r){return e(Ft)(t,r)},exports.assertIsWeakSet=function(t,r){return e(Nt)(t,r)},exports.createTypeAssertion=e,exports.createTypeGuard=r,exports.isAnyArrayBuffer=i,exports.isArray=c,exports.isArrayBuffer=n,exports.isAsyncFunction=f,exports.isAsyncGenerator=y,exports.isAsyncGeneratorFunction=x,exports.isAsyncIterable=l,exports.isBigInt=I,exports.isBigInt64Array=yt,exports.isBigUint64Array=xt,exports.isBoolean=A,exports.isBooleanObject=S,exports.isBuffer=j,exports.isDataView=B,exports.isDate=T,exports.isDefined=Ot,exports.isError=N,exports.isFloat32Array=pt,exports.isFloat64Array=ft,exports.isFunction=O,exports.isGenerator=V,exports.isGeneratorFunction=k,exports.isInt16Array=at,exports.isInt32Array=ut,exports.isInt8Array=st,exports.isIterable=G,exports.isIterator=E,exports.isMap=D,exports.isNotNull=Vt,exports.isNotNullish=function(t){return Ot(t)&&Vt(t)},exports.isNull=R,exports.isNullish=M,exports.isNumber=P,exports.isNumberObject=_,exports.isObject=o,exports.isPromise=H,exports.isRecord=J,exports.isRegExp=K,exports.isSet=Q,exports.isSharedArrayBuffer=a,exports.isString=h,exports.isStringObject=Z,exports.isSymbol=tt,exports.isTypedArray=et,exports.isUint16Array=it,exports.isUint32Array=ct,exports.isUint8Array=ot,exports.isUint8ClampedArray=nt,exports.isUndefined=F,exports.isUnion=s,exports.isWeakMap=Ft,exports.isWeakSet=Nt;
//# sourceMappingURL=index.js.map
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=r=>Object.prototype.toString.call(r);function e(r,t){return t?n=>r(n,t):n=>r(n)}function s(r){return(t,n)=>{if(!r(t,n))throw new TypeError(n==null?void 0:n.message)}}function f(...r){return function(t,...n){for(const er of r)if(er(t,...n))return!0;return!1}}const a=e(r=>typeof r=="object"&&r!==null),I=e(r=>a(r)&&(i(r)==="[object ArrayBuffer]"||r instanceof ArrayBuffer)),A=e(r=>a(r)&&(i(r)==="[object SharedArrayBuffer]"||r instanceof SharedArrayBuffer)),b=f(I,A),nr=s(b);function g(r,t){return e(n=>Array.isArray(n)&&(!(t!=null&&t.valueValidator)||n.every(t.valueValidator)))(r)}function ar(r,t){s(g)(r,t)}const ir=s(I);function l(r){return e(t=>typeof t=="function"&&i(t)==="[object AsyncFunction]")(r)}function or(r,t){s(l)(r,t)}function S(r){return e(t=>a(t)&&i(t)==="[object AsyncGenerator]")(r)}function cr(r,t){s(S)(r,t)}function d(r){return e(t=>typeof t=="function"&&i(t)==="[object AsyncGeneratorFunction]")(r)}function yr(r,t){s(d)(r,t)}function B(r){return e(t=>a(t)&&typeof Reflect.get(t,Symbol.asyncIterator)=="function")(r)}function fr(r,t){s(B)(r,t)}const j=e(r=>typeof r=="bigint"),Ir=s(j),m=e(r=>typeof r=="boolean"),Ar=s(m),N=e(r=>a(r)&&(i(r)==="[object Boolean]"||r instanceof Boolean)),ur=s(N),U=e(r=>typeof Buffer<"u"&&r instanceof Buffer),br=s(U),F=e(r=>a(r)&&(i(r)==="[object DataView]"||r instanceof DataView)),gr=s(F),O=e(r=>a(r)&&(i(r)==="[object Date]"||r instanceof Date)),lr=s(O),c=e(r=>r===void 0);function Sr(r,t){if(c(r))throw new TypeError(t==null?void 0:t.message)}function T(r){return e(t=>a(t)&&(i(t)==="[object Error]"||t instanceof Error))(r)}function dr(r,t){s(T)(r,t)}function G(r){return e(t=>typeof t=="function"&&i(t)==="[object Function]")(r)}function Br(r,t){s(G)(r,t)}function h(r){return e(t=>a(t)&&i(t)==="[object Generator]")(r)}function jr(r,t){s(h)(r,t)}function k(r){return e(t=>typeof t=="function"&&i(t)==="[object GeneratorFunction]")(r)}function mr(r,t){s(k)(r,t)}const u=e(r=>typeof r=="string");function V(r){return e(t=>a(t)&&typeof Reflect.get(t,Symbol.iterator)=="function"||u(t))(r)}function Nr(r,t){s(V)(r,t)}function D(r){return e(t=>a(t)&&typeof Reflect.get(t,"next")=="function")(r)}function Ur(r,t){s(D)(r,t)}function E(r,t){return e(n=>(n instanceof Map||a(n)&&i(n)==="[object Map]")&&(!(t!=null&&t.valueValidator)||[...n.values()].every(t.valueValidator))&&(!(t!=null&&t.keyValidator)||[...n.keys()].every(t.keyValidator)))(r)}function Fr(r,t){s(E)(r,t)}const y=e(r=>r===null);function Or(r,t){if(y(r))throw new TypeError(t==null?void 0:t.message)}function Tr(r,t){if(c(r)||y(r))throw new TypeError(t==null?void 0:t.message)}const Gr=s(y),w=f(y,c),hr=s(w),R=e(r=>typeof r=="number"),kr=s(R),M=e(r=>a(r)&&(i(r)==="[object Number]"||r instanceof Number)),Vr=s(M),Dr=s(a);function W(r){return e(t=>t instanceof Promise||a(t)&&typeof Reflect.get(t,"then")=="function")(r)}function Er(r,t){s(W)(r,t)}function P(r,t){return e(n=>a(n)&&i(n)==="[object Object]"&&(!(t!=null&&t.valueValidator)||Object.values(n).every(t.valueValidator))&&(!(t!=null&&t.keyValidator)||Object.keys(n).every(t.keyValidator)))(r)}function wr(r,t){s(P)(r,t)}const x=e(r=>a(r)&&(i(r)==="[object RegExp]"||r instanceof RegExp)),Rr=s(x);function C(r,t){return e(n=>a(n)&&(i(n)==="[object Set]"||n instanceof Set)&&(!(t!=null&&t.valueValidator)||[...n].every(t.valueValidator)))(r)}function Mr(r,t){s(C)(r,t)}const Wr=s(A),Pr=s(u),p=e(r=>a(r)&&(i(r)==="[object String]"||r instanceof String)),xr=s(p),q=e(r=>typeof r=="symbol"),Cr=s(q),o=e(r=>r instanceof Object.getPrototypeOf(Int8Array)||r instanceof Object.getPrototypeOf(Uint8Array)),z=r=>e(t=>o(t)&&t[Symbol.toStringTag]==="Int8Array")(r),H=r=>e(t=>o(t)&&t[Symbol.toStringTag]==="Uint8Array")(r),J=r=>e(t=>o(t)&&t[Symbol.toStringTag]==="Uint8ClampedArray")(r),K=r=>e(t=>o(t)&&t[Symbol.toStringTag]==="Int16Array")(r),L=r=>e(t=>o(t)&&t[Symbol.toStringTag]==="Uint16Array")(r),Q=r=>e(t=>o(t)&&t[Symbol.toStringTag]==="Int32Array")(r),X=r=>e(t=>o(t)&&t[Symbol.toStringTag]==="Uint32Array")(r),Y=r=>e(t=>o(t)&&t[Symbol.toStringTag]==="Float32Array")(r),Z=r=>e(t=>o(t)&&t[Symbol.toStringTag]==="Float64Array")(r),_=r=>e(t=>o(t)&&t[Symbol.toStringTag]==="BigInt64Array")(r),$=r=>e(t=>o(t)&&t[Symbol.toStringTag]==="BigUint64Array")(r),pr=s(o),qr=s(z),zr=s(H),Hr=s(J),Jr=s(K),Kr=s(L),Lr=s(Q),Qr=s(X),Xr=s(Y),Yr=s(Z),Zr=s(_),_r=s($),$r=s(c);function v(r){return e(t=>t instanceof WeakMap||a(t)&&i(t)==="[object WeakMap]")(r)}function vr(r,t){s(v)(r,t)}function rr(r){return e(t=>t instanceof WeakSet||a(t)&&i(t)==="[object WeakSet]")(r)}function rt(r,t){s(rr)(r,t)}function tr(r){return r!==void 0}function sr(r){return r!==null}function tt(r){return tr(r)&&sr(r)}exports.assertIsAnyArrayBuffer=nr;exports.assertIsArray=ar;exports.assertIsArrayBuffer=ir;exports.assertIsAsyncFunction=or;exports.assertIsAsyncGenerator=cr;exports.assertIsAsyncGeneratorFunction=yr;exports.assertIsAsyncIterable=fr;exports.assertIsBigInt=Ir;exports.assertIsBigInt64Array=Zr;exports.assertIsBigUint64Array=_r;exports.assertIsBoolean=Ar;exports.assertIsBooleanObject=ur;exports.assertIsBuffer=br;exports.assertIsDataView=gr;exports.assertIsDate=lr;exports.assertIsDefined=Sr;exports.assertIsError=dr;exports.assertIsFloat32Array=Xr;exports.assertIsFloat64Array=Yr;exports.assertIsFunction=Br;exports.assertIsGenerator=jr;exports.assertIsGeneratorFunction=mr;exports.assertIsInt16Array=Jr;exports.assertIsInt32Array=Lr;exports.assertIsInt8Array=qr;exports.assertIsIterable=Nr;exports.assertIsIterator=Ur;exports.assertIsMap=Fr;exports.assertIsNotNull=Or;exports.assertIsNotNullish=Tr;exports.assertIsNull=Gr;exports.assertIsNullish=hr;exports.assertIsNumber=kr;exports.assertIsNumberObject=Vr;exports.assertIsObject=Dr;exports.assertIsPromise=Er;exports.assertIsRecord=wr;exports.assertIsRegExp=Rr;exports.assertIsSet=Mr;exports.assertIsSharedArrayBuffer=Wr;exports.assertIsString=Pr;exports.assertIsStringObject=xr;exports.assertIsSymbol=Cr;exports.assertIsTypedArray=pr;exports.assertIsUint16Array=Kr;exports.assertIsUint32Array=Qr;exports.assertIsUint8Array=zr;exports.assertIsUint8ClampedArray=Hr;exports.assertIsUndefined=$r;exports.assertIsWeakMap=vr;exports.assertIsWeakSet=rt;exports.createTypeAssertion=s;exports.createTypeGuard=e;exports.isAnyArrayBuffer=b;exports.isArray=g;exports.isArrayBuffer=I;exports.isAsyncFunction=l;exports.isAsyncGenerator=S;exports.isAsyncGeneratorFunction=d;exports.isAsyncIterable=B;exports.isBigInt=j;exports.isBigInt64Array=_;exports.isBigUint64Array=$;exports.isBoolean=m;exports.isBooleanObject=N;exports.isBuffer=U;exports.isDataView=F;exports.isDate=O;exports.isDefined=tr;exports.isError=T;exports.isFloat32Array=Y;exports.isFloat64Array=Z;exports.isFunction=G;exports.isGenerator=h;exports.isGeneratorFunction=k;exports.isInt16Array=K;exports.isInt32Array=Q;exports.isInt8Array=z;exports.isIterable=V;exports.isIterator=D;exports.isMap=E;exports.isNotNull=sr;exports.isNotNullish=tt;exports.isNull=y;exports.isNullish=w;exports.isNumber=R;exports.isNumberObject=M;exports.isObject=a;exports.isPromise=W;exports.isRecord=P;exports.isRegExp=x;exports.isSet=C;exports.isSharedArrayBuffer=A;exports.isString=u;exports.isStringObject=p;exports.isSymbol=q;exports.isTypedArray=o;exports.isUint16Array=L;exports.isUint32Array=X;exports.isUint8Array=H;exports.isUint8ClampedArray=J;exports.isUndefined=c;exports.isUnion=f;exports.isWeakMap=v;exports.isWeakSet=rr;
{
"name": "@tool-belt/type-predicates",
"version": "1.2.2",
"version": "1.3.0",
"description": "Collection of performant type-guard utilities",

@@ -30,6 +30,7 @@ "repository": {

"main": "dist/index.js",
"module": "dist/index.es.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"scripts": {
"build": "rimraf dist && rollup --config rollup.config.ts --configPlugin @rollup/plugin-typescript",
"prepublish": "pnpm run build",
"build": "rimraf dist && vite build",
"docs": "rimraf dist && typedoc",

@@ -41,27 +42,25 @@ "contributors:add": "all-contributors add",

"prepare": "husky install",
"test": "jest",
"test:coverage": "jest --coverage",
"test:watch": "jest --watch"
"test": "vitest run",
"test:coverage": "vitest run --coverage",
"test:watch": "vitest"
},
"devDependencies": {
"@rollup/plugin-typescript": "^8.3.3",
"@tool-belt/eslint-config": "^1.2.3",
"@types/jest": "^28.1.6",
"all-contributors-cli": "^6.20.0",
"eslint": "^8.20.0",
"eslint-plugin-tsdoc": "^0.2.16",
"expect-type": "^0.13.0",
"husky": ">=8",
"jest": "^28.1.3",
"lint-staged": ">=13",
"prettier": "^2.7.1",
"prettier-plugin-jsdoc": "^0.3.38",
"rimraf": "^3.0.2",
"rollup": "2.77.0",
"rollup-plugin-terser": "^7.0.2",
"ts-jest": "^28.0.7",
"@tool-belt/eslint-config": "^3.0.5",
"@types/node": "^20.6.1",
"@vitest/coverage-v8": "^0.34.4",
"eslint": "^8.49.0",
"eslint-plugin-tsdoc": "^0.2.17",
"expect-type": "^0.16.0",
"husky": "^8.0.3",
"lint-staged": "^14.0.1",
"prettier": "^3.0.3",
"prettier-plugin-jsdoc": "^1.0.2",
"rimraf": "^5.0.1",
"ts-node": "^10.9.1",
"type-fest": "^2.16.0",
"typedoc": "^0.23.8",
"typescript": "4.7.4"
"type-fest": "^4.3.1",
"typedoc": "^0.25.1",
"typescript": "5.2.2",
"vite": "^4.4.9",
"vite-plugin-dts": "^3.5.3",
"vitest": "^0.34.4"
},

@@ -68,0 +67,0 @@ "lint-staged": {

@@ -16,8 +16,2 @@ ![Tests](https://github.com/tool-belt/type-predicates/actions/workflows/main.yaml/badge.svg)

Or
```bash
yarn add @tool-belt/type-predicates
```
## Contents

@@ -27,8 +21,8 @@

- a comprehensive collection of performant and flexible type-guards, that can function as a drop-in replacement for
the type-guards included in the NodeJS builtin `utils/types` module - with better significantly typing.
- a comprehensive collection of type assertions covering all type-guards included in the package.
- `isUnion`, `createTypeGuard` and `createTypeAssertion` utilities for the composition of type-guards and assertions.
- supports ES modules and tree shaking, i.e., works great with module bundlers such as Webpack for the browser.
- a comprehensive collection of performant and flexible type-guards, that can function as a drop-in replacement for
the type-guards included in the NodeJS builtin `utils/types` module - with better significantly typing.
- a comprehensive collection of type assertions covering all type-guards included in the package.
- `isUnion`, `createTypeGuard` and `createTypeAssertion` utilities for the composition of type-guards and assertions.
- supports ES modules and tree shaking, i.e., works great with module bundlers such as Webpack for the browser.
See the [docs](https://tool-belt.github.io/type-predicates/) for details.
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