import type { Observable } from 'rxjs'; import type { Primative } from '../@types/index'; /** * 进行类型检测的常用手段包括: * - typeof: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof * https://tc39.es/ecma262/#sec-typeof-operator * - instanceof: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/instanceof * - toString: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString * * - `typeof` operator can operate on non-exist variable. */ export declare const isUndefined: (target: unknown) => target is undefined; /** * @see {@link https://stackoverflow.com/a/52097700} */ export declare const isDefined: (target: T) => target is T; export declare const isBoolean: (target: unknown) => target is boolean; export declare const isString: (target: unknown) => target is string; export declare const isNumber: (target: any) => target is number; export declare const isFiniteNumber: (target: unknown) => target is number; export declare const isInfiniteNumber: (target: unknown) => target is number; export declare const isNaN: (target: unknown) => boolean; export declare const isBigInt: (target: unknown) => target is bigint; export declare const isSymbol: (target: unknown) => target is symbol; export declare const isNull: (target: unknown) => target is null; export declare const isPrimative: (target: unknown) => target is Primative; export declare const isNonPrimative: (target: unknown) => target is object; /** * Predicate whether the targetget is a Object, use `instanceof` operator to check. * * @see {@link isGeneralObject}, {@link isPlainObject} */ export declare const isObject: (target: unknown) => target is Object; /** * Predicate whether the targetget is a general object, use `typeof` operator to check. * * A general object is an object that is: * - not `null`, not a `function`, not a `primitive`. * * Any other object is a general object: * - `Array` instance, `Map` instance, `WeakMap` instance, `Set` instance, `Date` instance, etc. * * @code * ``` * typeof null // => 'object' * typeof [] // => 'object' * typeof {} // => 'object' * typeof { a: 1 } // => 'object' * typeof (new Map()) // => 'object' * typeof (new WeakMap()) // => 'object' * typeof (new Set()) // => 'object' * typeof (new WeakSet()) // => 'object' * typeof (new Date()) // => 'object' * typeof window // => 'object' * typeof document // => 'object' * ``` * * @see {@link isObject}, {@link isPlainObject} */ export declare const isGeneralObject: (target: unknown) => target is Object; export interface PlainObject { [key: string]: any; [key: number]: any; [key: symbol]: any; } /** * Predicate whether the targetget is a plain object. * * A plain object is an object that is: * - not `null`, not a `function`, not a `primitive` type, * - not an `Array`, not a `RegExp`, not a `Date`, not a `Map`, not a `Set`, not a `WeakMap`, * - not `window`, not a DOM `element`, not an `Error`, * - not any other customize object type. * * @see {@link isObject}, {@link isGeneralObject} */ export declare const isPlainObject: (target: unknown) => target is PlainObject; /** * @see {@link Array.isArray} */ export declare function isArray(target: T[]): target is T[]; export declare function isArray(target: unknown): target is T[]; export declare function isArrayLike(target: ArrayLike): target is ArrayLike; export declare function isArrayLike(target: unknown): target is ArrayLike; export declare function isMap(target: Map): target is Map; export declare function isMap(target: unknown): target is Map; export declare function isWeakMap(target: WeakMap): target is WeakMap; export declare function isWeakMap(target: unknown): target is WeakMap; export declare function isSet(target: Set): target is Set; export declare function isSet(target: unknown): target is Set; export declare function isWeakSet(target: WeakSet): target is WeakSet; export declare function isWeakSet(target: unknown): target is WeakSet; export declare const isDate: (target: unknown) => target is Date; export declare const isRegExp: (target: unknown) => target is RegExp; export declare const isError: (target: unknown) => target is Error; export declare const isFunction: (target: unknown) => target is Function; export declare const isNormalFunction: (target: unknown) => target is Function; export declare const isAsyncFunction: (target: unknown) => target is Function; export declare const isGeneratorFunction: (target: unknown) => target is Function; export declare const isAsyncGeneratorFunction: (target: unknown) => target is Function; export declare function isPromise(target: Promise): target is Promise; export declare function isPromise(target: unknown): target is Promise; export declare const isEmptyString: (target: unknown) => target is ""; export declare const isEmptyArray: (target: unknown) => target is []; /** * @see {@link isEmptyObject} */ export declare const isEmptyPlainObject: (target: unknown) => target is PlainObject; /** * @see {@link isEmptyPlainObject}, {@link https://mannes.tech/typescript-object-type-errors/} */ export declare const isEmptyObject: (target: unknown) => target is {}; /** * - `null` and `undefined` are considered empty values * - `''` is the empty value for String * - `[]` is the empty value for Array * - `{}` is the empty value for PlainObject * - for other object types, they will be considered empty * when the value of their `isEmpty` property is true * * @see {@link isNull}, {@link isUndefined}, {@link isEmptyString}, {@link isEmptyArray}, {@link isEmptyObject} */ export declare const isEmpty: (target: any) => boolean; export declare const isNil: (target: unknown) => target is null | undefined; /** * Check `target` and `Window` is both defined * before use the `instanceof` operator to check `target` is instanceof `Window`. */ export declare const isWindow: (target: unknown) => target is Window; /** * Check `target` and `Element` is both defined * before use the `instanceof` operator to check `target` is instanceof `Element`. */ export declare const isElement: (target: unknown) => target is Element; /** * Check `target` and `Node` is both defined * before use the `instanceof` operator to check `target` is instanceof `Node`. */ export declare const isNode: (target: unknown) => target is Node; /** * Check `target` and `HTMLElement` is both defined * before use the `instanceof` operator to check `target` is instanceof `HTMLElement`. */ export declare const isHTMLElement: (target: unknown) => target is HTMLElement; /** * Check `target` and `HTMLCollection` is both defined * before use the `instanceof` operator to check `target` is instanceof `HTMLCollection`. */ export declare const isHTMLCollection: (target: unknown) => target is HTMLCollection; /** * Check `target` and `Document` is both defined * before use the `instanceof` operator to check `target` is instanceof `Document`. */ export declare const isDocument: (target: unknown) => target is Document; /** * Check `target` and `EventTarget` is both defined * before use the `instanceof` operator to check `target` is instanceof `EventTarget`. * * @see {@link https://developer.mozilla.org/zh-CN/docs/Web/API/Event} */ export declare const isEventTarget: (target: unknown) => target is EventTarget; /** * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_iterable_protocol} */ export declare function isIterable(target: Iterable): target is Iterable; export declare function isIterable(target: unknown): target is Iterable; /** * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/asyncIterator} */ export declare function isAsyncIterable(target: AsyncIterable): target is AsyncIterable; export declare function isAsyncIterable(target: unknown): target is AsyncIterable; /** * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_iterator_protocol} */ export declare function isIterator(target: Iterator): target is Iterator; export declare function isIterator(target: unknown): target is Iterator; export declare function isAsyncIterator(target: AsyncIterator): target is AsyncIterator; export declare function isAsyncIterator(target: unknown): target is AsyncIterator; export declare function isObservable(target: Observable): target is Observable; export declare function isObservable(target: unknown): target is Observable; export declare const asIs: (target: T, ...args: unknown[]) => T; export declare const asUndefined: (...target: unknown[]) => undefined; export declare const asNull: (...target: unknown[]) => null; export declare const asVoid: (...target: unknown[]) => void; //# sourceMappingURL=base.d.ts.map