type AnyRecord = Record; type Falsy = false | 0 | 0n | '' | null | undefined; type MaybePromise = T | Promise; type MaybePromiseLike = T | PromiseLike; type Promisable = T | PromiseLike; type Awaitable = T | PromiseLike; type MaybeNull = T | null; type Nullable = T | null; type NonNullable = Exclude; type MaybeUndefined = T | undefined; type Optional = T | undefined; type Undefinable = T | undefined; type NonUndefinable = Exclude; type Nullish = T | undefined | null; type NonNullish = Exclude; type MaybeArray = T | T[]; type Arrayable = T | T[]; type ElementOf = T extends (infer E)[] ? E : never; type Fn = () => T; type PromisifyFn = () => Promise>; type AnyFn = (...args: any[]) => T; type PromisifyAnyFn = (...args: Parameters) => Promise>; /** * Determines whether an array includes a certain element, returning true or false as appropriate. * * 确定数组是否包含某个元素,返回 true 或 false。 * * @param searchElement - The element to search for. * @param searchElement - 需要搜索的元素。 * @param fromIndex - The position in this array at which to begin searching for searchElement. * @param fromIndex - 开始搜索元素的位置。 */ declare function arrayIncludes(array: Type[] | readonly Type[], item: SuperType, fromIndex?: number): item is Type; /** * Convert value to an array. * * 将值转换成数组。 * * @example toArray() => [] * * @example toArray(undefined) => [] * * @example toArray(null) => [] * * @example toArray(1) => [1] * * @example toArray('abc') => ['abc'] * * @example toArray({ a: 1, b: 2 }) => [{ a: 1, b: 2 }] * * @example toArray([1, 2]) => [1, 2] * * @param value - The value to convert. * @param value - 需要转换的值。 */ declare function toArray(value?: Nullish>): T[]; /** * Find difference elements between two arrays. Pass a function to judge equation or fallback to * `Array#includes`. Return a new array. * * 找到两个数组中不同的元素。内部默认使用 `Array#includes` 判断相等性,你也可以传入一个自定义方法。返回一个新数组。 * * @example difference([1, '2'], [1]) => ['2'] * * @example difference([1, '2', {}], [1, {}]) => ['2', {}] * * @example difference([1, '2', { a: { b: 'c' } }], [1, { a: { b: 'c' } }]) => ['2', { a: { b: 'c' } * }] * * @example difference([1, '2', {}], [1, {}], isDeepEqual) => ['2'] * * @example difference([1, '2', { a: { b: 'c' } }], [1, { a: { b: 'c' } }], isDeepEqual) => ['2'] */ declare function difference(array1: T[], array2: T[], equalFn?: (value1: T, value2: T) => boolean): T[]; /** * Find same elements between two arrays. Pass a function to judge equation or fallback to * `Array#includes`. Return a new array. * * 找到两个数组中相同的元素。内部默认使用 `Array#includes` 判断相等性,你也可以传入一个自定义方法。返回一个新数组。 * * @example intersection([1, '2'], [1]) => [1] * * @example intersection([1, '2', {}], [1, {}]) => [1] * * @example intersection([1, '2', { a: { b: 'c' } }], [1, { a: { b: 'c' } }]) => [1] * * @example intersection([1, '2', {}], [1, {}], isDeepEqual) => [1, {}] * * @example intersection([1, '2', { a: { b: 'c' } }], [1, { a: { b: 'c' } }], isDeepEqual) => [1, { * a: { b: 'c' } }] */ declare function intersection(array1: T[], array2: T[], equalFn?: (value1: T, value2: T) => boolean): T[]; /** * Find unique elements. Pass a function to judge equation or fallback to `Set`. Return a new array. * * 数组去重。内部默认使用 `Array#includes` 判断相等性,你也可以传入一个自定义方法。返回一个新数组。 * * @example uniq([1, '2', 2, 2, '2']) => [1, '2', 2] * * @example uniq([1, '2', 2, 2, '2', {}, {}] => [1, '2', 2, {}, {}] * * @example uniq([1, '2', 2, 2, '2', {}, {}], isDeepEqual) => [1, '2', 2, {}] */ declare function uniq(array: T[], equalFn?: (value1: T, value2: T) => boolean): T[]; /** * Find all elements in two arrays. Use `uniq` under the hood. Return a new array. * * 找到两个数组所有不同元素。内部使用 `uniq`。返回一个新数组。 * * @example union([1, '2'], [1, 3]) => [1, '2', 3] * * @example union([1, '2', {}], [1, 3, {}]) => [1, '2', {}, 3, {}] * * @example union([1, '2', { a: { b: 'c' } }], [1, 3, { a: { b: 'c' } }]) => [1, '2', { a: { b: 'c' * } }, 3, { a: { b: 'c' } }] * * @example union([1, '2', {}], [1, 3, {}], isDeepEqual) => [1, '2', {}, 3] * * @example union([1, '2', { a: { b: 'c' } }], [1, 3, { a: { b: 'c' } }], isDeepEqual) => [1, '2', { * a: { b: 'c' } }, 3] */ declare function union(array1: T[], array2: T[], equalFn?: (value1: T, value2: T) => boolean): T[]; declare function range(end: number): number[]; declare function range(start: number, end: number): number[]; declare function range(start: number, end: number, step: number): number[]; /** * Get value type name. * * 获取值的类型名称。 * * @example getType(null) => 'Null' * * @example getType() => 'Undefined' * * @example getType(undefined) => 'Undefined' * * @example getType(true) => 'Boolean' * * @example getType(0) => 'Number' * * @example getType(0n) => 'BigInt' * * @example getType('') => 'String' * * @example getType({}) => 'Object' * * @example getType([]) => 'Array' */ declare function getType(value?: unknown): string; /** * Determine if a value is a string. * * 判断一个值是否为 string。 * * @example isString('') => true * * @example isString(0) => false * * @example isString(0n) => false * * @example isString(true) => false * * @example isString(undefined) => false * * @example isString(null) => false * * @example isString(Symbol()) => false * * @example isString({}) => false * * @example isString(() => {}) => false * * @example isString([]) => false */ declare function isString(value: unknown): value is string; /** * Determine if a value is a number. * * 判断一个值是否为 number。 * * @example isNumber('') => false * * @example isNumber(0) => true * * @example isNumber(0n) => false * * @example isNumber(true) => false * * @example isNumber(undefined) => false * * @example isNumber(null) => false * * @example isNumber(Symbol()) => false * * @example isNumber({}) => false * * @example isNumber(() => {}) => false * * @example isNumber([]) => false */ declare function isNumber(value: unknown): value is number; /** * Determine if a value is a bigint. * * 判断一个值是否为 bigint。 * * @example isBigInt('') => false * * @example isBigInt(0) => false * * @example isBigInt(0n) => true * * @example isBigInt(true) => false * * @example isBigInt(undefined) => false * * @example isBigInt(null) => false * * @example isBigInt(Symbol()) => false * * @example isBigInt({}) => false * * @example isBigInt(() => {}) => false * * @example isBigInt([]) => false */ declare function isBigInt(value: unknown): value is bigint; /** * Determine if a value is a boolean. * * 判断一个值是否为 boolean。 * * @example isBoolean('') => false * * @example isBoolean(0) => false * * @example isBoolean(0n) => false * * @example isBoolean(true) => true * * @example isBoolean(undefined) => false * * @example isBoolean(null) => false * * @example isBoolean(Symbol()) => false * * @example isBoolean({}) => false * * @example isBoolean(() => {}) => false * * @example isBoolean([]) => false */ declare function isBoolean(value: unknown): value is boolean; /** * Determine if a value is undefined. * * 判断一个值是否为 undefined。 * * @example isUndefined('') => false * * @example isUndefined(0) => false * * @example isUndefined(0n) => false * * @example isUndefined(true) => false * * @example isUndefined(undefined) => true * * @example isUndefined(null) => false * * @example isUndefined(Symbol()) => false * * @example isUndefined({}) => false * * @example isUndefined(() => {}) => false * * @example isUndefined([]) => false */ declare function isUndefined(value: unknown): value is undefined; /** * Determine if a value is null. * * 判断一个值是否为 null。 * * @example isNull('') => false * * @example isNull(0) => false * * @example isNull(0n) => false * * @example isNull(true) => false * * @example isNull(undefined) => false * * @example isNull(null) => true * * @example isNull(Symbol()) => false * * @example isNull({}) => false * * @example isNull(() => {}) => false * * @example isNull([]) => false */ declare function isNull(value: unknown): value is null; /** * Determine if a value is null or undefined. * * 判断一个值是否为 null 或 undefined。 * * @example isNullish('') => false * * @example isNullish(0) => false * * @example isNullish(0n) => false * * @example isNullish(true) => false * * @example isNullish(undefined) => true * * @example isNullish(null) => true * * @example isNullish(Symbol()) => false * * @example isNullish({}) => false * * @example isNullish(() => {}) => false * * @example isNullish([]) => false */ declare function isNullish(value: unknown): value is null | undefined; /** * Determine if a value is a symbol. * * 判断一个值是否为 symbol。 * * @example isSymbol('') => false * * @example isSymbol(0) => false * * @example isSymbol(0n) => false * * @example isSymbol(true) => false * * @example isSymbol(undefined) => false * * @example isSymbol(null) => false * * @example isSymbol(Symbol()) => true * * @example isSymbol({}) => false * * @example isSymbol(() => {}) => false * * @example isSymbol([]) => false */ declare function isSymbol(value: unknown): value is symbol; /** * Determine if a value is a object. * * 判断一个值是否为 object。 * * @example isObject('') => false * * @example isObject(0) => false * * @example isObject(0n) => false * * @example isObject(true) => false * * @example isObject(undefined) => false * * @example isObject(null) => false * * @example isObject(Symbol()) => false * * @example isObject({}) => true * * @example isObject(() => {}) => false * * @example isObject([]) => false */ declare function isObject(value: unknown): value is object; /** * Determine if a value is a function. * * 判断一个值是否为 function。 * * @example isFunction('') => false * * @example isFunction(0) => false * * @example isFunction(0n) => false * * @example isFunction(true) => false * * @example isFunction(undefined) => false * * @example isFunction(null) => false * * @example isFunction(Symbol()) => true * * @example isFunction({}) => false * * @example isFunction(() => {}) => true * * @example isFunction([]) => false */ declare function isFunction(value: unknown): value is Function; /** * Determine if a value is a array. * * 判断一个值是否为 array。 * * @example isArray('') => false * * @example isArray(0) => false * * @example isArray(0n) => false * * @example isArray(true) => false * * @example isArray(undefined) => false * * @example isArray(null) => false * * @example isArray(Symbol()) => true * * @example isArray({}) => false * * @example isArray(() => {}) => false * * @example isArray([]) => true * * @example isArray([1], isNumber) => true */ declare function isArray(value: unknown, assertion?: (value: unknown) => value is T): value is T[]; /** * Determine if a value is a blob. * * 判断一个值是否为 blob。 */ declare function isBlob(value: unknown): value is Blob; /** * Determine if a value is a file. * * 判断一个值是否为 file。 */ declare function isFile(value: unknown): value is File; /** * Get millisecond-based timestamp. * * 获取毫秒级时间戳。 * * @example getTimestamp() => 13 digits number */ declare function getTimestamp(): number; /** * Use `Object.is` directly to determine if two values are equal. * * Use `isDeepEqual` If you need a deep comparison. * * 直接使用 `Object.is` 来判断两个值是否相等。 * * 如果你需要深层比较,请使用 `isDeepEqual`。 * * @example isEqual(null, null) => true * * @example isEqual(undefined, null) => false * * @example isEqual(undefined, undefined) => true * * @example isEqual(true, true) => true * * @example isEqual(false, false) => true * * @example isEqual(true, false) => false * * @example isEqual(1, 2) => false * * @example isEqual(1, 1) => true * * @example isEqual({}, {}) => false * * @example isEqual({ a: 1 }, { a: 1, b: 2 }) => false * * @example isEqual({ a: 1 }, { a: 1 }) => false * * @example isEqual({ a: 1, b: { c: true } }, { a: 1, b: { c: true } }) => false * * @example isEqual({ a: 1, b: { c: true } }, { a: 1, b: { c: false } }) => false * * @example isEqual([], []) => false * * @example isEqual([1, 2, 3, { a: 1, b: { c: true } }], [1, 2, 3, { a: 1, b: { c: true } }]) => * false * * @example isEqual([1, 2, 3, { a: 1, b: { c: true } }], [1, 2, 3, { a: 1, b: { c: false } }]) => * false */ declare function isEqual(value1: unknown, value2: unknown): boolean; /** * Determine if two values are equal. * * For arrays, recursively determine the value corresponding to each index. * * For objects, recursively determine the value of each key. * * Other cases are determined with `Object.is`. * * 判断两个值是否相等。 * * 对于数组,递归地判断每个下标的值。 * * 对于对象,递归地判断每个键对应的值。 * * 其它情况使用 `Object.is` 来判断。 * * @example isDeepEqual(null, null) => true * * @example isDeepEqual(undefined, null) => false * * @example isDeepEqual(undefined, undefined) => true * * @example isDeepEqual(true, true) => true * * @example isDeepEqual(false, false) => true * * @example isDeepEqual(true, false) => false * * @example isDeepEqual(1, 2) => false * * @example isDeepEqual(1, 1) => true * * @example isDeepEqual({}, {}) => true * * @example isDeepEqual({ a: 1 }, { a: 1, b: 2 }) => false * * @example isDeepEqual({ a: 1 }, { a: 1 }) => true * * @example isDeepEqual({ a: 1, b: { c: true } }, { a: 1, b: { c: true } }) => true * * @example isDeepEqual({ a: 1, b: { c: true } }, { a: 1, b: { c: false } }) => false * * @example isDeepEqual([], []) => true * * @example isDeepEqual([1, 2, 3, { a: 1, b: { c: true } }], [1, 2, 3, { a: 1, b: { c: true } }]) => * true * * @example isDeepEqual([1, 2, 3, { a: 1, b: { c: true } }], [1, 2, 3, { a: 1, b: { c: false } }]) * => false */ declare function isDeepEqual(value1: unknown, value2: unknown): boolean; /** * Empty function. * * 空函数。 */ declare function noop(): void; /** * Creates a throttled function that only invokes `callback` at most once per every `delay` * milliseconds. * * 创建一个节流函数,每 `delay` 毫秒最多只调用一次 `callback`。 * * @param callback function to throttle * @param callback 需要节流的方法 * @param delay milliseconds to throttle * @param delay 节流的毫秒数 * @param options options object, default `{}` * @param options 选项 object,默认为 `{}` * @param options.leading specify invoking on the leading edge of the timeout, default `true` * @param options.leading 是否在超时前沿调用,默认 `true` * @param options.trailing specify invoking on the trailing edge of the timeout, default `true` * @param options.leading 是否在超时后沿调用,默认 `true` */ declare function throttle any>(callback: Callback, delay?: number, { leading, trailing }?: { leading?: boolean | undefined; trailing?: boolean | undefined; }): { (...args: Parameters): void; abort: (isOneTime?: boolean) => void; cancel: (isOneTime?: boolean) => void; isAborted(): boolean; isCancelled: () => boolean; }; /** * Creates a debounced function that delays invoking `callback` until after `delay` milliseconds * have elapsed since the last time the debounced function was invoked. * * 创建一个防抖函数,自上次调用以来过去了 `delay` 毫秒再调用 `callback`。。 * * @param callback function to throttle * @param callback 需要防抖的方法 * @param delay milliseconds to debounce * @param delay 防抖的毫秒数 * @param options options object, default `{}` * @param options 选项 object,默认为 `{}` * @param options.leading specify invoking on the leading edge of the timeout, default `false` * @param options.leading 是否在超时前沿调用,默认 `false` * @param options.trailing specify invoking on the trailing edge of the timeout, default `true` * @param options.leading 是否在超时后沿调用,默认 `true` */ declare function debounce any>(callback: Callback, delay?: number, { leading, trailing }?: { leading?: boolean | undefined; trailing?: boolean | undefined; }): { (...args: Parameters): void; abort: (isOneTime?: boolean) => void; cancel: (isOneTime?: boolean) => void; isAborted(): boolean; isCancelled: () => boolean; }; /** * Performs left-to-right function composition. * * 执行从左到右的函数组合。 * * @example pipe((a: number, b: number) => a + b)(1, 1) => 2 * * @example pipe((a: number, b: number) => a + b, (a) => Math.pow(a, 2))(1, 1) => 4 */ declare function pipe(fn1: (...args: Args) => Result1): (...args: Args) => Result1; declare function pipe(fn1: (...args: Args) => Result1, fn2: (arg: Result1) => Result2): (...args: Args) => Result2; declare function pipe(fn1: (...args: Args) => Result1, fn2: (arg: Result1) => Result2, fn3: (arg: Result2) => Result3): (...args: Args) => Result3; declare function pipe(fn1: (...args: Args) => Result1, fn2: (arg: Result1) => Result2, fn3: (arg: Result2) => Result3, fn4: (arg: Result3) => Result4): (...args: Args) => Result4; declare function pipe(fn1: (...args: Args) => Result1, fn2: (arg: Result1) => Result2, fn3: (arg: Result2) => Result3, fn4: (arg: Result3) => Result4, fn5: (arg: Result4) => Result5): (...args: Args) => Result5; declare function pipe(fn1: (...args: Args) => Result1, fn2: (arg: Result1) => Result2, fn3: (arg: Result2) => Result3, fn4: (arg: Result3) => Result4, fn5: (arg: Result4) => Result5, fn6: (arg: Result5) => Result6): (...args: Args) => Result6; declare function pipe(fn1: (...args: Args) => Result1, fn2: (arg: Result1) => Result2, fn3: (arg: Result2) => Result3, fn4: (arg: Result3) => Result4, fn5: (arg: Result4) => Result5, fn6: (arg: Result5) => Result6, fn7: (arg: Result6) => Result7): (...args: Args) => Result7; /** * Returns the names of the enumerable string properties and methods of an object. * * 返回对象的可枚举字符串属性和方法的名称。 * * @param o — Object that contains the properties and methods. This can be an object that you * created or an existing Document Object Model (DOM) object. * @param o - 包含属性和方法的 object。这可以是你创建的对象或现有文档对象模型(DOM)对象。 */ declare const objectKeys: (o: Type) => `${Exclude}`[]; /** * Returns an array of key/values of the enumerable properties of an object. * * 返回 object 可枚举属性的键值数组。 * * @param o — Object that contains the properties and methods. This can be an object that you * created or an existing Document Object Model (DOM) object. * @param o - 包含属性和方法的对象。这可以是你创建的对象或现有文档对象模型(DOM)对象。 */ declare const objectEntries: >(o: Type) => [`${Exclude}`, Type[`${Exclude}`]][]; /** * Returns an object created by key-value entries for properties and methods. * * 返回由属性和方法的键值条目创建的对象。 * * @param entries — An iterable object that contains key-value entries for properties and methods. * @param entries - 一个可迭代对象,包含属性和方法的键值条目。 */ declare const objectFromEntries: (entries: Entries) => { [K in Extract[0]]: Extract[1]; }; /** * Sleep 💤, then call `callback` if passed. * * 休眠 💤,之后如果传递了 `callback` 就会调用它。 * * @param ms - milliseconds to sleep * @param ms - 要休眠的毫秒数 * @param callback - the function called after awake * @param callback - 休眠后要调用的方法 */ declare function sleep(ms: number, callback?: Fn | PromisifyFn): Promise; /** * Determines whether a set includes a certain element, returning true or false as appropriate. * * 确定 set 是否包含某个元素,返回 true 或 false。 * * @param set - The set to search in. * @param set - 需要搜索的 set。 * @param value - The element to search for. * @param value - 需要搜索的元素。 */ declare function setHas(set: Set | ReadonlySet, value: SuperType): value is Type; /** * Convert string to lower case. * * 将字符串转换成小写。 */ declare function lowerCase(string: string): string; /** * Convert string to locale lower case. * * 将字符串转换成本地小写。 */ declare function localeLowerCase(string: string, locales?: string | string[]): string; /** * Convert first char to lower case. * * 将第一个字符转换成小写。 */ declare function lowerCaseFirst(string: string): string; /** * Convert string to upper case. * * 将字符串转换成大写。 */ declare function upperCase(string: string): string; /** * Convert string to locale upper case. * * 将字符串转换成本地大写。 */ declare function localeUpperCase(string: string, locales?: string | string[]): string; /** * Convert first char to upper case. * * 将第一个字符转换成大写。 */ declare function upperCaseFirst(string: string): string; /** * Convert value to string. * * Try `value.toString()` first, then `Object#toString.call(value)`. * * 将值转换成字符串。 * * 首先尝试 `value.toString()`,然后再尝试 `Object#toString.call(value)`。 * * @example toString(undefined) => '[object Undefined]' * * @example toString(null) => '[object Null]' * * @example toString(0) => '0' * * @example toString(Symbol('test')) => 'Symbol(test)' * * @example toString([1,2,3]) => '1,2,3' */ declare function toString(v: any): string; export { AnyFn, AnyRecord, Arrayable, Awaitable, ElementOf, Falsy, Fn, MaybeArray, MaybeNull, MaybePromise, MaybePromiseLike, MaybeUndefined, NonNullable, NonNullish, NonUndefinable, Nullable, Nullish, Optional, Promisable, PromisifyAnyFn, PromisifyFn, Undefinable, arrayIncludes, debounce, difference, getTimestamp, getType, intersection, isArray, isBigInt, isBlob, isBoolean, isDeepEqual, isEqual, isFile, isFunction, isNull, isNullish, isNumber, isObject, isString, isSymbol, isUndefined, localeLowerCase, localeUpperCase, lowerCase, lowerCaseFirst, noop, objectEntries, objectFromEntries, objectKeys, pipe, range, setHas, sleep, throttle, toArray, toString, union, uniq, upperCase, upperCaseFirst };