From 953ddd82e48dd206cef5ac94456549aed13b3ad5 Mon Sep 17 00:00:00 2001 From: RaindropsSys Date: Fri, 17 Nov 2023 23:25:29 +0100 Subject: Updated 30 files and deleted 2976 files (automated) --- .../node_modules/@sindresorhus/is/dist/index.d.ts | 235 -------- .../node_modules/@sindresorhus/is/dist/index.js | 434 ------------- .../node_modules/@sindresorhus/is/dist/types.d.ts | 29 - .../node_modules/@sindresorhus/is/dist/types.js | 2 - .../node_modules/@sindresorhus/is/license | 9 - .../node_modules/@sindresorhus/is/package.json | 82 --- .../node_modules/@sindresorhus/is/readme.md | 670 --------------------- 7 files changed, 1461 deletions(-) delete mode 100644 includes/external/addressbook/node_modules/@sindresorhus/is/dist/index.d.ts delete mode 100644 includes/external/addressbook/node_modules/@sindresorhus/is/dist/index.js delete mode 100644 includes/external/addressbook/node_modules/@sindresorhus/is/dist/types.d.ts delete mode 100644 includes/external/addressbook/node_modules/@sindresorhus/is/dist/types.js delete mode 100644 includes/external/addressbook/node_modules/@sindresorhus/is/license delete mode 100644 includes/external/addressbook/node_modules/@sindresorhus/is/package.json delete mode 100644 includes/external/addressbook/node_modules/@sindresorhus/is/readme.md (limited to 'includes/external/addressbook/node_modules/@sindresorhus/is') diff --git a/includes/external/addressbook/node_modules/@sindresorhus/is/dist/index.d.ts b/includes/external/addressbook/node_modules/@sindresorhus/is/dist/index.d.ts deleted file mode 100644 index fe2beb0..0000000 --- a/includes/external/addressbook/node_modules/@sindresorhus/is/dist/index.d.ts +++ /dev/null @@ -1,235 +0,0 @@ -/// -/// -/// -import type { Buffer } from 'node:buffer'; -import type { Class, Falsy, TypedArray, ObservableLike, Primitive, WeakRef } from './types.js'; -declare const objectTypeNames: readonly ["Function", "Generator", "AsyncGenerator", "GeneratorFunction", "AsyncGeneratorFunction", "AsyncFunction", "Observable", "Array", "Buffer", "Blob", "Object", "RegExp", "Date", "Error", "Map", "Set", "WeakMap", "WeakSet", "WeakRef", "ArrayBuffer", "SharedArrayBuffer", "DataView", "Promise", "URL", "FormData", "URLSearchParams", "HTMLElement", "NaN", "Int8Array", "Uint8Array", "Uint8ClampedArray", "Int16Array", "Uint16Array", "Int32Array", "Uint32Array", "Float32Array", "Float64Array", "BigInt64Array", "BigUint64Array"]; -declare type ObjectTypeName = typeof objectTypeNames[number]; -declare const primitiveTypeNames: readonly ["null", "undefined", "string", "number", "bigint", "boolean", "symbol"]; -declare type PrimitiveTypeName = typeof primitiveTypeNames[number]; -export declare type TypeName = ObjectTypeName | PrimitiveTypeName; -declare function is(value: unknown): TypeName; -declare namespace is { - var undefined: (value: unknown) => value is undefined; - var string: (value: unknown) => value is string; - var number: (value: unknown) => value is number; - var bigint: (value: unknown) => value is bigint; - var function_: (value: unknown) => value is Function; - var null_: (value: unknown) => value is null; - var class_: (value: unknown) => value is Class; - var boolean: (value: unknown) => value is boolean; - var symbol: (value: unknown) => value is symbol; - var numericString: (value: unknown) => value is string; - var array: (value: unknown, assertion?: ((value: T) => value is T) | undefined) => value is T[]; - var buffer: (value: unknown) => value is Buffer; - var blob: (value: unknown) => value is Blob; - var nullOrUndefined: (value: unknown) => value is null | undefined; - var object: (value: unknown) => value is object; - var iterable: (value: unknown) => value is Iterable; - var asyncIterable: (value: unknown) => value is AsyncIterable; - var generator: (value: unknown) => value is Generator; - var asyncGenerator: (value: unknown) => value is AsyncGenerator; - var nativePromise: (value: unknown) => value is Promise; - var promise: (value: unknown) => value is Promise; - var generatorFunction: (value: unknown) => value is GeneratorFunction; - var asyncGeneratorFunction: (value: unknown) => value is (...args: any[]) => Promise; - var asyncFunction: (value: unknown) => value is (...args: any[]) => Promise; - var boundFunction: (value: unknown) => value is Function; - var regExp: (value: unknown) => value is RegExp; - var date: (value: unknown) => value is Date; - var error: (value: unknown) => value is Error; - var map: (value: unknown) => value is Map; - var set: (value: unknown) => value is Set; - var weakMap: (value: unknown) => value is WeakMap; - var weakSet: (value: unknown) => value is WeakSet; - var weakRef: (value: unknown) => value is WeakRef; - var int8Array: (value: unknown) => value is Int8Array; - var uint8Array: (value: unknown) => value is Uint8Array; - var uint8ClampedArray: (value: unknown) => value is Uint8ClampedArray; - var int16Array: (value: unknown) => value is Int16Array; - var uint16Array: (value: unknown) => value is Uint16Array; - var int32Array: (value: unknown) => value is Int32Array; - var uint32Array: (value: unknown) => value is Uint32Array; - var float32Array: (value: unknown) => value is Float32Array; - var float64Array: (value: unknown) => value is Float64Array; - var bigInt64Array: (value: unknown) => value is BigInt64Array; - var bigUint64Array: (value: unknown) => value is BigUint64Array; - var arrayBuffer: (value: unknown) => value is ArrayBuffer; - var sharedArrayBuffer: (value: unknown) => value is SharedArrayBuffer; - var dataView: (value: unknown) => value is DataView; - var enumCase: (value: unknown, targetEnum: T) => boolean; - var directInstanceOf: (instance: unknown, class_: Class) => instance is T; - var urlInstance: (value: unknown) => value is URL; - var urlString: (value: unknown) => value is string; - var truthy: (value: Falsy | T) => value is T; - var falsy: (value: Falsy | T) => value is Falsy; - var nan: (value: unknown) => boolean; - var primitive: (value: unknown) => value is Primitive; - var integer: (value: unknown) => value is number; - var safeInteger: (value: unknown) => value is number; - var plainObject: (value: unknown) => value is Record; - var typedArray: (value: unknown) => value is TypedArray; - var arrayLike: (value: unknown) => value is ArrayLike; - var inRange: (value: number, range: number | number[]) => value is number; - var domElement: (value: unknown) => value is HTMLElement; - var observable: (value: unknown) => value is ObservableLike; - var nodeStream: (value: unknown) => value is NodeStream; - var infinite: (value: unknown) => value is number; - var evenInteger: (value: number) => value is number; - var oddInteger: (value: number) => value is number; - var emptyArray: (value: unknown) => value is never[]; - var nonEmptyArray: (value: unknown) => value is [unknown, ...unknown[]]; - var emptyString: (value: unknown) => value is ""; - var emptyStringOrWhitespace: (value: unknown) => value is string; - var nonEmptyString: (value: unknown) => value is string; - var nonEmptyStringAndNotWhitespace: (value: unknown) => value is string; - var emptyObject: (value: unknown) => value is Record; - var nonEmptyObject: (value: unknown) => value is Record; - var emptySet: (value: unknown) => value is Set; - var nonEmptySet: (value: unknown) => value is Set; - var emptyMap: (value: unknown) => value is Map; - var nonEmptyMap: (value: unknown) => value is Map; - var propertyKey: (value: unknown) => value is PropertyKey; - var formData: (value: unknown) => value is FormData; - var urlSearchParams: (value: unknown) => value is URLSearchParams; - var any: (predicate: Predicate | Predicate[], ...values: unknown[]) => boolean; - var all: (predicate: Predicate, ...values: unknown[]) => boolean; -} -export interface ArrayLike { - readonly [index: number]: T; - readonly length: number; -} -export interface NodeStream extends NodeJS.EventEmitter { - pipe(destination: T, options?: { - end?: boolean; - }): T; -} -export declare type Predicate = (value: unknown) => boolean; -export declare const enum AssertionTypeDescription { - class_ = "Class", - numericString = "string with a number", - nullOrUndefined = "null or undefined", - iterable = "Iterable", - asyncIterable = "AsyncIterable", - nativePromise = "native Promise", - urlString = "string with a URL", - truthy = "truthy", - falsy = "falsy", - nan = "NaN", - primitive = "primitive", - integer = "integer", - safeInteger = "integer", - plainObject = "plain object", - arrayLike = "array-like", - typedArray = "TypedArray", - domElement = "HTMLElement", - nodeStream = "Node.js Stream", - infinite = "infinite number", - emptyArray = "empty array", - nonEmptyArray = "non-empty array", - emptyString = "empty string", - emptyStringOrWhitespace = "empty string or whitespace", - nonEmptyString = "non-empty string", - nonEmptyStringAndNotWhitespace = "non-empty string and not whitespace", - emptyObject = "empty object", - nonEmptyObject = "non-empty object", - emptySet = "empty set", - nonEmptySet = "non-empty set", - emptyMap = "empty map", - nonEmptyMap = "non-empty map", - evenInteger = "even integer", - oddInteger = "odd integer", - directInstanceOf = "T", - inRange = "in range", - any = "predicate returns truthy for any value", - all = "predicate returns truthy for all values" -} -interface Assert { - undefined: (value: unknown) => asserts value is undefined; - string: (value: unknown) => asserts value is string; - number: (value: unknown) => asserts value is number; - bigint: (value: unknown) => asserts value is bigint; - function_: (value: unknown) => asserts value is Function; - null_: (value: unknown) => asserts value is null; - class_: (value: unknown) => asserts value is Class; - boolean: (value: unknown) => asserts value is boolean; - symbol: (value: unknown) => asserts value is symbol; - numericString: (value: unknown) => asserts value is string; - array: (value: unknown, assertion?: (element: unknown) => asserts element is T) => asserts value is T[]; - buffer: (value: unknown) => asserts value is Buffer; - blob: (value: unknown) => asserts value is Blob; - nullOrUndefined: (value: unknown) => asserts value is null | undefined; - object: (value: unknown) => asserts value is Record; - iterable: (value: unknown) => asserts value is Iterable; - asyncIterable: (value: unknown) => asserts value is AsyncIterable; - generator: (value: unknown) => asserts value is Generator; - asyncGenerator: (value: unknown) => asserts value is AsyncGenerator; - nativePromise: (value: unknown) => asserts value is Promise; - promise: (value: unknown) => asserts value is Promise; - generatorFunction: (value: unknown) => asserts value is GeneratorFunction; - asyncGeneratorFunction: (value: unknown) => asserts value is AsyncGeneratorFunction; - asyncFunction: (value: unknown) => asserts value is Function; - boundFunction: (value: unknown) => asserts value is Function; - regExp: (value: unknown) => asserts value is RegExp; - date: (value: unknown) => asserts value is Date; - error: (value: unknown) => asserts value is Error; - map: (value: unknown) => asserts value is Map; - set: (value: unknown) => asserts value is Set; - weakMap: (value: unknown) => asserts value is WeakMap; - weakSet: (value: unknown) => asserts value is WeakSet; - weakRef: (value: unknown) => asserts value is WeakRef; - int8Array: (value: unknown) => asserts value is Int8Array; - uint8Array: (value: unknown) => asserts value is Uint8Array; - uint8ClampedArray: (value: unknown) => asserts value is Uint8ClampedArray; - int16Array: (value: unknown) => asserts value is Int16Array; - uint16Array: (value: unknown) => asserts value is Uint16Array; - int32Array: (value: unknown) => asserts value is Int32Array; - uint32Array: (value: unknown) => asserts value is Uint32Array; - float32Array: (value: unknown) => asserts value is Float32Array; - float64Array: (value: unknown) => asserts value is Float64Array; - bigInt64Array: (value: unknown) => asserts value is BigInt64Array; - bigUint64Array: (value: unknown) => asserts value is BigUint64Array; - arrayBuffer: (value: unknown) => asserts value is ArrayBuffer; - sharedArrayBuffer: (value: unknown) => asserts value is SharedArrayBuffer; - dataView: (value: unknown) => asserts value is DataView; - enumCase: (value: unknown, targetEnum: T) => asserts value is T[keyof T]; - urlInstance: (value: unknown) => asserts value is URL; - urlString: (value: unknown) => asserts value is string; - truthy: (value: unknown) => asserts value is unknown; - falsy: (value: unknown) => asserts value is unknown; - nan: (value: unknown) => asserts value is unknown; - primitive: (value: unknown) => asserts value is Primitive; - integer: (value: unknown) => asserts value is number; - safeInteger: (value: unknown) => asserts value is number; - plainObject: (value: unknown) => asserts value is Record; - typedArray: (value: unknown) => asserts value is TypedArray; - arrayLike: (value: unknown) => asserts value is ArrayLike; - domElement: (value: unknown) => asserts value is HTMLElement; - observable: (value: unknown) => asserts value is ObservableLike; - nodeStream: (value: unknown) => asserts value is NodeStream; - infinite: (value: unknown) => asserts value is number; - emptyArray: (value: unknown) => asserts value is never[]; - nonEmptyArray: (value: unknown) => asserts value is [unknown, ...unknown[]]; - emptyString: (value: unknown) => asserts value is ''; - emptyStringOrWhitespace: (value: unknown) => asserts value is string; - nonEmptyString: (value: unknown) => asserts value is string; - nonEmptyStringAndNotWhitespace: (value: unknown) => asserts value is string; - emptyObject: (value: unknown) => asserts value is Record; - nonEmptyObject: (value: unknown) => asserts value is Record; - emptySet: (value: unknown) => asserts value is Set; - nonEmptySet: (value: unknown) => asserts value is Set; - emptyMap: (value: unknown) => asserts value is Map; - nonEmptyMap: (value: unknown) => asserts value is Map; - propertyKey: (value: unknown) => asserts value is PropertyKey; - formData: (value: unknown) => asserts value is FormData; - urlSearchParams: (value: unknown) => asserts value is URLSearchParams; - evenInteger: (value: number) => asserts value is number; - oddInteger: (value: number) => asserts value is number; - directInstanceOf: (instance: unknown, class_: Class) => asserts instance is T; - inRange: (value: number, range: number | number[]) => asserts value is number; - any: (predicate: Predicate | Predicate[], ...values: unknown[]) => void | never; - all: (predicate: Predicate, ...values: unknown[]) => void | never; -} -export declare const assert: Assert; -export default is; -export type { Class, TypedArray, ObservableLike, Primitive } from './types.js'; diff --git a/includes/external/addressbook/node_modules/@sindresorhus/is/dist/index.js b/includes/external/addressbook/node_modules/@sindresorhus/is/dist/index.js deleted file mode 100644 index 9161dc2..0000000 --- a/includes/external/addressbook/node_modules/@sindresorhus/is/dist/index.js +++ /dev/null @@ -1,434 +0,0 @@ -const typedArrayTypeNames = [ - 'Int8Array', - 'Uint8Array', - 'Uint8ClampedArray', - 'Int16Array', - 'Uint16Array', - 'Int32Array', - 'Uint32Array', - 'Float32Array', - 'Float64Array', - 'BigInt64Array', - 'BigUint64Array', -]; -function isTypedArrayName(name) { - return typedArrayTypeNames.includes(name); -} -const objectTypeNames = [ - 'Function', - 'Generator', - 'AsyncGenerator', - 'GeneratorFunction', - 'AsyncGeneratorFunction', - 'AsyncFunction', - 'Observable', - 'Array', - 'Buffer', - 'Blob', - 'Object', - 'RegExp', - 'Date', - 'Error', - 'Map', - 'Set', - 'WeakMap', - 'WeakSet', - 'WeakRef', - 'ArrayBuffer', - 'SharedArrayBuffer', - 'DataView', - 'Promise', - 'URL', - 'FormData', - 'URLSearchParams', - 'HTMLElement', - 'NaN', - ...typedArrayTypeNames, -]; -function isObjectTypeName(name) { - return objectTypeNames.includes(name); -} -const primitiveTypeNames = [ - 'null', - 'undefined', - 'string', - 'number', - 'bigint', - 'boolean', - 'symbol', -]; -function isPrimitiveTypeName(name) { - return primitiveTypeNames.includes(name); -} -// eslint-disable-next-line @typescript-eslint/ban-types -function isOfType(type) { - return (value) => typeof value === type; -} -const { toString } = Object.prototype; -const getObjectType = (value) => { - const objectTypeName = toString.call(value).slice(8, -1); - if (/HTML\w+Element/.test(objectTypeName) && is.domElement(value)) { - return 'HTMLElement'; - } - if (isObjectTypeName(objectTypeName)) { - return objectTypeName; - } - return undefined; -}; -const isObjectOfType = (type) => (value) => getObjectType(value) === type; -function is(value) { - if (value === null) { - return 'null'; - } - switch (typeof value) { - case 'undefined': - return 'undefined'; - case 'string': - return 'string'; - case 'number': - return Number.isNaN(value) ? 'NaN' : 'number'; - case 'boolean': - return 'boolean'; - case 'function': - return 'Function'; - case 'bigint': - return 'bigint'; - case 'symbol': - return 'symbol'; - default: - } - if (is.observable(value)) { - return 'Observable'; - } - if (is.array(value)) { - return 'Array'; - } - if (is.buffer(value)) { - return 'Buffer'; - } - const tagType = getObjectType(value); - if (tagType) { - return tagType; - } - if (value instanceof String || value instanceof Boolean || value instanceof Number) { - throw new TypeError('Please don\'t use object wrappers for primitive types'); - } - return 'Object'; -} -is.undefined = isOfType('undefined'); -is.string = isOfType('string'); -const isNumberType = isOfType('number'); -is.number = (value) => isNumberType(value) && !is.nan(value); -is.bigint = isOfType('bigint'); -// eslint-disable-next-line @typescript-eslint/ban-types -is.function_ = isOfType('function'); -// eslint-disable-next-line @typescript-eslint/ban-types -is.null_ = (value) => value === null; -is.class_ = (value) => is.function_(value) && value.toString().startsWith('class '); -is.boolean = (value) => value === true || value === false; -is.symbol = isOfType('symbol'); -is.numericString = (value) => is.string(value) && !is.emptyStringOrWhitespace(value) && !Number.isNaN(Number(value)); -is.array = (value, assertion) => { - if (!Array.isArray(value)) { - return false; - } - if (!is.function_(assertion)) { - return true; - } - return value.every(element => assertion(element)); -}; -// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call -is.buffer = (value) => value?.constructor?.isBuffer?.(value) ?? false; -is.blob = (value) => isObjectOfType('Blob')(value); -is.nullOrUndefined = (value) => is.null_(value) || is.undefined(value); // eslint-disable-line @typescript-eslint/ban-types -is.object = (value) => !is.null_(value) && (typeof value === 'object' || is.function_(value)); // eslint-disable-line @typescript-eslint/ban-types -is.iterable = (value) => is.function_(value?.[Symbol.iterator]); -is.asyncIterable = (value) => is.function_(value?.[Symbol.asyncIterator]); -is.generator = (value) => is.iterable(value) && is.function_(value?.next) && is.function_(value?.throw); -is.asyncGenerator = (value) => is.asyncIterable(value) && is.function_(value.next) && is.function_(value.throw); -is.nativePromise = (value) => isObjectOfType('Promise')(value); -const hasPromiseApi = (value) => is.function_(value?.then) - && is.function_(value?.catch); -is.promise = (value) => is.nativePromise(value) || hasPromiseApi(value); -is.generatorFunction = isObjectOfType('GeneratorFunction'); -is.asyncGeneratorFunction = (value) => getObjectType(value) === 'AsyncGeneratorFunction'; -is.asyncFunction = (value) => getObjectType(value) === 'AsyncFunction'; -// eslint-disable-next-line no-prototype-builtins, @typescript-eslint/ban-types -is.boundFunction = (value) => is.function_(value) && !value.hasOwnProperty('prototype'); -is.regExp = isObjectOfType('RegExp'); -is.date = isObjectOfType('Date'); -is.error = isObjectOfType('Error'); -is.map = (value) => isObjectOfType('Map')(value); -is.set = (value) => isObjectOfType('Set')(value); -is.weakMap = (value) => isObjectOfType('WeakMap')(value); // eslint-disable-line @typescript-eslint/ban-types -is.weakSet = (value) => isObjectOfType('WeakSet')(value); // eslint-disable-line @typescript-eslint/ban-types -is.weakRef = (value) => isObjectOfType('WeakRef')(value); // eslint-disable-line @typescript-eslint/ban-types -is.int8Array = isObjectOfType('Int8Array'); -is.uint8Array = isObjectOfType('Uint8Array'); -is.uint8ClampedArray = isObjectOfType('Uint8ClampedArray'); -is.int16Array = isObjectOfType('Int16Array'); -is.uint16Array = isObjectOfType('Uint16Array'); -is.int32Array = isObjectOfType('Int32Array'); -is.uint32Array = isObjectOfType('Uint32Array'); -is.float32Array = isObjectOfType('Float32Array'); -is.float64Array = isObjectOfType('Float64Array'); -is.bigInt64Array = isObjectOfType('BigInt64Array'); -is.bigUint64Array = isObjectOfType('BigUint64Array'); -is.arrayBuffer = isObjectOfType('ArrayBuffer'); -is.sharedArrayBuffer = isObjectOfType('SharedArrayBuffer'); -is.dataView = isObjectOfType('DataView'); -is.enumCase = (value, targetEnum) => Object.values(targetEnum).includes(value); -is.directInstanceOf = (instance, class_) => Object.getPrototypeOf(instance) === class_.prototype; -is.urlInstance = (value) => isObjectOfType('URL')(value); -is.urlString = (value) => { - if (!is.string(value)) { - return false; - } - try { - new URL(value); // eslint-disable-line no-new - return true; - } - catch { - return false; - } -}; -// Example: `is.truthy = (value: unknown): value is (not false | not 0 | not '' | not undefined | not null) => Boolean(value);` -is.truthy = (value) => Boolean(value); // eslint-disable-line unicorn/prefer-native-coercion-functions -// Example: `is.falsy = (value: unknown): value is (not true | 0 | '' | undefined | null) => Boolean(value);` -is.falsy = (value) => !value; -is.nan = (value) => Number.isNaN(value); -is.primitive = (value) => is.null_(value) || isPrimitiveTypeName(typeof value); -is.integer = (value) => Number.isInteger(value); -is.safeInteger = (value) => Number.isSafeInteger(value); -is.plainObject = (value) => { - // From: https://github.com/sindresorhus/is-plain-obj/blob/main/index.js - if (typeof value !== 'object' || value === null) { - return false; - } - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment - const prototype = Object.getPrototypeOf(value); - return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in value) && !(Symbol.iterator in value); -}; -is.typedArray = (value) => isTypedArrayName(getObjectType(value)); -const isValidLength = (value) => is.safeInteger(value) && value >= 0; -is.arrayLike = (value) => !is.nullOrUndefined(value) && !is.function_(value) && isValidLength(value.length); -is.inRange = (value, range) => { - if (is.number(range)) { - return value >= Math.min(0, range) && value <= Math.max(range, 0); - } - if (is.array(range) && range.length === 2) { - return value >= Math.min(...range) && value <= Math.max(...range); - } - throw new TypeError(`Invalid range: ${JSON.stringify(range)}`); -}; -// eslint-disable-next-line @typescript-eslint/naming-convention -const NODE_TYPE_ELEMENT = 1; -// eslint-disable-next-line @typescript-eslint/naming-convention -const DOM_PROPERTIES_TO_CHECK = [ - 'innerHTML', - 'ownerDocument', - 'style', - 'attributes', - 'nodeValue', -]; -is.domElement = (value) => is.object(value) - && value.nodeType === NODE_TYPE_ELEMENT - && is.string(value.nodeName) - && !is.plainObject(value) - && DOM_PROPERTIES_TO_CHECK.every(property => property in value); -is.observable = (value) => { - if (!value) { - return false; - } - // eslint-disable-next-line no-use-extend-native/no-use-extend-native, @typescript-eslint/no-unsafe-call - if (value === value[Symbol.observable]?.()) { - return true; - } - // eslint-disable-next-line @typescript-eslint/no-unsafe-call - if (value === value['@@observable']?.()) { - return true; - } - return false; -}; -is.nodeStream = (value) => is.object(value) && is.function_(value.pipe) && !is.observable(value); -is.infinite = (value) => value === Number.POSITIVE_INFINITY || value === Number.NEGATIVE_INFINITY; -const isAbsoluteMod2 = (remainder) => (value) => is.integer(value) && Math.abs(value % 2) === remainder; -is.evenInteger = isAbsoluteMod2(0); -is.oddInteger = isAbsoluteMod2(1); -is.emptyArray = (value) => is.array(value) && value.length === 0; -is.nonEmptyArray = (value) => is.array(value) && value.length > 0; -is.emptyString = (value) => is.string(value) && value.length === 0; -const isWhiteSpaceString = (value) => is.string(value) && !/\S/.test(value); -is.emptyStringOrWhitespace = (value) => is.emptyString(value) || isWhiteSpaceString(value); -// TODO: Use `not ''` when the `not` operator is available. -is.nonEmptyString = (value) => is.string(value) && value.length > 0; -// TODO: Use `not ''` when the `not` operator is available. -is.nonEmptyStringAndNotWhitespace = (value) => is.string(value) && !is.emptyStringOrWhitespace(value); -// eslint-disable-next-line unicorn/no-array-callback-reference -is.emptyObject = (value) => is.object(value) && !is.map(value) && !is.set(value) && Object.keys(value).length === 0; -// TODO: Use `not` operator here to remove `Map` and `Set` from type guard: -// - https://github.com/Microsoft/TypeScript/pull/29317 -// eslint-disable-next-line unicorn/no-array-callback-reference -is.nonEmptyObject = (value) => is.object(value) && !is.map(value) && !is.set(value) && Object.keys(value).length > 0; -is.emptySet = (value) => is.set(value) && value.size === 0; -is.nonEmptySet = (value) => is.set(value) && value.size > 0; -// eslint-disable-next-line unicorn/no-array-callback-reference -is.emptyMap = (value) => is.map(value) && value.size === 0; -// eslint-disable-next-line unicorn/no-array-callback-reference -is.nonEmptyMap = (value) => is.map(value) && value.size > 0; -// `PropertyKey` is any value that can be used as an object key (string, number, or symbol) -is.propertyKey = (value) => is.any([is.string, is.number, is.symbol], value); -is.formData = (value) => isObjectOfType('FormData')(value); -is.urlSearchParams = (value) => isObjectOfType('URLSearchParams')(value); -const predicateOnArray = (method, predicate, values) => { - if (!is.function_(predicate)) { - throw new TypeError(`Invalid predicate: ${JSON.stringify(predicate)}`); - } - if (values.length === 0) { - throw new TypeError('Invalid number of values'); - } - return method.call(values, predicate); -}; -is.any = (predicate, ...values) => { - const predicates = is.array(predicate) ? predicate : [predicate]; - return predicates.some(singlePredicate => predicateOnArray(Array.prototype.some, singlePredicate, values)); -}; -is.all = (predicate, ...values) => predicateOnArray(Array.prototype.every, predicate, values); -const assertType = (condition, description, value, options = {}) => { - if (!condition) { - const { multipleValues } = options; - const valuesMessage = multipleValues - ? `received values of types ${[ - ...new Set(value.map(singleValue => `\`${is(singleValue)}\``)), - ].join(', ')}` - : `received value of type \`${is(value)}\``; - throw new TypeError(`Expected value which is \`${description}\`, ${valuesMessage}.`); - } -}; -/* eslint-disable @typescript-eslint/no-confusing-void-expression */ -export const assert = { - // Unknowns. - undefined: (value) => assertType(is.undefined(value), 'undefined', value), - string: (value) => assertType(is.string(value), 'string', value), - number: (value) => assertType(is.number(value), 'number', value), - bigint: (value) => assertType(is.bigint(value), 'bigint', value), - // eslint-disable-next-line @typescript-eslint/ban-types - function_: (value) => assertType(is.function_(value), 'Function', value), - null_: (value) => assertType(is.null_(value), 'null', value), - class_: (value) => assertType(is.class_(value), "Class" /* AssertionTypeDescription.class_ */, value), - boolean: (value) => assertType(is.boolean(value), 'boolean', value), - symbol: (value) => assertType(is.symbol(value), 'symbol', value), - numericString: (value) => assertType(is.numericString(value), "string with a number" /* AssertionTypeDescription.numericString */, value), - array: (value, assertion) => { - const assert = assertType; - assert(is.array(value), 'Array', value); - if (assertion) { - // eslint-disable-next-line unicorn/no-array-for-each, unicorn/no-array-callback-reference - value.forEach(assertion); - } - }, - buffer: (value) => assertType(is.buffer(value), 'Buffer', value), - blob: (value) => assertType(is.blob(value), 'Blob', value), - nullOrUndefined: (value) => assertType(is.nullOrUndefined(value), "null or undefined" /* AssertionTypeDescription.nullOrUndefined */, value), - object: (value) => assertType(is.object(value), 'Object', value), - iterable: (value) => assertType(is.iterable(value), "Iterable" /* AssertionTypeDescription.iterable */, value), - asyncIterable: (value) => assertType(is.asyncIterable(value), "AsyncIterable" /* AssertionTypeDescription.asyncIterable */, value), - generator: (value) => assertType(is.generator(value), 'Generator', value), - asyncGenerator: (value) => assertType(is.asyncGenerator(value), 'AsyncGenerator', value), - nativePromise: (value) => assertType(is.nativePromise(value), "native Promise" /* AssertionTypeDescription.nativePromise */, value), - promise: (value) => assertType(is.promise(value), 'Promise', value), - generatorFunction: (value) => assertType(is.generatorFunction(value), 'GeneratorFunction', value), - asyncGeneratorFunction: (value) => assertType(is.asyncGeneratorFunction(value), 'AsyncGeneratorFunction', value), - // eslint-disable-next-line @typescript-eslint/ban-types - asyncFunction: (value) => assertType(is.asyncFunction(value), 'AsyncFunction', value), - // eslint-disable-next-line @typescript-eslint/ban-types - boundFunction: (value) => assertType(is.boundFunction(value), 'Function', value), - regExp: (value) => assertType(is.regExp(value), 'RegExp', value), - date: (value) => assertType(is.date(value), 'Date', value), - error: (value) => assertType(is.error(value), 'Error', value), - map: (value) => assertType(is.map(value), 'Map', value), - set: (value) => assertType(is.set(value), 'Set', value), - weakMap: (value) => assertType(is.weakMap(value), 'WeakMap', value), - weakSet: (value) => assertType(is.weakSet(value), 'WeakSet', value), - weakRef: (value) => assertType(is.weakRef(value), 'WeakRef', value), - int8Array: (value) => assertType(is.int8Array(value), 'Int8Array', value), - uint8Array: (value) => assertType(is.uint8Array(value), 'Uint8Array', value), - uint8ClampedArray: (value) => assertType(is.uint8ClampedArray(value), 'Uint8ClampedArray', value), - int16Array: (value) => assertType(is.int16Array(value), 'Int16Array', value), - uint16Array: (value) => assertType(is.uint16Array(value), 'Uint16Array', value), - int32Array: (value) => assertType(is.int32Array(value), 'Int32Array', value), - uint32Array: (value) => assertType(is.uint32Array(value), 'Uint32Array', value), - float32Array: (value) => assertType(is.float32Array(value), 'Float32Array', value), - float64Array: (value) => assertType(is.float64Array(value), 'Float64Array', value), - bigInt64Array: (value) => assertType(is.bigInt64Array(value), 'BigInt64Array', value), - bigUint64Array: (value) => assertType(is.bigUint64Array(value), 'BigUint64Array', value), - arrayBuffer: (value) => assertType(is.arrayBuffer(value), 'ArrayBuffer', value), - sharedArrayBuffer: (value) => assertType(is.sharedArrayBuffer(value), 'SharedArrayBuffer', value), - dataView: (value) => assertType(is.dataView(value), 'DataView', value), - enumCase: (value, targetEnum) => assertType(is.enumCase(value, targetEnum), 'EnumCase', value), - urlInstance: (value) => assertType(is.urlInstance(value), 'URL', value), - urlString: (value) => assertType(is.urlString(value), "string with a URL" /* AssertionTypeDescription.urlString */, value), - truthy: (value) => assertType(is.truthy(value), "truthy" /* AssertionTypeDescription.truthy */, value), - falsy: (value) => assertType(is.falsy(value), "falsy" /* AssertionTypeDescription.falsy */, value), - nan: (value) => assertType(is.nan(value), "NaN" /* AssertionTypeDescription.nan */, value), - primitive: (value) => assertType(is.primitive(value), "primitive" /* AssertionTypeDescription.primitive */, value), - integer: (value) => assertType(is.integer(value), "integer" /* AssertionTypeDescription.integer */, value), - safeInteger: (value) => assertType(is.safeInteger(value), "integer" /* AssertionTypeDescription.safeInteger */, value), - plainObject: (value) => assertType(is.plainObject(value), "plain object" /* AssertionTypeDescription.plainObject */, value), - typedArray: (value) => assertType(is.typedArray(value), "TypedArray" /* AssertionTypeDescription.typedArray */, value), - arrayLike: (value) => assertType(is.arrayLike(value), "array-like" /* AssertionTypeDescription.arrayLike */, value), - domElement: (value) => assertType(is.domElement(value), "HTMLElement" /* AssertionTypeDescription.domElement */, value), - observable: (value) => assertType(is.observable(value), 'Observable', value), - nodeStream: (value) => assertType(is.nodeStream(value), "Node.js Stream" /* AssertionTypeDescription.nodeStream */, value), - infinite: (value) => assertType(is.infinite(value), "infinite number" /* AssertionTypeDescription.infinite */, value), - emptyArray: (value) => assertType(is.emptyArray(value), "empty array" /* AssertionTypeDescription.emptyArray */, value), - nonEmptyArray: (value) => assertType(is.nonEmptyArray(value), "non-empty array" /* AssertionTypeDescription.nonEmptyArray */, value), - emptyString: (value) => assertType(is.emptyString(value), "empty string" /* AssertionTypeDescription.emptyString */, value), - emptyStringOrWhitespace: (value) => assertType(is.emptyStringOrWhitespace(value), "empty string or whitespace" /* AssertionTypeDescription.emptyStringOrWhitespace */, value), - nonEmptyString: (value) => assertType(is.nonEmptyString(value), "non-empty string" /* AssertionTypeDescription.nonEmptyString */, value), - nonEmptyStringAndNotWhitespace: (value) => assertType(is.nonEmptyStringAndNotWhitespace(value), "non-empty string and not whitespace" /* AssertionTypeDescription.nonEmptyStringAndNotWhitespace */, value), - emptyObject: (value) => assertType(is.emptyObject(value), "empty object" /* AssertionTypeDescription.emptyObject */, value), - nonEmptyObject: (value) => assertType(is.nonEmptyObject(value), "non-empty object" /* AssertionTypeDescription.nonEmptyObject */, value), - emptySet: (value) => assertType(is.emptySet(value), "empty set" /* AssertionTypeDescription.emptySet */, value), - nonEmptySet: (value) => assertType(is.nonEmptySet(value), "non-empty set" /* AssertionTypeDescription.nonEmptySet */, value), - emptyMap: (value) => assertType(is.emptyMap(value), "empty map" /* AssertionTypeDescription.emptyMap */, value), - nonEmptyMap: (value) => assertType(is.nonEmptyMap(value), "non-empty map" /* AssertionTypeDescription.nonEmptyMap */, value), - propertyKey: (value) => assertType(is.propertyKey(value), 'PropertyKey', value), - formData: (value) => assertType(is.formData(value), 'FormData', value), - urlSearchParams: (value) => assertType(is.urlSearchParams(value), 'URLSearchParams', value), - // Numbers. - evenInteger: (value) => assertType(is.evenInteger(value), "even integer" /* AssertionTypeDescription.evenInteger */, value), - oddInteger: (value) => assertType(is.oddInteger(value), "odd integer" /* AssertionTypeDescription.oddInteger */, value), - // Two arguments. - directInstanceOf: (instance, class_) => assertType(is.directInstanceOf(instance, class_), "T" /* AssertionTypeDescription.directInstanceOf */, instance), - inRange: (value, range) => assertType(is.inRange(value, range), "in range" /* AssertionTypeDescription.inRange */, value), - // Variadic functions. - any: (predicate, ...values) => assertType(is.any(predicate, ...values), "predicate returns truthy for any value" /* AssertionTypeDescription.any */, values, { multipleValues: true }), - all: (predicate, ...values) => assertType(is.all(predicate, ...values), "predicate returns truthy for all values" /* AssertionTypeDescription.all */, values, { multipleValues: true }), -}; -/* eslint-enable @typescript-eslint/no-confusing-void-expression */ -// Some few keywords are reserved, but we'll populate them for Node.js users -// See https://github.com/Microsoft/TypeScript/issues/2536 -Object.defineProperties(is, { - class: { - value: is.class_, - }, - function: { - value: is.function_, - }, - null: { - value: is.null_, - }, -}); -Object.defineProperties(assert, { - class: { - value: assert.class_, - }, - function: { - value: assert.function_, - }, - null: { - value: assert.null_, - }, -}); -export default is; diff --git a/includes/external/addressbook/node_modules/@sindresorhus/is/dist/types.d.ts b/includes/external/addressbook/node_modules/@sindresorhus/is/dist/types.d.ts deleted file mode 100644 index add7d48..0000000 --- a/includes/external/addressbook/node_modules/@sindresorhus/is/dist/types.d.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** -Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive). -*/ -export declare type Primitive = null | undefined | string | number | boolean | symbol | bigint; -/** -Matches a [`class` constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes). -*/ -export declare type Class = new (...arguments_: Arguments) => T; -/** -Matches any [typed array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray), like `Uint8Array` or `Float64Array`. -*/ -export declare type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array; -declare global { - interface SymbolConstructor { - readonly observable: symbol; - } -} -/** -Matches a value that is like an [Observable](https://github.com/tc39/proposal-observable). -*/ -export interface ObservableLike { - subscribe(observer: (value: unknown) => void): void; - [Symbol.observable](): ObservableLike; -} -export declare type Falsy = false | 0 | 0n | '' | null | undefined; -export interface WeakRef { - readonly [Symbol.toStringTag]: 'WeakRef'; - deref(): T | undefined; -} diff --git a/includes/external/addressbook/node_modules/@sindresorhus/is/dist/types.js b/includes/external/addressbook/node_modules/@sindresorhus/is/dist/types.js deleted file mode 100644 index 584792b..0000000 --- a/includes/external/addressbook/node_modules/@sindresorhus/is/dist/types.js +++ /dev/null @@ -1,2 +0,0 @@ -// Extracted from https://github.com/sindresorhus/type-fest/blob/78019f42ea888b0cdceb41a4a78163868de57555/index.d.ts -export {}; diff --git a/includes/external/addressbook/node_modules/@sindresorhus/is/license b/includes/external/addressbook/node_modules/@sindresorhus/is/license deleted file mode 100644 index fa7ceba..0000000 --- a/includes/external/addressbook/node_modules/@sindresorhus/is/license +++ /dev/null @@ -1,9 +0,0 @@ -MIT License - -Copyright (c) Sindre Sorhus (https://sindresorhus.com) - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/includes/external/addressbook/node_modules/@sindresorhus/is/package.json b/includes/external/addressbook/node_modules/@sindresorhus/is/package.json deleted file mode 100644 index 3c029c5..0000000 --- a/includes/external/addressbook/node_modules/@sindresorhus/is/package.json +++ /dev/null @@ -1,82 +0,0 @@ -{ - "name": "@sindresorhus/is", - "version": "5.3.0", - "description": "Type check values", - "license": "MIT", - "repository": "sindresorhus/is", - "funding": "https://github.com/sindresorhus/is?sponsor=1", - "author": { - "name": "Sindre Sorhus", - "email": "sindresorhus@gmail.com", - "url": "https://sindresorhus.com" - }, - "type": "module", - "exports": "./dist/index.js", - "types": "./dist/index.d.ts", - "engines": { - "node": ">=14.16" - }, - "scripts": { - "build": "del dist && tsc", - "test": "xo && ava", - "prepare": "npm run build" - }, - "files": [ - "dist" - ], - "keywords": [ - "type", - "types", - "is", - "check", - "checking", - "validate", - "validation", - "utility", - "util", - "typeof", - "instanceof", - "object", - "assert", - "assertion", - "test", - "kind", - "primitive", - "verify", - "compare", - "typescript", - "typeguards", - "types" - ], - "devDependencies": { - "@sindresorhus/tsconfig": "^3.0.1", - "@types/jsdom": "^16.2.15", - "@types/node": "^18.0.6", - "@types/zen-observable": "^0.8.3", - "ava": "^4.3.1", - "del-cli": "^5.0.0", - "jsdom": "^20.0.0", - "rxjs": "^7.5.6", - "tempy": "^3.0.0", - "ts-node": "^10.9.1", - "typescript": "~4.7.4", - "xo": "^0.51.0", - "zen-observable": "^0.8.15" - }, - "sideEffects": false, - "ava": { - "extensions": { - "ts": "module" - }, - "nodeArguments": [ - "--loader=ts-node/esm" - ] - }, - "xo": { - "rules": { - "@typescript-eslint/no-empty-function": "off", - "@typescript-eslint/explicit-function-return-type": "off", - "@typescript-eslint/triple-slash-reference": "off" - } - } -} diff --git a/includes/external/addressbook/node_modules/@sindresorhus/is/readme.md b/includes/external/addressbook/node_modules/@sindresorhus/is/readme.md deleted file mode 100644 index a517379..0000000 --- a/includes/external/addressbook/node_modules/@sindresorhus/is/readme.md +++ /dev/null @@ -1,670 +0,0 @@ -# is - -> Type check values - -For example, `is.string('🦄') //=> true` - - - -## Highlights - -- Written in TypeScript -- [Extensive use of type guards](#type-guards) -- [Supports type assertions](#type-assertions) -- [Aware of generic type parameters](#generic-type-parameters) (use with caution) -- Actively maintained -- ![Millions of downloads per week](https://img.shields.io/npm/dw/@sindresorhus/is) - -## Install - -```sh -npm install @sindresorhus/is -``` - -## Usage - -```js -import is from '@sindresorhus/is'; - -is('🦄'); -//=> 'string' - -is(new Map()); -//=> 'Map' - -is.number(6); -//=> true -``` - -[Assertions](#type-assertions) perform the same type checks, but throw an error if the type does not match. - -```js -import {assert} from '@sindresorhus/is'; - -assert.string(2); -//=> Error: Expected value which is `string`, received value of type `number`. -``` - -And with TypeScript: - -```ts -import {assert} from '@sindresorhus/is'; - -assert.string(foo); -// `foo` is now typed as a `string`. -``` - -## API - -### is(value) - -Returns the type of `value`. - -Primitives are lowercase and object types are camelcase. - -Example: - -- `'undefined'` -- `'null'` -- `'string'` -- `'symbol'` -- `'Array'` -- `'Function'` -- `'Object'` - -Note: It will throw an error if you try to feed it object-wrapped primitives, as that's a bad practice. For example `new String('foo')`. - -### is.{method} - -All the below methods accept a value and returns a boolean for whether the value is of the desired type. - -#### Primitives - -##### .undefined(value) -##### .null(value) - -**Note:** TypeScript users must use `.null_()` because of a TypeScript naming limitation. - -##### .string(value) -##### .number(value) - -Note: `is.number(NaN)` returns `false`. This intentionally deviates from `typeof` behavior to increase user-friendliness of `is` type checks. - -##### .boolean(value) -##### .symbol(value) -##### .bigint(value) - -#### Built-in types - -##### .array(value, assertion?) - -Returns true if `value` is an array and all of its items match the assertion (if provided). - -```js -is.array(value); // Validate `value` is an array. -is.array(value, is.number); // Validate `value` is an array and all of its items are numbers. -``` - -##### .function(value) - -**Note:** TypeScript users must use `.function_()` because of a TypeScript naming limitation. - -##### .buffer(value) -##### .blob(value) -##### .object(value) - -Keep in mind that [functions are objects too](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions). - -##### .numericString(value) - -Returns `true` for a string that represents a number satisfying `is.number`, for example, `'42'` and `'-8.3'`. - -Note: `'NaN'` returns `false`, but `'Infinity'` and `'-Infinity'` return `true`. - -##### .regExp(value) -##### .date(value) -##### .error(value) -##### .nativePromise(value) -##### .promise(value) - -Returns `true` for any object with a `.then()` and `.catch()` method. Prefer this one over `.nativePromise()` as you usually want to allow userland promise implementations too. - -##### .generator(value) - -Returns `true` for any object that implements its own `.next()` and `.throw()` methods and has a function definition for `Symbol.iterator`. - -##### .generatorFunction(value) - -##### .asyncFunction(value) - -Returns `true` for any `async` function that can be called with the `await` operator. - -```js -is.asyncFunction(async () => {}); -//=> true - -is.asyncFunction(() => {}); -//=> false -``` - -##### .asyncGenerator(value) - -```js -is.asyncGenerator( - (async function * () { - yield 4; - })() -); -//=> true - -is.asyncGenerator( - (function * () { - yield 4; - })() -); -//=> false -``` - -##### .asyncGeneratorFunction(value) - -```js -is.asyncGeneratorFunction(async function * () { - yield 4; -}); -//=> true - -is.asyncGeneratorFunction(function * () { - yield 4; -}); -//=> false -``` - -##### .boundFunction(value) - -Returns `true` for any `bound` function. - -```js -is.boundFunction(() => {}); -//=> true - -is.boundFunction(function () {}.bind(null)); -//=> true - -is.boundFunction(function () {}); -//=> false -``` - -##### .map(value) -##### .set(value) -##### .weakMap(value) -##### .weakSet(value) -##### .weakRef(value) - -#### Typed arrays - -##### .int8Array(value) -##### .uint8Array(value) -##### .uint8ClampedArray(value) -##### .int16Array(value) -##### .uint16Array(value) -##### .int32Array(value) -##### .uint32Array(value) -##### .float32Array(value) -##### .float64Array(value) -##### .bigInt64Array(value) -##### .bigUint64Array(value) - -#### Structured data - -##### .arrayBuffer(value) -##### .sharedArrayBuffer(value) -##### .dataView(value) - -##### .enumCase(value, enum) - -TypeScript-only. Returns `true` if `value` is a member of `enum`. - -```ts -enum Direction { - Ascending = 'ascending', - Descending = 'descending' -} - -is.enumCase('ascending', Direction); -//=> true - -is.enumCase('other', Direction); -//=> false -``` - -#### Emptiness - -##### .emptyString(value) - -Returns `true` if the value is a `string` and the `.length` is 0. - -##### .emptyStringOrWhitespace(value) - -Returns `true` if `is.emptyString(value)` or if it's a `string` that is all whitespace. - -##### .nonEmptyString(value) - -Returns `true` if the value is a `string` and the `.length` is more than 0. - -##### .nonEmptyStringAndNotWhitespace(value) - -Returns `true` if the value is a `string` that is not empty and not whitespace. - -```js -const values = ['property1', '', null, 'property2', ' ', undefined]; - -values.filter(is.nonEmptyStringAndNotWhitespace); -//=> ['property1', 'property2'] -``` - -##### .emptyArray(value) - -Returns `true` if the value is an `Array` and the `.length` is 0. - -##### .nonEmptyArray(value) - -Returns `true` if the value is an `Array` and the `.length` is more than 0. - -##### .emptyObject(value) - -Returns `true` if the value is an `Object` and `Object.keys(value).length` is 0. - -Please note that `Object.keys` returns only own enumerable properties. Hence something like this can happen: - -```js -const object1 = {}; - -Object.defineProperty(object1, 'property1', { - value: 42, - writable: true, - enumerable: false, - configurable: true -}); - -is.emptyObject(object1); -//=> true -``` - -##### .nonEmptyObject(value) - -Returns `true` if the value is an `Object` and `Object.keys(value).length` is more than 0. - -##### .emptySet(value) - -Returns `true` if the value is a `Set` and the `.size` is 0. - -##### .nonEmptySet(Value) - -Returns `true` if the value is a `Set` and the `.size` is more than 0. - -##### .emptyMap(value) - -Returns `true` if the value is a `Map` and the `.size` is 0. - -##### .nonEmptyMap(value) - -Returns `true` if the value is a `Map` and the `.size` is more than 0. - -#### Miscellaneous - -##### .directInstanceOf(value, class) - -Returns `true` if `value` is a direct instance of `class`. - -```js -is.directInstanceOf(new Error(), Error); -//=> true - -class UnicornError extends Error {} - -is.directInstanceOf(new UnicornError(), Error); -//=> false -``` - -##### .urlInstance(value) - -Returns `true` if `value` is an instance of the [`URL` class](https://developer.mozilla.org/en-US/docs/Web/API/URL). - -```js -const url = new URL('https://example.com'); - -is.urlInstance(url); -//=> true -``` - -##### .urlString(value) - -Returns `true` if `value` is a URL string. - -Note: this only does basic checking using the [`URL` class](https://developer.mozilla.org/en-US/docs/Web/API/URL) constructor. - -```js -const url = 'https://example.com'; - -is.urlString(url); -//=> true - -is.urlString(new URL(url)); -//=> false -``` - -##### .truthy(value) - -Returns `true` for all values that evaluate to true in a boolean context: - -```js -is.truthy('🦄'); -//=> true - -is.truthy(undefined); -//=> false -``` - -##### .falsy(value) - -Returns `true` if `value` is one of: `false`, `0`, `''`, `null`, `undefined`, `NaN`. - -##### .nan(value) -##### .nullOrUndefined(value) -##### .primitive(value) - -JavaScript primitives are as follows: `null`, `undefined`, `string`, `number`, `boolean`, `symbol`. - -##### .integer(value) - -##### .safeInteger(value) - -Returns `true` if `value` is a [safe integer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger). - -##### .plainObject(value) - -An object is plain if it's created by either `{}`, `new Object()`, or `Object.create(null)`. - -##### .iterable(value) -##### .asyncIterable(value) -##### .class(value) - -Returns `true` for instances created by a class. - -**Note:** TypeScript users must use `.class_()` because of a TypeScript naming limitation. - -##### .typedArray(value) - -##### .arrayLike(value) - -A `value` is array-like if it is not a function and has a `value.length` that is a safe integer greater than or equal to 0. - -```js -is.arrayLike(document.forms); -//=> true - -function foo() { - is.arrayLike(arguments); - //=> true -} -foo(); -``` - -##### .inRange(value, range) - -Check if `value` (number) is in the given `range`. The range is an array of two values, lower bound and upper bound, in no specific order. - -```js -is.inRange(3, [0, 5]); -is.inRange(3, [5, 0]); -is.inRange(0, [-2, 2]); -``` - -##### .inRange(value, upperBound) - -Check if `value` (number) is in the range of `0` to `upperBound`. - -```js -is.inRange(3, 10); -``` - -##### .domElement(value) - -Returns `true` if `value` is a DOM Element. - -##### .nodeStream(value) - -Returns `true` if `value` is a Node.js [stream](https://nodejs.org/api/stream.html). - -```js -import fs from 'node:fs'; - -is.nodeStream(fs.createReadStream('unicorn.png')); -//=> true -``` - -##### .observable(value) - -Returns `true` if `value` is an `Observable`. - -```js -import {Observable} from 'rxjs'; - -is.observable(new Observable()); -//=> true -``` - -##### .infinite(value) - -Check if `value` is `Infinity` or `-Infinity`. - -##### .evenInteger(value) - -Returns `true` if `value` is an even integer. - -##### .oddInteger(value) - -Returns `true` if `value` is an odd integer. - -##### .propertyKey(value) - -Returns `true` if `value` can be used as an object property key (either `string`, `number`, or `symbol`). - -##### .formData(value) - -Returns `true` if `value` is an instance of the [`FormData` class](https://developer.mozilla.org/en-US/docs/Web/API/FormData). - -```js -const data = new FormData(); - -is.formData(data); -//=> true -``` - -##### .urlSearchParams(value) - -Returns `true` if `value` is an instance of the [`URLSearchParams` class](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams). - -```js -const searchParams = new URLSearchParams(); - -is.urlSearchParams(searchParams); -//=> true -``` - -##### .any(predicate | predicate[], ...values) - -Using a single `predicate` argument, returns `true` if **any** of the input `values` returns true in the `predicate`: - -```js -is.any(is.string, {}, true, '🦄'); -//=> true - -is.any(is.boolean, 'unicorns', [], new Map()); -//=> false -``` - -Using an array of `predicate[]`, returns `true` if **any** of the input `values` returns true for **any** of the `predicates` provided in an array: - -```js -is.any([is.string, is.number], {}, true, '🦄'); -//=> true - -is.any([is.boolean, is.number], 'unicorns', [], new Map()); -//=> false -``` - -##### .all(predicate, ...values) - -Returns `true` if **all** of the input `values` returns true in the `predicate`: - -```js -is.all(is.object, {}, new Map(), new Set()); -//=> true - -is.all(is.string, '🦄', [], 'unicorns'); -//=> false -``` - -## Type guards - -When using `is` together with TypeScript, [type guards](http://www.typescriptlang.org/docs/handbook/advanced-types.html#type-guards-and-differentiating-types) are being used extensively to infer the correct type inside if-else statements. - -```ts -import is from '@sindresorhus/is'; - -const padLeft = (value: string, padding: string | number) => { - if (is.number(padding)) { - // `padding` is typed as `number` - return Array(padding + 1).join(' ') + value; - } - - if (is.string(padding)) { - // `padding` is typed as `string` - return padding + value; - } - - throw new TypeError(`Expected 'padding' to be of type 'string' or 'number', got '${is(padding)}'.`); -} - -padLeft('🦄', 3); -//=> ' 🦄' - -padLeft('🦄', '🌈'); -//=> '🌈🦄' -``` - -## Type assertions - -The type guards are also available as [type assertions](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#assertion-functions), which throw an error for unexpected types. It is a convenient one-line version of the often repetitive "if-not-expected-type-throw" pattern. - -```ts -import {assert} from '@sindresorhus/is'; - -const handleMovieRatingApiResponse = (response: unknown) => { - assert.plainObject(response); - // `response` is now typed as a plain `object` with `unknown` properties. - - assert.number(response.rating); - // `response.rating` is now typed as a `number`. - - assert.string(response.title); - // `response.title` is now typed as a `string`. - - return `${response.title} (${response.rating * 10})`; -}; - -handleMovieRatingApiResponse({rating: 0.87, title: 'The Matrix'}); -//=> 'The Matrix (8.7)' - -// This throws an error. -handleMovieRatingApiResponse({rating: '🦄'}); -``` - -## Generic type parameters - -The type guards and type assertions are aware of [generic type parameters](https://www.typescriptlang.org/docs/handbook/generics.html), such as `Promise` and `Map`. The default is `unknown` for most cases, since `is` cannot check them at runtime. If the generic type is known at compile-time, either implicitly (inferred) or explicitly (provided), `is` propagates the type so it can be used later. - -Use generic type parameters with caution. They are only checked by the TypeScript compiler, and not checked by `is` at runtime. This can lead to unexpected behavior, where the generic type is _assumed_ at compile-time, but actually is something completely different at runtime. It is best to use `unknown` (default) and type-check the value of the generic type parameter at runtime with `is` or `assert`. - -```ts -import {assert} from '@sindresorhus/is'; - -async function badNumberAssumption(input: unknown) { - // Bad assumption about the generic type parameter fools the compile-time type system. - assert.promise(input); - // `input` is a `Promise` but only assumed to be `Promise`. - - const resolved = await input; - // `resolved` is typed as `number` but was not actually checked at runtime. - - // Multiplication will return NaN if the input promise did not actually contain a number. - return 2 * resolved; -} - -async function goodNumberAssertion(input: unknown) { - assert.promise(input); - // `input` is typed as `Promise` - - const resolved = await input; - // `resolved` is typed as `unknown` - - assert.number(resolved); - // `resolved` is typed as `number` - - // Uses runtime checks so only numbers will reach the multiplication. - return 2 * resolved; -} - -badNumberAssumption(Promise.resolve('An unexpected string')); -//=> NaN - -// This correctly throws an error because of the unexpected string value. -goodNumberAssertion(Promise.resolve('An unexpected string')); -``` - -## FAQ - -### Why yet another type checking module? - -There are hundreds of type checking modules on npm, unfortunately, I couldn't find any that fit my needs: - -- Includes both type methods and ability to get the type -- Types of primitives returned as lowercase and object types as camelcase -- Covers all built-ins -- Unsurprising behavior -- Well-maintained -- Comprehensive test suite - -For the ones I found, pick 3 of these. - -The most common mistakes I noticed in these modules was using `instanceof` for type checking, forgetting that functions are objects, and omitting `symbol` as a primitive. - -### Why not just use `instanceof` instead of this package? - -`instanceof` does not work correctly for all types and it does not work across [realms](https://stackoverflow.com/a/49832343/64949). Examples of realms are iframes, windows, web workers, and the `vm` module in Node.js. - -## For enterprise - -Available as part of the Tidelift Subscription. - -The maintainers of @sindresorhus/is and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-sindresorhus-is?utm_source=npm-sindresorhus-is&utm_medium=referral&utm_campaign=enterprise&utm_term=repo) - -## Related - -- [ow](https://github.com/sindresorhus/ow) - Function argument validation for humans -- [is-stream](https://github.com/sindresorhus/is-stream) - Check if something is a Node.js stream -- [is-observable](https://github.com/sindresorhus/is-observable) - Check if a value is an Observable -- [file-type](https://github.com/sindresorhus/file-type) - Detect the file type of a Buffer/Uint8Array -- [is-ip](https://github.com/sindresorhus/is-ip) - Check if a string is an IP address -- [is-array-sorted](https://github.com/sindresorhus/is-array-sorted) - Check if an Array is sorted -- [is-error-constructor](https://github.com/sindresorhus/is-error-constructor) - Check if a value is an error constructor -- [is-empty-iterable](https://github.com/sindresorhus/is-empty-iterable) - Check if an Iterable is empty -- [is-blob](https://github.com/sindresorhus/is-blob) - Check if a value is a Blob - File-like object of immutable, raw data -- [has-emoji](https://github.com/sindresorhus/has-emoji) - Check whether a string has any emoji - -## Maintainers - -- [Sindre Sorhus](https://github.com/sindresorhus) -- [Giora Guttsait](https://github.com/gioragutt) -- [Brandon Smith](https://github.com/brandon93s) -- cgit