@tool-belt/type-predicates
Version:
A comprehensive collection of performant type guards and assertions with excellent TypeScript support
1 lines • 89.4 kB
Source Map (JSON)
{"version":3,"file":"index.mjs","sources":["../src/utils.ts","../src/guards/isObject.ts","../src/guards/isArrayBuffer.ts","../src/guards/isSharedArrayBuffer.ts","../src/guards/isAnyArrayBuffer.ts","../src/assertions/assertIsAnyArrayBuffer.ts","../src/guards/isArgumentsObject.ts","../src/assertions/assertIsArgumentsObject.ts","../src/assertions/assertIsArray.ts","../src/assertions/assertIsArrayBuffer.ts","../src/guards/isTypedArray.ts","../src/guards/isDataView.ts","../src/guards/isArrayBufferView.ts","../src/assertions/assertIsArrayBufferView.ts","../src/guards/isAsyncFunction.ts","../src/assertions/assertIsAsyncFunction.ts","../src/guards/isAsyncGenerator.ts","../src/assertions/assertIsAsyncGenerator.ts","../src/guards/isAsyncGeneratorFunction.ts","../src/assertions/assertIsAsyncGeneratorFunction.ts","../src/guards/isAsyncIterable.ts","../src/assertions/assertIsAsyncIterable.ts","../src/guards/isBigInt.ts","../src/assertions/assertIsBigInt.ts","../src/guards/isBigIntObject.ts","../src/assertions/assertIsBigIntObject.ts","../src/guards/isBoolean.ts","../src/assertions/assertIsBoolean.ts","../src/guards/isBooleanObject.ts","../src/assertions/assertIsBooleanObject.ts","../src/guards/isNumberObject.ts","../src/guards/isStringObject.ts","../src/guards/isSymbolObject.ts","../src/guards/isBoxedPrimitive.ts","../src/assertions/assertIsBoxedPrimitive.ts","../src/guards/isBuffer.ts","../src/assertions/assertIsBuffer.ts","../src/assertions/assertIsDataView.ts","../src/guards/isDate.ts","../src/assertions/assertIsDate.ts","../src/guards/isUndefined.ts","../src/assertions/assertIsDefined.ts","../src/guards/isArray.ts","../src/guards/isEmptyArray.ts","../src/assertions/assertIsEmptyArray.ts","../src/guards/isEmptyObject.ts","../src/assertions/assertIsEmptyObject.ts","../src/guards/isString.ts","../src/guards/isEmptyString.ts","../src/assertions/assertIsEmptyString.ts","../src/guards/isError.ts","../src/assertions/assertIsError.ts","../src/guards/isFinite.ts","../src/assertions/assertIsFinite.ts","../src/guards/isFunction.ts","../src/assertions/assertIsFunction.ts","../src/guards/isGenerator.ts","../src/assertions/assertIsGenerator.ts","../src/guards/isGeneratorFunction.ts","../src/assertions/assertIsGeneratorFunction.ts","../src/guards/isInteger.ts","../src/assertions/assertIsInteger.ts","../src/guards/isIterable.ts","../src/assertions/assertIsIterable.ts","../src/guards/isIterator.ts","../src/assertions/assertIsIterator.ts","../src/guards/isMap.ts","../src/assertions/assertIsMap.ts","../src/guards/isMapIterator.ts","../src/assertions/assertIsMapIterator.ts","../src/guards/isNaN.ts","../src/assertions/assertIsNaN.ts","../src/guards/isNativeError.ts","../src/assertions/assertIsNativeError.ts","../src/guards/isNonEmptyArray.ts","../src/assertions/assertIsNonEmptyArray.ts","../src/guards/isNonEmptyString.ts","../src/assertions/assertIsNonEmptyString.ts","../src/guards/isNull.ts","../src/assertions/assertIsNotNull.ts","../src/assertions/assertIsNotNullish.ts","../src/assertions/assertIsNull.ts","../src/guards/isNullish.ts","../src/assertions/assertIsNullish.ts","../src/guards/isNumber.ts","../src/assertions/assertIsNumber.ts","../src/assertions/assertIsNumberObject.ts","../src/assertions/assertIsObject.ts","../src/guards/isPlainObject.ts","../src/assertions/assertIsPlainObject.ts","../src/guards/isPromise.ts","../src/assertions/assertIsPromise.ts","../src/guards/isRecord.ts","../src/assertions/assertIsRecord.ts","../src/guards/isRegExp.ts","../src/assertions/assertIsRegExp.ts","../src/guards/isSafeInteger.ts","../src/assertions/assertIsSafeInteger.ts","../src/guards/isSet.ts","../src/assertions/assertIsSet.ts","../src/guards/isSetIterator.ts","../src/assertions/assertIsSetIterator.ts","../src/assertions/assertIsSharedArrayBuffer.ts","../src/assertions/assertIsString.ts","../src/assertions/assertIsStringObject.ts","../src/guards/isSymbol.ts","../src/assertions/assertIsSymbol.ts","../src/assertions/assertIsSymbolObject.ts","../src/assertions/assertIsTypedArray.ts","../src/assertions/assertIsUndefined.ts","../src/guards/isWeakMap.ts","../src/assertions/assertIsWeakMap.ts","../src/guards/isWeakSet.ts","../src/assertions/assertIsWeakSet.ts","../src/guards/isDefined.ts","../src/guards/isNotNull.ts","../src/guards/isNotNullish.ts"],"sourcesContent":["import { TypeGuard, TypeGuardOptions, TypeValidator } from './types';\n\nexport const toObjectString = (value: unknown): string =>\n Object.prototype.toString.call(value);\n\n/**\n * @category Utility\n * @example\n *\n * ```typescript\n * // myTypeGuard === (input: unknown, { throwError: boolean }) => input is MyClass\n * const myTypeGuard = createTypeGuard<MyClass>(\n * (value) => isObject(value) && Reflect.get(value, 'myProp'),\n * MyClass.name,\n * );\n * ```\n */\nexport function createTypeGuard<\n T,\n O extends TypeGuardOptions | undefined = undefined,\n>(validator: TypeValidator, options?: O): TypeGuard<T, O> {\n return options\n ? (input: unknown): input is T => validator(input, options)\n : (input: unknown): input is T => validator(input);\n}\n\n/**\n * @category Utility\n * @example\n *\n * ```typescript\n * // unionTypeGuard === <T>(input: unknown, ...args: unknown[]) => input is T\n * const unionTypeGuard = isUnion<string | number | symbol>(\n * isString,\n * isNumber,\n * isSymbol,\n * );\n * ```\n */\nexport function isUnion<T>(...guards: TypeGuard<T>[]): TypeGuard<T> {\n return function (input: unknown): input is T {\n for (const guard of guards) {\n if (guard(input)) {\n return true;\n }\n }\n return false;\n };\n}\n","import { createTypeGuard } from '../utils';\n\n/**\n * @remarks\n * Tests true for all objects that have a typeof 'object' excluding null\n * @category Type Guard\n * @example\n *\n * ```typescript\n * // true\n * isObject({});\n *\n * // true\n * isObject([]);\n *\n * // false\n * isObject(null);\n * ```\n */\nexport const isObject = createTypeGuard<object>(\n (value) => typeof value === 'object' && value !== null,\n);\n","import { createTypeGuard, toObjectString } from '../utils';\nimport { isObject } from './isObject';\n\n/** @category Type Guard */\nexport const isArrayBuffer = createTypeGuard<ArrayBuffer>(\n (value) =>\n isObject(value) &&\n (toObjectString(value) === '[object ArrayBuffer]' ||\n value instanceof ArrayBuffer),\n);\n","import { createTypeGuard, toObjectString } from '../utils';\nimport { isObject } from './isObject';\n\n/** @category Type Guard */\nexport const isSharedArrayBuffer = createTypeGuard<SharedArrayBuffer>(\n (value) =>\n isObject(value) &&\n (toObjectString(value) === '[object SharedArrayBuffer]' ||\n value instanceof SharedArrayBuffer),\n);\n","import { isUnion } from '../utils';\nimport { isArrayBuffer } from './isArrayBuffer';\nimport { isSharedArrayBuffer } from './isSharedArrayBuffer';\n\n/** @category Type Guard */\nexport const isAnyArrayBuffer = isUnion<ArrayBuffer | SharedArrayBuffer>(\n isArrayBuffer,\n isSharedArrayBuffer,\n);\n","import type { ErrorMessage } from '../types';\nimport { isAnyArrayBuffer } from '../guards/isAnyArrayBuffer';\n\n/**\n * @category Type Assertion\n * @throws TypeError\n */\nexport function assertIsAnyArrayBuffer(\n input: unknown,\n options?: ErrorMessage,\n): asserts input is ArrayBuffer | SharedArrayBuffer {\n if (!isAnyArrayBuffer(input)) {\n throw new TypeError(options?.message);\n }\n}\n","import { createTypeGuard } from '../utils';\n\n/** @category Type Guard */\nexport const isArgumentsObject = createTypeGuard<IArguments>(\n (value) =>\n typeof value === 'object' &&\n value !== null &&\n Object.prototype.toString.call(value) === '[object Arguments]',\n);\n","import type { ErrorMessage } from '../types';\nimport { isArgumentsObject } from '../guards/isArgumentsObject';\n\n/**\n * @category Type Assertion\n * @throws TypeError\n */\nexport function assertIsArgumentsObject(\n input: unknown,\n options?: ErrorMessage,\n): asserts input is IArguments {\n if (!isArgumentsObject(input)) {\n throw new TypeError(options?.message);\n }\n}\n","import { ErrorMessage, ValueValidator } from '../types';\n\n/**\n * @category Type Assertion\n * @example\n *\n * ```typescript\n * // doesn't throw, value is typed as unknown[]\n * assertIsArray(['xyz']);\n *\n * // doesn't throw, value is typed as string[]\n * assertIsArray<string>(['xyz'], { valueValidator: isString });\n *\n * // throws\n * assertIsArray<string>(['xyz', 1], { valueValidator: isString });\n * ```\n *\n * @throws TypeError\n */\nexport function assertIsArray(\n input: unknown,\n options?: ErrorMessage,\n): asserts input is unknown[];\n\nexport function assertIsArray<T>(\n input: unknown,\n options: (ErrorMessage & ValueValidator) | ValueValidator,\n): asserts input is T[];\n\nexport function assertIsArray<T>(\n input: unknown,\n options?: Partial<ErrorMessage & ValueValidator>,\n): asserts input is T[] {\n if (!Array.isArray(input)) {\n throw new TypeError(options?.message);\n }\n\n if (options?.valueValidator && !input.every(options.valueValidator)) {\n throw new TypeError(options.message);\n }\n}\n","import type { ErrorMessage } from '../types';\nimport { isArrayBuffer } from '../guards/isArrayBuffer';\n\n/**\n * @category Type Assertion\n * @throws TypeError\n */\nexport function assertIsArrayBuffer(\n input: unknown,\n options?: ErrorMessage,\n): asserts input is ArrayBuffer {\n if (!isArrayBuffer(input)) {\n throw new TypeError(options?.message);\n }\n}\n","import { TypedArray } from '../types';\nimport { createTypeGuard } from '../utils';\n\n/** @category Type Guard */\nexport const isTypedArray = createTypeGuard<TypedArray>(\n (value) =>\n value instanceof Object.getPrototypeOf(Int8Array) ||\n value instanceof Object.getPrototypeOf(Uint8Array),\n);\n\n/** @category Type Guard */\nexport const isInt8Array = (input: unknown): input is Int8Array =>\n createTypeGuard<Int8Array>(\n (value) =>\n isTypedArray(value) && value[Symbol.toStringTag] === 'Int8Array',\n )(input);\n\n/** @category Type Guard */\nexport const isUint8Array = (input: unknown): input is Uint8Array =>\n createTypeGuard<Uint8Array>(\n (value) =>\n isTypedArray(value) && value[Symbol.toStringTag] === 'Uint8Array',\n )(input);\n\n/** @category Type Guard */\nexport const isUint8ClampedArray = (\n input: unknown,\n): input is Uint8ClampedArray =>\n createTypeGuard<Uint8ClampedArray>(\n (value) =>\n isTypedArray(value) &&\n value[Symbol.toStringTag] === 'Uint8ClampedArray',\n )(input);\n\n/** @category Type Guard */\nexport const isInt16Array = (input: unknown): input is Int16Array =>\n createTypeGuard<Int16Array>(\n (value) =>\n isTypedArray(value) && value[Symbol.toStringTag] === 'Int16Array',\n )(input);\n\n/** @category Type Guard */\nexport const isUint16Array = (input: unknown): input is Uint16Array =>\n createTypeGuard<Uint16Array>(\n (value) =>\n isTypedArray(value) && value[Symbol.toStringTag] === 'Uint16Array',\n )(input);\n\n/** @category Type Guard */\nexport const isInt32Array = (input: unknown): input is Int32Array =>\n createTypeGuard<Int32Array>(\n (value) =>\n isTypedArray(value) && value[Symbol.toStringTag] === 'Int32Array',\n )(input);\n\n/** @category Type Guard */\nexport const isUint32Array = (input: unknown): input is Uint32Array =>\n createTypeGuard<Uint32Array>(\n (value) =>\n isTypedArray(value) && value[Symbol.toStringTag] === 'Uint32Array',\n )(input);\n\n/** @category Type Guard */\nexport const isFloat32Array = (input: unknown): input is Float32Array =>\n createTypeGuard<Float32Array>(\n (value) =>\n isTypedArray(value) && value[Symbol.toStringTag] === 'Float32Array',\n )(input);\n\n/** @category Type Guard */\nexport const isFloat64Array = (input: unknown): input is Float64Array =>\n createTypeGuard<Float64Array>(\n (value) =>\n isTypedArray(value) && value[Symbol.toStringTag] === 'Float64Array',\n )(input);\n\n/** @category Type Guard */\nexport const isBigInt64Array = (input: unknown): input is BigInt64Array =>\n createTypeGuard<BigInt64Array>(\n (value) =>\n isTypedArray(value) &&\n value[Symbol.toStringTag] === 'BigInt64Array',\n )(input);\n\n/** @category Type Guard */\nexport const isBigUint64Array = (input: unknown): input is BigUint64Array =>\n createTypeGuard<BigUint64Array>(\n (value) =>\n isTypedArray(value) &&\n value[Symbol.toStringTag] === 'BigUint64Array',\n )(input);\n","import { createTypeGuard, toObjectString } from '../utils';\nimport { isObject } from './isObject';\n\n/** @category Type Guard */\nexport const isDataView = createTypeGuard<DataView>(\n (value) =>\n isObject(value) &&\n (toObjectString(value) === '[object DataView]' ||\n value instanceof DataView),\n);\n","import { isTypedArray } from './isTypedArray';\nimport { isDataView } from './isDataView';\nimport { createTypeGuard } from '../utils';\n\n/** @category Type Guard */\nexport const isArrayBufferView = createTypeGuard<ArrayBufferView>(\n (value) => isTypedArray(value) || isDataView(value),\n);\n","import type { ErrorMessage } from '../types';\nimport { isArrayBufferView } from '../guards/isArrayBufferView';\n\n/**\n * @category Type Assertion\n * @throws TypeError\n */\nexport function assertIsArrayBufferView(\n input: unknown,\n options?: ErrorMessage,\n): asserts input is ArrayBufferView {\n if (!isArrayBufferView(input)) {\n throw new TypeError(options?.message);\n }\n}\n","import { createTypeGuard, toObjectString } from '../utils';\n\nexport type AsyncFunction<T = unknown> = (...args: unknown[]) => Promise<T>;\n\n/**\n * @remarks\n * This guard works only in ES2018 and above\n * @category Type Guard\n */\nexport function isAsyncFunction<T = unknown>(\n input: unknown,\n): input is AsyncFunction<T> {\n return createTypeGuard<AsyncFunction<T>>(\n (value) =>\n typeof value === 'function' &&\n toObjectString(value) === '[object AsyncFunction]',\n )(input);\n}\n","import { AsyncFunction, isAsyncFunction } from '../guards/isAsyncFunction';\nimport { ErrorMessage } from '../types';\n\n/**\n * @remarks\n * This assertion works only in ES2018 and above\n * @category Type Assertion\n * @throws TypeError\n */\nexport function assertIsAsyncFunction<T = unknown>(\n input: unknown,\n options?: ErrorMessage,\n): asserts input is AsyncFunction<T> {\n if (!isAsyncFunction(input)) {\n throw new TypeError(options?.message);\n }\n}\n","import { createTypeGuard, toObjectString } from '../utils';\nimport { isObject } from './isObject';\n\n/**\n * @remarks\n * This guard works only in ES2018 and above\n * @category Type Guard\n */\nexport function isAsyncGenerator<Y = unknown, R = unknown, N = unknown>(\n input: unknown,\n): input is AsyncGenerator<Y, R, N> {\n return createTypeGuard<AsyncGenerator<Y, R, N>>(\n (value) =>\n isObject(value) &&\n toObjectString(value) === '[object AsyncGenerator]',\n )(input);\n}\n","import { isAsyncGenerator } from '../guards/isAsyncGenerator';\nimport { ErrorMessage } from '../types';\n\n/**\n * @remarks\n * This assertion works only in ES2018 and above\n * @category Type Assertion\n * @throws TypeError\n */\nexport function assertIsAsyncGenerator<Y = unknown, R = unknown, N = unknown>(\n input: unknown,\n options?: ErrorMessage,\n): asserts input is AsyncGenerator<Y, R, N> {\n if (!isAsyncGenerator(input)) {\n throw new TypeError(options?.message);\n }\n}\n","import { createTypeGuard, toObjectString } from '../utils';\n\nexport type TypedAsyncGeneratorFunction<Y, R, N> = (\n ...args: unknown[]\n) => AsyncGenerator<Y, R, N>;\n\n/**\n * @remarks\n * This guard works only in ES2018 and above\n * @category Type Guard\n */\nexport function isAsyncGeneratorFunction<Y = unknown, R = unknown, N = unknown>(\n input: unknown,\n): input is TypedAsyncGeneratorFunction<Y, R, N> {\n return createTypeGuard<TypedAsyncGeneratorFunction<Y, R, N>>(\n (value) =>\n typeof value === 'function' &&\n toObjectString(value) === '[object AsyncGeneratorFunction]',\n )(input);\n}\n","import {\n isAsyncGeneratorFunction,\n TypedAsyncGeneratorFunction,\n} from '../guards/isAsyncGeneratorFunction';\nimport { ErrorMessage } from '../types';\n\n/**\n * @category Type Assertion\n * @throws TypeError\n */\nexport function assertIsAsyncGeneratorFunction<\n Y = unknown,\n R = unknown,\n N = unknown,\n>(\n input: unknown,\n options?: ErrorMessage,\n): asserts input is TypedAsyncGeneratorFunction<Y, R, N> {\n if (!isAsyncGeneratorFunction(input)) {\n throw new TypeError(options?.message);\n }\n}\n","import { createTypeGuard } from '../utils';\nimport { isObject } from './isObject';\n\n/**\n * @remarks\n * This guard tests for Symbol.asyncIterator. See:\n * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/asyncIterator}\n * @category Type Guard\n */\nexport function isAsyncIterable<T = unknown>(\n input: unknown,\n): input is AsyncIterable<T> {\n return createTypeGuard<AsyncIterable<T>>(\n (value) =>\n isObject(value) &&\n typeof Reflect.get(value, Symbol.asyncIterator) === 'function',\n )(input);\n}\n","import { isAsyncIterable } from '../guards/isAsyncIterable';\nimport { ErrorMessage } from '../types';\n\n/**\n * @remarks\n * This guard tests for Symbol.asyncIterator. See:\n * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/asyncIterator}\n * @category Type Assertion\n * @throws TypeError\n */\nexport function assertIsAsyncIterable<T = unknown>(\n input: unknown,\n options?: ErrorMessage,\n): asserts input is AsyncIterable<T> {\n if (!isAsyncIterable(input)) {\n throw new TypeError(options?.message);\n }\n}\n","import { createTypeGuard } from '../utils';\n\n/**\n * @category Type Guard\n * @example\n *\n * ```typescript\n * // true\n * isBigInt(BigInt(9007199254740991));\n *\n * // true\n * isBigInt(9007199254740991n);\n * ```\n */\nexport const isBigInt = createTypeGuard<bigint>(\n (value) => typeof value === 'bigint',\n);\n","import type { ErrorMessage } from '../types';\nimport { isBigInt } from '../guards/isBigInt';\n\n/**\n * @category Type Assertion\n * @example\n *\n * ```typescript\n * // does not throw\n * assertIsBigInt(BigInt(9007199254740991));\n *\n * // throws\n * assertIsBigInt(9007199254740991n);\n * ```\n *\n * @throws TypeError\n */\nexport function assertIsBigInt(\n input: unknown,\n options?: ErrorMessage,\n): asserts input is bigint {\n if (!isBigInt(input)) {\n throw new TypeError(options?.message);\n }\n}\n","import { createTypeGuard } from '../utils';\n\n/** @category Type Guard */\nexport const isBigIntObject = createTypeGuard<bigint>(\n (value) =>\n typeof value === 'object' &&\n value !== null &&\n Object.prototype.toString.call(value) === '[object BigInt]',\n);\n","import type { ErrorMessage } from '../types';\nimport { isBigIntObject } from '../guards/isBigIntObject';\n\n/**\n * @category Type Assertion\n * @throws TypeError\n */\nexport function assertIsBigIntObject(\n input: unknown,\n options?: ErrorMessage,\n): asserts input is bigint {\n if (!isBigIntObject(input)) {\n throw new TypeError(options?.message);\n }\n}\n","import { createTypeGuard } from '../utils';\n\n/**\n * @category Type Guard\n * @example\n *\n * ```typescript\n * // true\n * isBoolean(false);\n *\n * // false\n * isBoolean(new Boolean(false));\n * ```\n */\nexport const isBoolean = createTypeGuard<boolean>(\n (value) => typeof value === 'boolean',\n);\n","import { isBoolean } from '../guards/isBoolean';\nimport { ErrorMessage } from '../types';\n\n/**\n * @category Type Assertion\n * @throws TypeError\n */\nexport function assertIsBoolean(\n input: unknown,\n options?: ErrorMessage,\n): asserts input is boolean {\n if (!isBoolean(input)) {\n throw new TypeError(options?.message);\n }\n}\n","import { createTypeGuard, toObjectString } from '../utils';\nimport { isObject } from './isObject';\n\n/**\n * @category Type Guard\n * @example\n *\n * ```typescript\n * // true\n * isBooleanObject(new Boolean(true));\n *\n * // false\n * isBooleanObject(true);\n * ```\n */\nexport const isBooleanObject = createTypeGuard<boolean>(\n (value) =>\n isObject(value) &&\n toObjectString(value) === '[object Boolean]' &&\n typeof value.valueOf() === 'boolean',\n);\n","import type { ErrorMessage } from '../types';\nimport { isBooleanObject } from '../guards/isBooleanObject';\n\n/**\n * @category Type Assertion\n * @throws TypeError\n */\nexport function assertIsBooleanObject(\n input: unknown,\n options?: ErrorMessage,\n): asserts input is boolean {\n if (!isBooleanObject(input)) {\n throw new TypeError(options?.message);\n }\n}\n","import { createTypeGuard, toObjectString } from '../utils';\nimport { isObject } from './isObject';\n\n/**\n * @category Type Guard\n * @example\n *\n * ```typescript\n * // true\n * isNumberObject(new Number(1));\n *\n * // false\n * isNumberObject(1);\n * ```\n */\nexport const isNumberObject = createTypeGuard<number>(\n (value) =>\n isObject(value) &&\n toObjectString(value) === '[object Number]' &&\n typeof value.valueOf() === 'number',\n);\n","import { createTypeGuard, toObjectString } from '../utils';\nimport { isObject } from './isObject';\n\n/**\n * @category Type Guard\n * @example\n *\n * ```typescript\n * // true\n * isStringObject(new String('xyz'));\n *\n * // false\n * isStringObject('xyz');\n * ```\n */\nexport const isStringObject = createTypeGuard<string>(\n (value) =>\n isObject(value) &&\n toObjectString(value) === '[object String]' &&\n typeof value.valueOf() === 'string',\n);\n","import { createTypeGuard } from '../utils';\n\n/** @category Type Guard */\nexport const isSymbolObject = createTypeGuard<symbol>(\n (value) =>\n typeof value === 'object' &&\n value !== null &&\n Object.prototype.toString.call(value) === '[object Symbol]',\n);\n","import { isBooleanObject } from './isBooleanObject';\nimport { isNumberObject } from './isNumberObject';\nimport { isStringObject } from './isStringObject';\nimport { isBigIntObject } from './isBigIntObject';\nimport { isSymbolObject } from './isSymbolObject';\nimport { createTypeGuard } from '../utils';\n\n/** @category Type Guard */\nexport const isBoxedPrimitive = createTypeGuard<\n bigint | boolean | number | string | symbol\n>(\n (value) =>\n isBooleanObject(value) ||\n isNumberObject(value) ||\n isStringObject(value) ||\n isBigIntObject(value) ||\n isSymbolObject(value),\n);\n","import type { ErrorMessage } from '../types';\nimport { isBoxedPrimitive } from '../guards/isBoxedPrimitive';\n\n/**\n * @category Type Assertion\n * @throws TypeError\n */\nexport function assertIsBoxedPrimitive(\n input: unknown,\n options?: ErrorMessage,\n): asserts input is bigint | boolean | number | string | symbol {\n if (!isBoxedPrimitive(input)) {\n throw new TypeError(options?.message);\n }\n}\n","import { createTypeGuard } from '../utils';\n\n/** @category Type Guard */\nexport const isBuffer = createTypeGuard<Buffer>(\n (value) => typeof Buffer !== 'undefined' && value instanceof Buffer,\n);\n","import type { ErrorMessage } from '../types';\nimport { isBuffer } from '../guards/isBuffer';\n\n/**\n * @category Type Assertion\n * @throws TypeError\n */\nexport function assertIsBuffer(\n input: unknown,\n options?: ErrorMessage,\n): asserts input is Buffer {\n if (!isBuffer(input)) {\n throw new TypeError(options?.message);\n }\n}\n","import type { ErrorMessage } from '../types';\nimport { isDataView } from '../guards/isDataView';\n\n/**\n * @category Type Assertion\n * @throws TypeError\n */\nexport function assertIsDataView(\n input: unknown,\n options?: ErrorMessage,\n): asserts input is DataView {\n if (!isDataView(input)) {\n throw new TypeError(options?.message);\n }\n}\n","import { createTypeGuard, toObjectString } from '../utils';\nimport { isObject } from './isObject';\n\n/** @category Type Guard */\nexport const isDate = createTypeGuard<Date>(\n (value) =>\n isObject(value) &&\n (toObjectString(value) === '[object Date]' || value instanceof Date),\n);\n","import type { ErrorMessage } from '../types';\nimport { isDate } from '../guards/isDate';\n\n/**\n * @category Type Assertion\n * @throws TypeError\n */\nexport function assertIsDate(\n input: unknown,\n options?: ErrorMessage,\n): asserts input is Date {\n if (!isDate(input)) {\n throw new TypeError(options?.message);\n }\n}\n","import { createTypeGuard } from '../utils';\n\n/** @category Type Guard */\nexport const isUndefined = createTypeGuard<undefined>(\n (value) => value === undefined,\n);\n","import { isUndefined } from '../guards/isUndefined';\nimport { ErrorMessage } from '../types';\n\n/**\n * @remarks\n * This assertion asserts that the value is not null, use assertIsNotNullish to\n * also exclude undefined\n * @category Type Assertion\n * @throws TypeError\n */\nexport function assertIsDefined<T>(\n input: T | undefined,\n options?: ErrorMessage,\n): asserts input is T {\n if (isUndefined(input)) {\n throw new TypeError(options?.message);\n }\n}\n","import { ValueValidator } from '../types';\nimport { createTypeGuard } from '../utils';\n\n/**\n * @category Type Guard\n * @example\n *\n * ```typescript\n * // true, typed as unknown[]\n * isArray(['xyz']);\n *\n * // true, typed as string[]\n * isArray<string>(['xyz'], { valueValidator: isString });\n * ```\n */\nexport function isArray(input: unknown): input is unknown[];\nexport function isArray<T>(\n input: unknown,\n options: ValueValidator,\n): input is T[];\nexport function isArray<T>(\n input: unknown,\n options?: ValueValidator,\n): input is T[] {\n return createTypeGuard<T[], undefined | ValueValidator>(\n (value) =>\n Array.isArray(value) &&\n (!options?.valueValidator || value.every(options.valueValidator)),\n )(input);\n}\n","import { isArray } from './isArray';\nimport { createTypeGuard } from '../utils';\n\n/** @category Type Guard */\nexport const isEmptyArray = createTypeGuard<[]>(\n (value) => isArray(value) && value.length === 0,\n);\n","import type { ErrorMessage } from '../types';\nimport { isEmptyArray } from '../guards/isEmptyArray';\n\n/**\n * @category Type Assertion\n * @throws TypeError\n */\nexport function assertIsEmptyArray(\n input: unknown,\n options?: ErrorMessage,\n): asserts input is [] {\n if (!isEmptyArray(input)) {\n throw new TypeError(options?.message);\n }\n}\n","import { isObject } from './isObject';\nimport { createTypeGuard } from '../utils';\n\n/** @category Type Guard */\nexport const isEmptyObject = createTypeGuard<Record<string, never>>(\n (value) =>\n isObject(value) &&\n !Array.isArray(value) &&\n Object.keys(value).length === 0,\n);\n","import type { ErrorMessage } from '../types';\nimport { isEmptyObject } from '../guards/isEmptyObject';\n\n/**\n * @category Type Assertion\n * @throws TypeError\n */\nexport function assertIsEmptyObject(\n input: unknown,\n options?: ErrorMessage,\n): asserts input is Record<string, never> {\n if (!isEmptyObject(input)) {\n throw new TypeError(options?.message);\n }\n}\n","import { createTypeGuard } from '../utils';\n\n/**\n * ```typescript\n * // true\n * isString('xyz');\n *\n * // false\n * isString(new String('xyz'));\n * ```\n *\n * /**\n *\n * @category Type Guard\n * @example\n *\n * ```typescript\n * // true\n * isString('xyz');\n *\n * // false\n * isString(new String('xyz'));\n * ```\n */\nexport const isString = createTypeGuard<string>(\n (value) => typeof value === 'string',\n);\n","import { isString } from './isString';\nimport { createTypeGuard } from '../utils';\n\n/** @category Type Guard */\nexport const isEmptyString = createTypeGuard<''>(\n (value) => isString(value) && value.length === 0,\n);\n","import type { ErrorMessage } from '../types';\nimport { isEmptyString } from '../guards/isEmptyString';\n\n/**\n * @category Type Assertion\n * @throws TypeError\n */\nexport function assertIsEmptyString(\n input: unknown,\n options?: ErrorMessage,\n): asserts input is '' {\n if (!isEmptyString(input)) {\n throw new TypeError(options?.message);\n }\n}\n","import { createTypeGuard, toObjectString } from '../utils';\nimport { isObject } from './isObject';\n\n/**\n * @category Type Guard\n * @example\n *\n * ```typescript\n * // true\n * isError(new Error());\n *\n * // true, value is typed as Error\n * isError(new TypeError());\n *\n * // true, value is still typed as Error (use type assertion if needed)\n * const error = new TypeError();\n * if (isError(error)) {\n * // error is now typed as Error\n * }\n *\n * // For custom errors, you can use type assertion\n * class MyCustomError extends Error {}\n * const customError = new MyCustomError();\n * if (isError(customError)) {\n * // customError is typed as Error\n * const myError = customError as MyCustomError;\n * }\n * ```\n */\nexport function isError(input: unknown): input is Error {\n return createTypeGuard<Error>(\n (value) =>\n isObject(value) &&\n (toObjectString(value) === '[object Error]' ||\n value instanceof Error),\n )(input);\n}\n","import { isError } from '../guards/isError';\nimport { ErrorMessage } from '../types';\n\n/**\n * ```typescript\n * // does not throw, value is typed as Error\n * assertIsError(new Error());\n *\n * // does not throw, value is typed as Error\n * // Use type assertion for specific error types\n * const error = new TypeError();\n * assertIsError(error);\n * const typeError = error as TypeError;\n *\n * // For custom errors, use type assertion after the check\n * class MyError extends Error {}\n * const myError = new MyError();\n * assertIsError(myError);\n * const typedError = myError as MyError;\n * ```\n *\n * /**\n *\n * @category Type Assertion\n * @example\n *\n * ```typescript\n * // does not throw, value is typed as Error\n * assertIsError(new Error());\n *\n * // does not throw, value is typed as Error\n * // Use type assertion for specific error types\n * const error = new TypeError();\n * assertIsError(error);\n * const typeError = error as TypeError;\n *\n * // For custom errors, use type assertion after the check\n * class MyError extends Error {}\n * const myError = new MyError();\n * assertIsError(myError);\n * const typedError = myError as MyError;\n * ```\n *\n * @throws {TypeError} Will throw an error if the input is not an Error object\n */\nexport function assertIsError(\n input: unknown,\n options?: ErrorMessage,\n): asserts input is Error {\n if (!isError(input)) {\n throw new TypeError(options?.message);\n }\n}\n","import { createTypeGuard } from '../utils';\n\n/** @category Type Guard */\nexport const isFinite = createTypeGuard<number>(\n (value) => typeof value === 'number' && Number.isFinite(value),\n);\n","import type { ErrorMessage } from '../types';\nimport { isFinite } from '../guards/isFinite';\n\n/**\n * @category Type Assertion\n * @throws TypeError\n */\nexport function assertIsFinite(\n input: unknown,\n options?: ErrorMessage,\n): asserts input is number {\n if (!isFinite(input)) {\n throw new TypeError(options?.message);\n }\n}\n","import { createTypeGuard, toObjectString } from '../utils';\n\n/**\n * @remarks\n * This guard works only in ES2018 and above\n * @category Type Guard\n * @example\n *\n * ```typescript\n * // true, value is typed as (...args: unknown[]) => unknown\n * isFunction(() => null);\n *\n * // false - use isAsyncFunction for async functions\n * isFunction(async () => Promise.resolve(null));\n *\n * // false - use isGeneratorFunction for generator functions\n * isFunction(function* () {});\n *\n * // false - use isAsyncGeneratorFunction for async generator functions\n * isFunction(async function* () {});\n *\n * // false - use isConstructor for class constructors\n * isFunction(MyClass);\n *\n * // Type assertion can be used for specific function types\n * const specificFn = (x: number): string => x.toString();\n * if (isFunction(specificFn)) {\n * // specificFn is now typed as (...args: unknown[]) => unknown\n * // Use type assertion if needed: (specificFn as (x: number) => string)(42);\n * }\n * ```\n */\nexport function isFunction(\n input: unknown,\n): input is (...args: unknown[]) => unknown {\n return createTypeGuard<(...args: unknown[]) => unknown>(\n (value) =>\n typeof value === 'function' &&\n toObjectString(value) === '[object Function]',\n )(input);\n}\n","import { isFunction } from '../guards/isFunction';\nimport { ErrorMessage } from '../types';\n\n/**\n * @remarks\n * This guard works only in ES2018 and above\n * @category Type Assertion\n * @example\n *\n * ```typescript\n * // does not throw, value is typed as (...args: unknown[]) => unknown\n * assertIsFunction(() => true);\n *\n * // Use type assertion for specific function types\n * const myFunc = (x: number): string => x.toString();\n * assertIsFunction(myFunc);\n * const typedFunc = myFunc as (x: number) => string;\n *\n * // throws - use isAsyncFunction for async functions\n * assertIsFunction(async () => Promise.resolve(null));\n *\n * // throws - use isGeneratorFunction for generator functions\n * assertIsFunction(function* () {});\n *\n * // throws - use isAsyncGeneratorFunction for async generator functions\n * assertIsFunction(async function* () {});\n *\n * // throws - use isConstructor for class constructors\n * assertIsFunction(MyClass);\n * ```\n *\n * @throws {TypeError} Will throw an error if the input is not a function\n */\nexport function assertIsFunction(\n input: unknown,\n options?: ErrorMessage,\n): asserts input is (...args: unknown[]) => unknown {\n if (!isFunction(input)) {\n throw new TypeError(options?.message);\n }\n}\n","import { createTypeGuard, toObjectString } from '../utils';\nimport { isObject } from './isObject';\n\n/** @category Type Guard */\nexport function isGenerator<Y = unknown, R = unknown, N = unknown>(\n input: unknown,\n): input is Generator<Y, R, N> {\n return createTypeGuard<Generator<Y, R, N>>(\n (value) =>\n isObject(value) && toObjectString(value) === '[object Generator]',\n )(input);\n}\n","import { isGenerator } from '../guards/isGenerator';\nimport { ErrorMessage } from '../types';\n\n/**\n * @remarks\n * This assertion works only in ES2018 and above\n * @category Type Assertion\n * @throws TypeError\n */\nexport function assertIsGenerator<Y = unknown, R = unknown, N = unknown>(\n input: unknown,\n options?: ErrorMessage,\n): asserts input is Generator<Y, R, N> {\n if (!isGenerator(input)) {\n throw new TypeError(options?.message);\n }\n}\n","import { TypedGeneratorFunction } from '../types';\nimport { createTypeGuard, toObjectString } from '../utils';\n\n/** @category Type Guard */\nexport function isGeneratorFunction<Y = unknown, R = unknown, N = unknown>(\n input: unknown,\n): input is TypedGeneratorFunction<Y, R, N> {\n return createTypeGuard<TypedGeneratorFunction<Y, R, N>>(\n (value) =>\n typeof value === 'function' &&\n toObjectString(value) === '[object GeneratorFunction]',\n )(input);\n}\n","import { isGeneratorFunction } from '../guards/isGeneratorFunction';\nimport { ErrorMessage, TypedGeneratorFunction } from '../types';\n\n/**\n * @remarks\n * This assertion works only in ES2018 and above\n * @category Type Assertion\n * @throws TypeError\n */\nexport function assertIsGeneratorFunction<\n Y = unknown,\n R = unknown,\n N = unknown,\n>(\n input: unknown,\n options?: ErrorMessage,\n): asserts input is TypedGeneratorFunction<Y, R, N> {\n if (!isGeneratorFunction(input)) {\n throw new TypeError(options?.message);\n }\n}\n","import { createTypeGuard } from '../utils';\n\n/** @category Type Guard */\nexport const isInteger = createTypeGuard<number>(\n (value) => typeof value === 'number' && Number.isInteger(value),\n);\n","import type { ErrorMessage } from '../types';\nimport { isInteger } from '../guards/isInteger';\n\n/**\n * @category Type Assertion\n * @throws TypeError\n */\nexport function assertIsInteger(\n input: unknown,\n options?: ErrorMessage,\n): asserts input is number {\n if (!isInteger(input)) {\n throw new TypeError(options?.message);\n }\n}\n","import { createTypeGuard } from '../utils';\nimport { isObject } from './isObject';\nimport { isString } from './isString';\n\n/**\n * @remarks\n * This guard tests for Symbol.iterator, which defines the Iterable protocol.\n * See:\n * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols}\n * @category Type Guard\n */\nexport function isIterable<T = unknown>(input: unknown): input is Iterable<T> {\n return createTypeGuard<Iterable<T>>(\n (value) =>\n (isObject(value) &&\n typeof Reflect.get(value, Symbol.iterator) === 'function') ||\n isString(value),\n )(input);\n}\n","import { isIterable } from '../guards/isIterable';\nimport { ErrorMessage } from '../types';\n\n/**\n * @remarks\n * This guard tests for Symbol.iterator, which defines the Iterable protocol.\n * See:\n * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols}\n * @category Type Assertion\n * @throws TypeError\n */\nexport function assertIsIterable<T = unknown>(\n input: unknown,\n options?: ErrorMessage,\n): asserts input is Iterable<T> {\n if (!isIterable(input)) {\n throw new TypeError(options?.message);\n }\n}\n","import { createTypeGuard } from '../utils';\nimport { isObject } from './isObject';\n\n/**\n * @remarks\n * This guard tests for the presence of a '.next' method on the object, which\n * defines the Iteration protocol. See:\n * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols}.\n *\n * At present it is not possible to distinguish between Iterator and\n * AsyncIterator using reflection.\n * @category Type Guard\n */\nexport function isIterator<Y = unknown, R = unknown, N = unknown>(\n input: unknown,\n): input is Iterator<Y, R, N> {\n return createTypeGuard<Iterator<Y, R, N>>(\n (value) =>\n isObject(value) && typeof Reflect.get(value, 'next') === 'function',\n )(input);\n}\n","import { isIterator } from '../guards/isIterator';\nimport { ErrorMessage } from '../types';\n\n/**\n * @remarks\n * This assertion works only in ES2018 and above\n * @category Type Assertion\n * @throws TypeError\n */\nexport function assertIsIterator<Y = unknown, R = unknown, N = unknown>(\n input: unknown,\n options?: ErrorMessage,\n): asserts input is Iterator<Y, R, N> {\n if (!isIterator(input)) {\n throw new TypeError(options?.message);\n }\n}\n","import { KeyValidator, ValueValidator } from '../types';\nimport { createTypeGuard, toObjectString } from '../utils';\nimport { isObject } from './isObject';\n\n/**\n * @category Type Guard\n * @example\n *\n * ```typescript\n * // true, value is typed as Map<unknown, unknown>\n * isMap(new Map([['xyz', 'abc']]));\n *\n * // true, value is typed as Map<string, string | number>\n * isMap<string, string>(\n * new Map([\n * ['abc', 'def'],\n * ['xyz', 100],\n * ]),\n * {\n * keyValidator: isString,\n * valueValidator: isUnion(isString, isNumber),\n * },\n * );\n * ```\n */\nexport function isMap(input: unknown): input is Map<unknown, unknown>;\nexport function isMap<K>(\n input: unknown,\n options: KeyValidator,\n): input is Map<K, unknown>;\nexport function isMap<V>(\n input: unknown,\n options: ValueValidator,\n): input is Map<unknown, V>;\nexport function isMap<K, V>(\n input: unknown,\n options: KeyValidator & ValueValidator,\n): input is Map<K, V>;\nexport function isMap<K, V>(\n input: unknown,\n options?: Partial<KeyValidator & ValueValidator>,\n): input is Map<K, V> {\n return createTypeGuard<\n Map<K, V>,\n Partial<KeyValidator & ValueValidator> | undefined\n >((value) => {\n if (\n !(value instanceof Map) &&\n (!isObject(value) || toObjectString(value) !== '[object Map]')\n ) {\n return false;\n }\n\n const map = value as Map<unknown, unknown>;\n\n if (options?.valueValidator) {\n for (const v of map.values()) {\n if (!options.valueValidator(v)) {\n return false;\n }\n }\n }\n\n if (options?.keyValidator) {\n for (const k of map.keys()) {\n if (!options.keyValidator(k)) {\n return false;\n }\n }\n }\n\n return true;\n })(input);\n}\n","import { isMap } from '../guards/isMap';\nimport { ErrorMessage, KeyValidator, ValueValidator } from '../types';\n\n/**\n * @category Type Assertion\n * @example\n *\n * ```typescript\n * // does not throw, value is typed as Map<unknown, unknown>\n * assertIsMap(new Map([['xyz', 'abc']]));\n *\n * // does not throw, value is typed as Map<string, string | number>\n * assertIsMap<string, string>(\n * new Map([\n * ['abc', 'def'],\n * ['xyz', 100],\n * ]),\n * {\n * keyValidator: isString,\n * valueValidator: isUnion(isString, isNumber),\n * },\n * );\n * ```\n *\n * @throws TypeError\n */\nexport function assertIsMap(\n input: unknown,\n options?: ErrorMessage,\n): asserts input is Map<unknown, unknown>;\n\nexport function assertIsMap<K>(\n input: unknown,\n options: (ErrorMessage & KeyValidator) | KeyValidator,\n): asserts input is Map<K, unknown>;\n\nexport function assertIsMap<V>(\n input: unknown,\n options: (ErrorMessage & ValueValidator) | ValueValidator,\n): asserts input is Map<string, V>;\n\nexport function assertIsMap<K, V>(\n input: unknown,\n options:\n | (ErrorMessage & KeyValidator & ValueValidator)\n | (KeyValidator & ValueValidator),\n): asserts input is Map<K, V>;\n\nexport function assertIsMap<K, V>(\n input: unknown,\n options?: Partial<ErrorMessage & KeyValidator & ValueValidator>,\n): asserts input is Map<K, V> {\n if (!isMap(input)) {\n throw new TypeError(options?.message);\n }\n\n if (options?.keyValidator) {\n const keys = [...input.keys()];\n if (!keys.every(options.keyValidator)) {\n throw new TypeError(options.message);\n }\n }\n\n if (options?.valueValidator) {\n const values = [...input.values()];\n if (!values.every(options.valueValidator)) {\n throw new TypeError(options.message);\n }\n }\n}\n","import { createTypeGuard } from '../utils';\n\n/** @category Type Guard */\nexport const isMapIterator = createTypeGuard<\n IterableIterator<[unknown, unknown]>\n>(\n (value) =>\n typeof value === 'object' &&\n value !== null &&\n Object.prototype.toString.call(value) === '[object Map Iterator]',\n);\n","import type { ErrorMessage } from '../types';\nimport { isMapIterator } from '../guards/isMapIterator';\n\n/**\n * @category Type Assertion\n * @throws TypeError\n */\nexport function assertIsMapIterator(\n input: unknown,\n options?: ErrorMessage,\n): asserts input is IterableIterator<[unknown, unknown]> {\n if (!isMapIterator(input)) {\n throw new TypeError(options?.message);\n }\n}\n","import { createTypeGuard } from '../utils';\n\n/** @category Type Guard */\nexport const isNaN = createTypeGuard<number>(\n (value) => typeof value === 'number' && Number.isNaN(value),\n);\n","import type { ErrorMessage } from '../types';\nimport { isNaN } from '../guards/isNaN';\n\n/**\n * @category Type Assertion\n * @throws TypeError\n */\nexport function assertIsNaN(\n input: unknown,\n options?: ErrorMessage,\n): asserts input is number {\n if (!isNaN(input)) {\n throw new TypeError(options?.message);\n }\n}\n","import { createTypeGuard } from '../utils';\n\n/** @category Type Guard */\nexport const isNativeError = createTypeGuard<Error>(\n (value) =>\n value instanceof Error ||\n value instanceof EvalError ||\n value instanceof RangeError ||\n value instanceof ReferenceError ||\n value instanceof SyntaxError ||\n value instanceof TypeError ||\n value instanceof URIError ||\n (typeof AggregateError !== 'undefined' &&\n value instanceof AggregateError),\n);\n","import type { ErrorMessage } from '../types';\nimport { isNativeError } from '../guards/isNativeError';\n\n/**\n * @category Type Assertion\n * @throws TypeError\n */\nexport function assertIsNativeError(\n input: unknown,\n options?: ErrorMessage,\n): asserts input is Error {\n if (!isNativeError(input)) {\n throw new TypeError(options?.message);\n }\n}\n","import { isArray } from './isArray';\nimport { createTypeGuard } from '../utils';\n\n/** @category Type Guard */\nexport const isNonEmptyArray = createTypeGuard<[unknown, ...unknown[]]>(\n (value) => isArray(value) && value.length > 0,\n);\n","import type { ErrorMessage } from '../types';\nimport { isNonEmptyArray } from '../guards/isNonEmptyArray';\n\n/**\n * @category Type Assertion\n * @throws TypeError\n */\nexport function assertIsNonEmptyArray(\n input: unknown,\n options?: ErrorMessage,\n): asserts input is [unknown, ...unknown[]] {\n if (!isNonEmptyArray(input)) {\n throw new TypeError(options?.message);\n }\n}\n","import { isString } from './isString';\nimport { createTypeGuard } from '../utils';\n\n/** @category Type Guard */\nexport const isNonEmptyString = createTypeGuard<string>(\n (value) => isString(value) && value.length > 0,\n);\n","import type { ErrorMessage } from '../types';\nimport { isNonEmptyString } from '../guards/isNonEmptyString';\n\n/**\n * @category Type Assertion\n * @throws TypeError\n */\nexport function assertIsNonEmptyString(\n input: unknown,\n options?: ErrorMessage,\n): asserts input is string {\n if (!isNonEmptyString(input)) {\n throw new TypeError(options?.message);\n }\n}\n","import { createTypeGuard } from '../utils';\n\n/** @category Type Guard */\nexport const isNull = createTypeGuard<null>((value) => value === null);\n","import { isNull } from '../guards/isNull';\nimport { ErrorMessage } from '../types';\n\n/**\n * @remarks\n * This assertion asserts that the value is not null, use assertIsNotNullish to\n * also exclude undefined\n * @category Type Assertion\n * @throws TypeError\n */\nexport function assertIsNotNull<T>(\n input: null | T,\n options?: ErrorMessage,\n): asserts input is T {\n if (isNull(input)) {\n throw new TypeError(options?.message);\n }\n}\n","import { isNull } from '../guards/isNull';\nimport { isUndefined } from '../guards/isUndefined';\nimport { ErrorMessage } from '../types';\n\n/**\n * @remarks\n * Tests false for undefined and null, true for all other values\n * @category Type Assertion\n * @throws TypeError\n */\nexport function assertIsNotNullish<T>(\n input: null | T | undefined,\n options?: ErrorMessage,\n): asserts input is T {\n if (isUndefined(input) || isNull(input)) {\n throw new TypeError(options?.message);\n }\n}\n","import type { ErrorMessage } from '../types';\nimport { isNull } from '../guards/isNull';\n\n/**\n * @category Type Assertion\n * @throws TypeError\n */\nexport function assertIsNull(\n input: unknown,\n options?: ErrorMessage,\n): asserts input is null {\n if (!isNull(input)) {\n throw new TypeError(options?.message);\n }\n}\n","import { isUnion } from '../utils';\nimport { isNull } from './isNull';\nimport { isUndefined } from './isUndefined';\n\n/**\n * @remarks\n * Tests true for undefined and null, false for all other falsy values\n * @category Type Guard\n */\nexport const isNullish = isUnion<null | undefined>(isNull, isUndefined);\n","import type { ErrorMessage } from '../types';\nimport { isNullish } from '../guards/isNullish';\n\n/**\n * @category Type Assertion\n * @throws TypeError\n */\nexport function assertIsNullish(\n input: unknown,\n options?: ErrorMessage,\n): asserts input is null | undefined {\n if (!isNullish(input)) {\n throw new TypeError(options?.message);\n }\n}\n","import { createTypeGuard } from '../utils';\n\n/**\n * @category Type Guard\n * @example\n *\n * ```typescript\n * // true\n * isNumber(1);\n *\n * // false\n * isNumber(new Number(1));\n *\n * // false\n * isNumber(new BigInt(9007199254740991n));\n * ```\n */\nexport const isNumber = createTypeGuard<number>(\n (value) => typeof value === 'number',\n);\n","import { isNumber } from '../guards/isNumber';\nimport { ErrorMessage } from '../types';\n\n/**\n * @category Type Asse