/** * Chunks an array into multiple arrays, each containing size or fewer items. * @since 0.1.0 * @template T * @param {T[]} array The array to process. * @param {number} size The length of each chunk * @returns {Array} Returns new array of chunks * @example * * const array = [1, 2, 3, 4, 5, 6] * chunk(array, 2) // [[1, 2], [3, 4], [5, 6]] */ declare const chunk: (array: T[], size: number) => T[][]; /** * Creates an array of array values not included in the other given arrays. The order and references of result values are determined by the first array. * @since 0.1.0 * @template T * @param {T[]} array The array to inspect. * @param {T[][] | [...T[][], (value: T, index: number) => any]} other The arrays to exclude. * @param [transformer] The transformer invoked per element for comparison. * @returns {T[]} Returns the new array of filtered values. * @example * * const arr = [1, 2, 3, 4, 5] * const other = [3, 5, 6] * difference(arr, other) // [1, 2, 4] * difference(arr, other, [2], (v) => v % 5) // [2, 4] */ declare function difference(array: T[], ...other: T[][] | [...T[][], (value: T, index: number) => any]): T[]; /** * Creates an array of values that are included in all given arrays. The order and references of result values are determined by the first array. * @since 0.1.0 * @template T * @param {T[][] | [...T[][], (value: T, index: number) => any]} arrays The arrays to inspect. * @param [transformer] The transformer invoked per element for comparison. * @returns {T[]} Returns the new array of intersecting values. * @example * * const arr = [1, 2, 3, 4, 5] * const other = [3, 5, 6] * intersection(arr, other) // [3, 5] * intersection(arr, other, [5], (value) => value > 3) // [4, 5, 6] */ declare function intersection(...arrays: T[][] | [...T[][], (value: T, index: number) => any]): T[]; /** * A function to create numbered lists of integers, * @since 0.1.0 * @param {number} start The start value of array, if `arguments.length === 0`, array started at 0 value * @param {number} size The size of array * @returns {number[]} Returns `size` length array, started at `start` * @example * * range(5) // [0, 1, 2, 3, 4] * range(3, 4) // [3, 4, 5, 6] */ declare function range(size: number): number[]; declare function range(start: number, size: number): number[]; /** * Creates an array of shuffled values, using knuth shuffle * @since 0.1.0 * @template T * @param {T[]} array The array to query * @returns {T[]} Returns the new shuffled array. */ declare const shuffle: (array: T[]) => T[]; /** * Checks if predicate returns truthy for all element of collection. * @since 0.1.0 * @template T * @param {T} collection The collection to iterate over. * @param {(value: any, index: any, collection: T) => boolean} predicate The function invoked per iteration. * @returns {boolean} Returns true if all elements pass the predicate check, else false. * @example * * const arr = [1, 2, 5] * every(arr, (value) => value < 10) // true * * const obj = { a: 1, b: 2 } * every(arr, (_, key) => key !== 'a') // false */ declare function every>(collection: T, predicate: (value: ArrayLikeValue, index: number, collection: T) => boolean): boolean; declare function every>(collection: T, predicate: (value: DictionaryValue, key: string, collection: T) => boolean): boolean; /** * Iterates over elements of collection, returning an array of all elements predicate returns truthy for * @since 0.1.0 * @template T * @param {T} collection The collection to iterate over * @param {(value: any, index: any, collection: T) => void} predicate The function invoked per iteration * @returns {any[]} Returns the new filterd array * @example * * const arr = [1, 2, 3] * filter(arr, (value, index) => index === 1) // [1, 3] * * const obj = { a: 1, b: 'str' } * filter(obj, (value, key) => typeof value === 'string') // ['str'] */ declare function filter>(collection: T, predicate: (value: ArrayLikeValue, index: number, collection: T) => boolean): ArrayLikeValue[]; declare function filter>(collection: T, predicate: (value: DictionaryValue, key: string, collection: T) => boolean): DictionaryValue[]; /** * Iterates over elements of collection, returning the first element predicate returns truthy for. * @since 0.1.0 * @template T * @param {T} collection The collection to iterate over. * @param {(value: any, index: any, collection: T) => boolean} predicate The function invoked per iteration. * @returns {boolean} Returns the matched element, else `undefined`. * @example * * const arr = [1, 2, 13] * find(arr, (value) => value > 10) // 13 * * const obj = { a: 1, b: 2 } * find(arr, (_, key) => key === 'c') // undefined */ declare function find>(collection: T, predicate: (value: ArrayLikeValue, index: number, collection: T) => boolean): ArrayLikeValue | undefined; declare function find>(collection: T, predicate: (value: DictionaryValue, key: string, collection: T) => boolean): DictionaryValue | undefined; /** * Iterates over elements of collection and invokes iteratee for each element. * @since 0.1.0 * @template T * @param {T} collection The collection to iterate over. * @param {(value: any, index: any, collection: T) => void} callback The function invoked per iteration. * @example * * const arr = [1] * forEach(arr, (value, index) => console.log(value, index)) // 1, 0 * * const obj = { a: 1 } * forEach(obj, (value, key) => console.log(value, key)) // 1, 'a' */ declare function forEach>(collection: T, callback: (value: ArrayLikeValue, index: number, collection: T) => void): void; declare function forEach>(collection: T, callback: (value: DictionaryValue, key: string, collection: T) => void): void; /** * Iterates over elements of collection and invokes iteratee for each element. * @since 0.1.0 * @template T * @param {T} collection The collection to iterate over. * @param {(value: any, index: any, collection: T) => void} callback The function invoked per iteration. * @example * * const arr = [1] * forEachRight(arr, (value, index) => console.log(value, index)) // 1, 0 * * const obj = { a: 1 } * forEachRight(obj, (value, key) => console.log(value, key)) // 1, 'a' */ declare function forEachRight>(collection: T, callback: (value: ArrayLikeValue, index: number, collection: T) => void): void; declare function forEachRight>(collection: T, callback: (value: DictionaryValue, key: string, collection: T) => void): void; /** * Iterates over elements of collection and invokes iteratee for each element. * @since 0.1.0 * @template T * @param {T} collection The collection to iterate over. * @param {(value: any, index: any, collection: T) => string} callback The function invoked per iteration. * @returns {Record} Returns new grouped array * @example * * const students = [ * { name: 'john', class: 'A', score: 100 }, * { name: 'alice', class: 'B', score: 91 }, * { name: 'smith', class: 'C', score: 65 }, * { name: 'gale', class: 'A', score: 74 }, * ] * * const results = groupBy(students, (value) => value.score < 70 ? 'fail' : 'pass') * results.fail // [{ name: 'smith', class: 'C', score: 65 }] * results.pass.length // 3 */ declare function groupBy>(collection: T, callback: (value: ArrayLikeValue, index: number, collection: T) => string): Record[]>; declare function groupBy>(collection: T, callback: (value: DictionaryValue, key: string, collection: T) => string): Record[]>; /** * Iterates over elements of collection and invokes iteratee for each element. * @since 0.1.0 * @template [T = any] * @template {Collection} [O = Collection] * @param {T} collection The collection to iterate over. * @param {(value: any, index: any, collection: O) => T} callback The function invoked per iteration. * @returns {T[]} Returns the new mapped array. * @example * * const arr = [1, 2, 3] * map(arr, (value, index) => value + index) // [1, 3, 5] * * const obj = { a: 1, b: 2, c: 3 } * map(obj, (value, key) => value + key) // ['a1', 'b2', 'c3'] */ declare function map = ArrayLike>(collection: O, callback: (value: ArrayLikeValue, index: number, collection: O) => T): T[]; declare function map = Dictionary>(collection: O, callback: (value: DictionaryValue, key: string, collection: O) => T): T[]; /** * Executes a user-supplied "reducer" callback function on each element of the array, in order, passing in the return value from the calculation on the preceding element. The final result of running the reducer across all elements of the array is a single value. * * The first time that the callback is run there is no "return value of the previous calculation". If supplied, an initial value may be used in its place. Otherwise the collection's first element is used as the initial value * @since 0.1.0 * @param {*} collection The collection to iterate over. * @param {(accumulator: any, value: any, index: any, collection: any) => any} reducer The function invoked per iteration. * @param {*} [accumulator] The initial value. * @returns {any} Returns the accumulated value. * @example * * const arr = [1, 2, 3] * reduce(arr, (acc, value) => `${acc}_${value}`, '') // '_1_2_3' */ declare function reduce = ArrayLike$1>(collection: T, reducer: (accumulator: ArrayLikeValue, value: ArrayLikeValue, index: number, collection: T) => ArrayLikeValue, accumulator?: ArrayLikeValue): ArrayLikeValue; declare function reduce = ArrayLike$1, V = any>(collection: T, reducer: (accumulator: V, value: ArrayLikeValue, index: number, collection: T) => V, accumulator: V): V; declare function reduce = Dictionary>(collection: T, reducer: (accumulator: DictionaryValue, value: DictionaryValue, key: string, collection: T) => DictionaryValue, accumulator?: DictionaryValue): DictionaryValue; declare function reduce = Dictionary, V = any>(collection: T, reducer: (accumulator: V, value: DictionaryValue, key: string, collection: T) => V, accumulator: V): V; /** * Executes a user-supplied "reducer" callback function on each element of the array, in order, passing in the return value from the calculation on the preceding element. The final result of running the reducer across all elements of the array is a single value. * * The first time that the callback is run there is no "return value of the previous calculation". If supplied, an initial value may be used in its place. Otherwise the collection's last element is used as the initial value * @since 0.1.0 * @param {*} collection The collection to iterate over. * @param {(accumulator: any, value: any, index: any, collection: any) => any} reducer The function invoked per iteration. * @param {*} [accumulator] The initial value. * @returns {any} Returns the accumulated value. * @example * * const arr = [1, 2, 3] * reduceRight(arr, (acc, value) => `${acc}_${value}`, '') // '_3_2_1' */ declare function reduceRight = ArrayLike$1>(collection: T, reducer: (accumulator: ArrayLikeValue, value: ArrayLikeValue, index: number, collection: T) => ArrayLikeValue, accumulator?: ArrayLikeValue): ArrayLikeValue; declare function reduceRight = ArrayLike$1, V = any>(collection: T, reducer: (accumulator: V, value: ArrayLikeValue, index: number, collection: T) => V, accumulator: V): V; declare function reduceRight = Dictionary>(collection: T, reducer: (accumulator: DictionaryValue, value: DictionaryValue, key: string, collection: T) => DictionaryValue, accumulator?: DictionaryValue): DictionaryValue; declare function reduceRight = ArrayLike$1, V = any>(collection: T, reducer: (accumulator: V, value: DictionaryValue, key: string, collection: T) => V, accumulator: V): V; /** * Checks if predicate returns truthy for any element of collection. * @since 0.1.0 * @template T * @param {T} collection The collection to iterate over. * @param {(value: any, index: any, collection: T) => boolean} predicate The function invoked per iteration. * @returns {boolean} Returns true if any element passes the predicate check, else false. * @example * * const arr = [1, 2, 13] * some(arr, (value) => value > 10) // true * * const obj = { a: 1, b: 2 } * some(arr, (_, key) => key === 'c') // false */ declare function some>(collection: T, predicate: (value: ArrayLikeValue, index: number, collection: T) => boolean): boolean; declare function some>(collection: T, predicate: (value: DictionaryValue, key: string, collection: T) => boolean): boolean; /** * Returns the first `Element` within the document that matches the specified selector, or group of selectors. If no matches are found, `null` is returned. * @since 0.1.0 * @template {Element} [T = HTMLElement] * @param {string} selector A string containing one or more selectors to match. * @param {Element | Document} [element] The target element to find selector * @returns {T | null} Returns the first element that is a descendant of node that matches selectors. * @example * * find$('.some-class') */ declare function find$(selector: string, element?: Element | Document): T | null; /** * Returns a static (not live) NodeList representing a list of the document's elements that match the specified group of selectors. * @since 0.1.0 * @template {Element} [T = HTMLElement] * @param {string} selector A string containing one or more selectors to match. * @param {Element | Document} [element] The target element to find selector * @returns {NodeListOf} A non-live `NodeList` containing one `Element` object for each element that matches at least one of the specified selectors or an empty `NodeList` in case of no matches. * @example * * const $items = findAll$('.some-item') */ declare function findAll$(selector: string, element?: Element | Document): NodeListOf; /** * Bind event listener * @since 0.1.0 * @template {Element | Window | Document} T * @param {T} element The element to bind event * @param {string} eventType A case-sensitive string representing the event type to listen for. * @param {(event: Event) => any} listener The object that receives a notification when an event of the specified type occurs. * @param {AddEventListenerOptions | boolean} [options] An object that specifies characteristics about the event listener. If `true`, allows you to take advantage of event bubbling for events that otherwise don’t support it. * @example * * const handler = () => console.log('hi') * on(document.body, 'click', handler) * document.body.click() // 'hi' */ declare function on(element: T, eventType: K, listener: EvtListener, options?: AddEventListenerOptions | boolean): void; declare function on(element: T, eventType: K, listener: (event: WindowEventMap[K]) => any, options?: AddEventListenerOptions | boolean): void; declare function on(element: T, eventType: K, listener: (event: DocumentEventMap[K]) => any, options?: AddEventListenerOptions | boolean): void; declare function on(element: T, eventType: string, listener: (event: Event) => any, options?: AddEventListenerOptions | boolean): void; /** * Unbind event listener * @since 0.1.0 * @template {*} [T = HTMLElement] * @param {T} element The element to unbind event * @param {string} eventType A case-sensitive string representing the event type to listen for. * @param {(event: Event) => any} listener The object that receives a notification when an event of the specified type occurs. * @example * * const handler = () => console.log('hi') * document.body.addEventListener('click', handler) * document.body.click() // 'hi' * off(document.body, 'click', handler) * document.body.click() // */ declare function off(element: T, eventType: K, listener: EvtListener, options?: AddEventListenerOptions | boolean): void; declare function off(element: T, eventType: K, listener: (event: WindowEventMap[K]) => any, options?: AddEventListenerOptions | boolean): void; declare function off(element: T, eventType: K, listener: (event: DocumentEventMap[K]) => any, options?: AddEventListenerOptions | boolean): void; declare function off(element: T, eventType: string, listener: (event: Event) => any, options?: AddEventListenerOptions | boolean): void; /** * Callback function that determine whether to fire an event listener * @callback BindCondition * @param {Window | Document | Element} parent The parent element where the event is actually registered * @param {Element} target The selector element on which to fire the event. * @returns {boolean} Whether to fire an event */ type BindCondition = (parent: Window | Document | Element, target: Element) => boolean; type MouseEventKeys = { [K in keyof T]: T[K] extends MouseEvent ? K : never; }[keyof T]; /** * Function to pre-register events for elements whose existence is uncertain by registering events on the parent element. * @since 0.1.0 * @template {MouseEventKeys} K * @template {Element} [T = HTMLElement] * @param {Element} $element Parent element * @param {K} eventType Event type to listen for. It should be of the mouse event type * @param {string} selector A string containing one or more selectors to match. * @param {EvtListener} listener The object that receives a notification when an event of the specified type occurs. * @param {BindCondition} [condition] Callback function that determine whether to fire an event listener * @example * * bind$(document.body, 'click', '.some-selector', (event) => console.log(event)) */ declare function bind$($element: Window | Document | Element, eventType: K, selector: string, listener: EvtListener, condition?: BindCondition): void; type IfEquals = (() => T extends X ? 1 : 2) extends () => T extends Y ? 1 : 2 ? A : B; type WritableKeys = { [P in keyof T]-?: IfEquals<{ [Q in P]: T[P]; }, { -readonly [Q in P]: T[P]; }, P, never>; }[keyof T]; type Writable = { [P in WritableKeys]: T[P]; }; type FunctionKeys = { [K in keyof T]: T[K] extends (...args: any[]) => any ? K : never; }[keyof T]; type OmitFunction = { [P in Exclude>]: T[P]; }; type CreateOptions = Partial>, keyof CreateCustomOptions>> & CreateCustomOptions; type CreateCustomOptions = { id?: string | undefined; className?: string | undefined; classList?: string[] | undefined; role?: AriaRole; style?: Partial | undefined; dataset?: Record | undefined; }; /** * Create Element * @template {keyof HTMLElementTagNameMap} K * @template [T = HTMLElementTagNameMap[K]] * @param {K} tagName The tag name of element * @param {CreateOptions} options The element options * @example * * const $div = create$('div', { className: 'my-class', innerHTML: 'welcome' }) * //
welcome
*/ declare function create$(tagName: K, options?: CreateOptions): HTMLElementTagNameMap[K]; type Storage = { /** Returns the current value associated with the given key, or null if the given key does not exist. */ get(key: string, defaultValue?: V): T | V; /** Sets the value of the pair identified by key to value, creating a new key/value pair if none existed for key previously. */ set(key: string, value: any): void; /** Removes the key/value pair with the given key, if a key/value pair with the given key exists. */ remove(key: string): void; /** Removes all key/value pairs, if there are any. */ clear(): void; }; /** * Create storage. For easy to use browser localStorage(or sessionStorage) * @since 1.1.0 * @param {'local' | 'session'} [storageType = 'local'] The storage to use. * @returns {Storage} Returns storage * @example * * const storage = useStorage() * storage.get('name') // null * storage.get('name', 'Who are you?') // 'Who are you?' * * storage.set('name', 'Kim') * storage.get('name') // 'Kim' * * storage.set('data', { x: 1, y: 10 }) // Save stringify value, '{ "x": 1, "y": 10 }' * storage.get('data') // Get parse value ,{ x: 1, y: 10 } * * storage.remove('name') * storage.get('name') // null * * storage.clear() * storage.get('data') // null */ declare function useStorage(storageType?: 'local' | 'session'): Storage; type Evt = HTMLElementEventMap[K] & { currentTarget: T; }; type EvtListener = (event: Evt) => any; /** All the WAI-ARIA 1.1 role attribute values from https://www.w3.org/TR/wai-aria-1.1/#role_definitions */ type AriaRole = 'alert' | 'alertdialog' | 'application' | 'article' | 'banner' | 'button' | 'cell' | 'checkbox' | 'columnheader' | 'combobox' | 'complementary' | 'contentinfo' | 'definition' | 'dialog' | 'directory' | 'document' | 'feed' | 'figure' | 'form' | 'grid' | 'gridcell' | 'group' | 'heading' | 'img' | 'link' | 'list' | 'listbox' | 'listitem' | 'log' | 'main' | 'marquee' | 'math' | 'menu' | 'menubar' | 'menuitem' | 'menuitemcheckbox' | 'menuitemradio' | 'navigation' | 'none' | 'note' | 'option' | 'presentation' | 'progressbar' | 'radio' | 'radiogroup' | 'region' | 'row' | 'rowgroup' | 'rowheader' | 'scrollbar' | 'search' | 'searchbox' | 'separator' | 'slider' | 'spinbutton' | 'status' | 'switch' | 'tab' | 'table' | 'tablist' | 'tabpanel' | 'term' | 'textbox' | 'timer' | 'toolbar' | 'tooltip' | 'tree' | 'treegrid' | 'treeitem' | (string & object); type Debounced any> = { (...args: Parameters): ReturnType; cancel: () => void; }; /** * Creates a debounced function that delays invoking func until after wait milliseconds have elapsed since the last time the debounced function was invoked. * * The debounced function comes with a cancel method to cancel delayed func invocations and a flush method to immediately invoke them. * @since 0.1.0 * @param {Function} func The function to debounce. * @param {number} wait The number of milliseconds to delay * @param {boolean} [immediate] If immediate is `true`, the argument `func` will be triggered at the beginning of the sequence instead of at the end. * @returns {Function} Returns debounce function. You can cancel debounce using `debounced.cancel` * @example * * const debounced = debounce(resizeHandler, 200) * document.body.addEventListener('resize', debounced) * * // You can cancel the trailing bebounced invocation. * function mustStopDebounce() { * debounced.cancel() * } * * // Invoke `requestData` when clicked, debouncing subsequent calls. * $requestApiBtn.addEventListener('click', debounce(requestData, 300, true)) */ declare function debounce any = (...args: any[]) => any>(func: T, wait: number, immediate?: boolean): Debounced; /** * Trigger delay * @since 0.1.0 * @param {number} wait The number of milliseconds to delay * @example * * (async () => { * workDurationOneSecond(); * await sleep(1000); * doAfterWork(); * })() */ declare const sleep: (wait: number) => Promise; type ThrottleOptions = { leading?: boolean; trailing?: boolean; }; type Throttled any> = { (...args: Parameters): ReturnType; cancel: () => void; }; /** *Creates a throttled function that only invokes func at most once per every wait milliseconds. * * The throttled function comes with a cancel method to cancel delayed func invocations and a flush method to immediately invoke them. * @since 0.1.0 * @param {Function} func The function to throttle. * @param {number} wait The number of milliseconds to delay * @param {ThrottleOptions} [options] The options object. * @param {boolean} [options.leading] Specify invoking on the leading edge of the timeout. * @param {boolean} [options.trailing] Specify invoking on the trailing edge of the timeout. * @returns {Function} Returns throttled function. You can cancel throttle using `throttled.cancel` * @example * * const throttled = throttle(scrollHandler, 200) * window.addEventListener('scroll', throttled); * * // You can cancel the trailing throttled invocation. * throttled.cancel() */ declare function throttle any>(func: T, wait: number, options?: ThrottleOptions): Throttled; /** * Invokes the iteratee n times, returning an array of the results of each invocation. * * The iteratee is invoked with one argument; (index). * @since 1.1.0 * @param {number} count The number of times to invoke iteratee. * @param {Function} fn The function invoked per iteration. * @returns {any[]} Returns the array of results. * @example * * times(3, Boolean) // [false, true, true] */ declare function times any>(count: number, fn: Fn): ReturnType[]; type ConstructorObject = { name: string; }; /** * @since 0.1.0 * @param {*} object The object (constructor) to used for comparison * @param {*} value The value to compare * @returns {boolean} Retruns `true` if the `value` is `object`, else `false` * @example * * is(String, 'str') // true * is(Boolean, true) // true * is(Boolean, 'true') // false */ declare const is: (object: T, value: unknown) => value is T; /** * Check value is array * @since 0.1.0 * @param {*} value The value to check * @returns {value is any[]} Retruns `true` if `value` is array, else `false` * @example * * isArray([1, 2, 3]) // true * isArray(new Array()) // true * isArray(1) // false */ declare const isArray: (value: unknown) => value is T[]; /** * Check value is array-like * @since 0.1.0 * @template {ArrayLike} T * @param {*} value The value to check * @returns {value is T} Retruns `true` if `value` is array-like, else `false` * @example * * isArrayLike([1, 2, 3]) // true * isArrayLike('string') // true * isArrayLike(1) // false */ declare const isArrayLike: >(value: any) => value is T; /** * Check value is blank * @since 0.1.0 * @param {*} value The value to check * @returns {boolean} Retruns `true` if `value.length` is falsy, else `false` * @example * * isBlank('') // true * isBlank(undefined) // true * isBlank('a') // false */ declare const isBlank: (value: unknown) => boolean; /** * Check value is boolean * @since 0.1.0 * @param {*} value The value to check * @returns {value is boolean} Retruns `true` if `value` is boolean, else `false` * @example * * isBoolean(true) // true * isBoolean('true') // false */ declare const isBoolean: (value: unknown) => value is boolean; /** * Check value is date * @since 0.1.0 * @param {*} value The value to check * @returns {value is Date} Retruns `true` if `value` is date, else `false` * @example * * isDate(new Date()) // true * isDate('2024-01-01') // false */ declare const isDate: (value: unknown) => value is Date; /** * Check value is date-like * @since 0.1.0 * @param {*} value The value to check * @returns {boolean} Retruns `true` if `value` is date-like, else `false` * @example * * isDateLike(new Date()) // true * isDateLike('2024-01-01') // true * isDateLike(100000000) // true * isDateLike('string') // false */ declare const isDateLike: (value: T) => boolean; /** * Check value is element * @since 0.1.0 * @param {*} value The value to check * @returns {value is Element} Retruns `true` if `value` is element, else `false` * @example * * isElement(document.body) // true * isElement('
') // false */ declare const isElement: (value: unknown) => value is Element; /** * Check value is empty * @since 0.1.0 * @param {*} value The value to check * @returns {boolean} Retruns `true` if `value` is empty, else `false` * @example * * isEmpty([]) // true * isEmpty({}) // true * isEmpty(new Set()) // true * isEmpty(false) // false */ declare const isEmpty: (value: unknown) => boolean; /** * Check values are equal * @since 0.1.0 * @param {*} value * @param {*} compare * @returns {boolean} Retruns `true` if the values are equal, else `false` * @example * * const obj = { a: 1 }; * * isEqual(obj, obj) // true * isEqual(obj, { a: 1 }) // true */ declare const isEqual: (value: any, compare: any) => boolean; /** * Check value is Error * @since 0.1.0 * @param {*} value The value to check * @returns {value is Error} Retruns `true` if `value` is error, else `false` * @example * * isError(new Error()) // true * isError('error') // false */ declare const isError: (value: unknown) => value is Error; /** * Check value is function * @since 0.1.0 * @param {*} value The value to check * @returns {value is Function} Retruns `true` if `value` is function, else `false` * @example * * isFunction(() => null) // true * isFunction({}) // false */ declare const isFunction: (value: unknown) => value is (...arg: any[]) => any; /** * Check value is Map * @since 0.1.0 * @param {*} value The value to check * @returns {boolean} Retruns `true` if `value` is Map, else `false` * @example * * isMap(new Map()) // true * isMap({ a: 1, b: 2 }) // false */ declare const isMap: >(value: unknown) => value is T; /** * Check value is null * @since 0.1.0 * @param {*} value The value to check * @returns {value is null} Retruns `true` if `value` is null, else `false` * @example * * isNull(null) // true * isNull(true) // false */ declare const isNull: (value: unknown) => value is null; /** * Check value is nullish * @since 0.1.0 * @param {*} value The value to check * @returns {boolean} Retruns `true` if `value` is null or undefined, else `false` * @example * * isNullish(null) // true * isNullish(undefined) // true * isNullish(0) // false */ declare const isNullish: (value: unknown) => value is null | undefined; /** * Check value is number * @since 0.1.0 * @param {*} value The value to check * @returns {value is number} Retruns `true` if `value` is number, else `false` * @example * * isNumber(123) // true * isNumber('123') // false */ declare const isNumber: (value: unknown) => value is number; /** * Check value is plain object * @since 0.1.0 * @param {*} value The value to check * @returns {boolean} Retruns `true` if `value` is plain object, else `false` * @example * * isPlainObject({}) // true * isPlainObject(new Map()) // false * isPlainObject(1) // false */ declare const isPlainObject: & Object>(value: unknown) => value is T; /** * Check value is RegExp * @since 0.1.0 * @param {*} value The value to check * @returns {value is RegExp} Retruns `true` if `value` is RegExp, else `false` * @example * * isRegExp(/\d/gi) // true * isRegExp(new RegExp()) // true * isRegExp('d') // false */ declare const isRegExp: (value: unknown) => value is RegExp; /** * Check value is object-like * @since 0.1.0 * @param {*} value The value to check * @returns {boolean} Retruns `true` if `value` is object-like, else `false` * @example * * isObject({}) // true * isObject(() => false) // true * isObject([]) // true * isObject(1) // false */ declare const isObject: >(value: unknown) => value is T; /** * Check value is Set * @since 0.1.0 * @param {*} value The value to check * @returns {boolean} Retruns `true` if `value` is Set, else `false` * @example * * isSet(new Set()) // true * isSet([1, 2, 3]) // false */ declare const isSet: = Set>(value: unknown) => value is T; /** * Check value is string * @since 0.1.0 * @param {*} value The value to check * @returns {value is string} Retruns `true` if `value` is string, else `false` * @example * * isString('is this string?') // true * isString(0) // false */ declare const isString: (value: unknown) => value is string; /** * Check value is symbol * @since 0.1.0 * @param {*} value The value to check * @returns {value is symbol} Retruns `true` if `value` is symbol, else `false` * @example * * isSymbol(Symbol('a')) // true * isSymbol('a') // false */ declare const isSymbol: (value: unknown) => value is symbol; /** * Check value is undefined * @since 0.1.0 * @param {*} value The value to check * @returns {value is undefined} Retruns `true` if `value` is undefined, else `false` * @example * * isUndefined(undefined) // true * isUndefined(0) // false */ declare const isUndefined: (value: unknown) => value is undefined; /** * Check value is WeakMap * @since 0.1.0 * @param {*} value The value to check * @returns {boolean} Retruns `true` if `value` is WeakMap, else `false` * @example * * isWeakMap(new WeakMap()) // true * isWeakMap(new Map()) // false */ declare const isWeakMap: = WeakMap>(value: unknown) => value is T; /** * Check value is WeakSet * @since 0.1.0 * @param {*} value The value to check * @returns {boolean} Retruns `true` if `value` is WeakSet, else `false` * @example * * isWeakSet(new WeakSet()) // true * isWeakSet(new Set()) // false */ declare const isWeakSet: = WeakSet>(value: unknown) => value is T; /** * Get Object.prototype.toString() type of value * @since 0.1.0 * @param {*} value The value to check type * @returns {string} The prototype of `value` * @example * * tagType({}) // 'Object' * tagType(1) // 'Number' */ declare const tagType: (value: any) => string; /** * Computes the average of the values * @since 0.1.0 * @param {number[]} values The values to calculate. * @returns {number} Returns the average of values * @example * * average([1, 2, 3]) // 2 */ declare function average(values: number[]): number; /** * Checks if n is between start and up to end * @since 0.1.0 * @param {number} number The number to check. * @param {number} start The start of the range. * @param {number} end The end of the range. * @returns {boolean} Returns `true` if number is in the range, else `false`. * @example * * between(3, 1, 5) // true * between(8, 1, 5) // false */ declare function between(number: number, start: number, end: number): boolean; /** * Clamp number * @since 0.1.0 * @param {number} number The number to clamp * @param {number} lower The lower bound * @param {number} upper The upper bound * @returns {number} Returns the clamped number * @example * * clamp(3, 1, 5) // 3 * clamp(8, 1, 5) // 5 */ declare function clamp(number: number, lower: number, upper: number): number; /** * Computes the sum of the values * @since 0.1.0 * @param {number[]} values The values to calculate. * @returns {number} Returns the sum of `values` * @example * * sum([1, 2, 3]) // 6 */ declare function sum(values: number[]): number; /** * Copy the values of all of the enumerable own properties from one or more source objects to a target object. Returns the target object. * @since 0.1.0 * @param {object} target The target object to copy to. * @param {...object} sources The source object from which to copy properties. * @returns {any} Returns the merged `target` object. * @example * * assign({}, { x: 1 }, { y: 10 }) // { x: 1, y: 10 } */ declare const assign: { (target: T, source: U): T & U; (target: T_1, source1: U_1, source2: V): T_1 & U_1 & V; (target: T_2, source1: U_2, source2: V_1, source3: W): T_2 & U_2 & V_1 & W; (target: object, ...sources: any[]): any; }; /** * This method is like assign except that it iterates over own and inherited source properties. * @since 0.1.0 * @param {object} object The object to merged * @param {...any} sources The source objects * @returns {any} Returns the merged `target` object. * @example * * function Foo() { * this.a = 1; * this.b = 2; * } * Foo.prototype.c = 3; * * assignIn({ x: 'x' }, new Foo()) // { x: 'x', a: 1, b: 2, c: 3 } */ declare function assignIn(object: T, source: U): T & U; declare function assignIn(object: T, source1: U, source2: V): T & U & V; declare function assignIn(object: T, source1: U, source2: V, source3: W): T & U & V & W; /** * Get the value at paths of object * @since 0.1.0 * @template [T = any] * @param {object} object The object to query. * @param {string} paths The path of the property to get. * @returns {T | undefined} Returns the resolved value. * @example * * onst obj = { a: { b: [{}, { c: 3 }] } }; * get(obj, 'a.b[1].c') // 3 * * const pkg = { exports: { '.': { import: 'file' } } }; * get(pkg, 'exports["."].import') // 'file' */ declare const get: (object: object, paths: string) => T | undefined; /** * Sets the value at path of object. * @since 0.1.0 * @param {object} object The object to modify. * @param {string} paths The path of the property to set. * @param {*} value The value to set * @example * * const obj = {}; * set(obj, 'a.b[1].c', 3) // { a: { b: [undefined, { c: 3 }] } } * * const arrMap = {} * set(arrMap, 'arr[-3]', 10) // { arr: [10, undefined, undefined] } */ declare const set: (object: object, paths: string, value: any) => void; /** * Checks if path is a direct property of object. * @since 0.1.0 * @param {object} object The object to query * @param {string} paths The path to check * @returns {boolean} Returns `true` if path exists, else `false` * @example * * const obj = { a: { b: c: 3 } } * has('a') // true * has('a.b.c') // true * has('a.b.d') // false * * const pkg = { exports: { '.': { import: 'file' } } }; * has(pkg, 'exports["."].import') // true */ declare const has: (object: object, paths: string) => boolean; /** * Create an array of a given object's own enumerable string-keyed property names. * @since 0.1.0 * @template {string} T * @param {object} object The object to extract keys * @returns {T[]} Retruns the array of property names * @example * * keys({ a: 1, b: 2 }) // ['a', 'b'] * * function Foo() { * this.a = 1 * this.b = 2 * } * Foo.prototype.c = 3 * keys(new Foo()) // ['a', 'b'] */ declare const keys: (object: object) => T[]; /** * Create an array of a given object's own and inherited enumerable property names. * @since 0.1.0 * @template {string} T * @param {object} object The object to extract keys * @returns {T[]} Retruns the array of property names * @example * * keysIn({ a: 1, b: 2 }) // ['a', 'b'] * * function Foo() { * this.a = 1 * this.b = 2 * } * Foo.prototype.c = 3 * keysIn(new Foo()) // ['a', 'b', 'c'] */ declare const keysIn: (object: object) => T[]; /** * Create an array of a given object's own enumerable string-keyed property values. * @since 0.1.0 * @template [T = any] * @param {Collection} object The object to extract values * @returns {T[]} Returns the array of property values. * @example * * const object = { a: 1, b: '2' } * const results = values(object) // [1, '2'] */ declare const values: (object: Collection) => T[]; /** * Create an array of a given object's own and inherited enumerable string-keyed property values. * @since 0.1.0 * @template [T = any] * @param {Collection} object The object to extract values * @returns {T[]} Returns the array of property values. * @example * * function Foo() { * this.a = 1 * this.b = 2 * } * Foo.prototype.c = 3 * valuesIn(new Foo()) // [1, 2, 3] */ declare const valuesIn: (object: Collection) => T[]; /** * Create an array of a given object's own enumerable string-keyed property key-value pairs. * @since 0.1.0 * @template [V = any] * @template {string} [K = string] * @param {Collection} object The object to extract entries * @returns {Array<[V, K]>} Returns the array of key-value pairs * @example * * const object = { a: 1, b: '2' } * const results = entries(object) // [['a', 1], ['b', '2']] */ declare const entries: (object: Collection) => [V, K][]; /** * Create an array of a given object's own and inherited enumerable string-keyed property key-value pairs. * @since 0.1.0 * @template [V = any] * @template {string} [K = string] * @param {Collection} object The object to extract entries * @returns {Array<[V, K]>} Returns the array of key-value pairs * @example * * function Foo() { * this.a = 1 * this.b = 2 * } * Foo.prototype.c = 3 * const results = entriesIn(new Foo()) // [['a', 1], ['b', '2'], ['c', 3]] */ declare const entriesIn: (object: Collection) => [V, K][]; /** * Returns the key of the first element predicate * @since 0.1.0 * @template {object} T * @param {T} object The object to inspect. * @param {(value: any) => boolean} predicate The function invoked per iteration. * @returns {string | undefined} Returns the key of the matched element, else undefined. * @example * * const obj = { * john: { class: 1, grade: 'A' }, * anna: { class: 3, grade: 'C' }, * smith: { class: 2, grade: 'B' }, * }; * findKey(obj, (o) => 'class' in o) // 'john' * findKey(obj, (o) => o.class === 3) // 'anna' */ declare const findKey: (object: T, predicate: (value: any) => boolean) => string | undefined; /** * Returns the key of the last element predicate * @since 0.1.0 * @template {object} T * @param {T} object The object to inspect. * @param {(value: any) => boolean} predicate The function invoked per iteration. * @returns {string | undefined} Returns the key of the matched element, else undefined. * @example * * const obj = { * john: { class: 1, grade: 'A' }, * anna: { class: 3, grade: 'C' }, * smith: { class: 2, grade: 'B' }, * }; * findLastKey(obj, (o) => 'class' in o) // 'smith' * findLastKey(obj, (o) => o.class === 3) // 'anna' */ declare const findLastKey: (object: T, predicate: (value: any) => boolean) => string | undefined; /** * Create object omitted by given keys * @since 0.1.0 * @template {object} T * @template {keyof T} K * @param {T} object * @param {...K} keys The property keys to omit. * @returns {Omit} Returns omitted object * @example * * const obj = { a: 1, b: 2, c: 3 } * omit(obj, 'a', 'c') // { b: 2 } */ declare const omit: (object: T, ...keys: K[]) => Omit; /** * Create object pickted by given keys * @since 0.1.0 * @template {object} T * @template {keyof T} K * @param {T} object * @param {...K} keys The property keys to pick. * @returns {Pick} Returns pickted object * @example * * const obj = { a: 1, b: 2, c: 3 } * pick(obj, 'a', 'c') // { a: 1, c: 3 } */ declare const pick: (object: T, ...keys: K[]) => Pick; /** * Converts string to camel case. https://developer.mozilla.org/en-US/docs/Glossary/Camel_case * @since 0.1.0 * @param {string} str The string to convert. * @returns {string} Returns the camel cased string. * @example * * camelCase('foo bar') // 'fooBar' * camelCase('foo-bar') // 'fooBar' * camelCase('FOO__bar') // 'fooBar' */ declare function camelCase(str?: string): string; /** * Converts the first character of string to upper case and the remaining to lower case * @since 0.1.0 * @param {string} str The string to capitalize * @returns {string} Retruns the capitalized string * @example * * capitalize('HELLO') // 'Hello' */ declare const capitalize: (str: string) => string; /** * Convert string to kebab case. https://developer.mozilla.org/en-US/docs/Glossary/Kebab_case * @since 0.1.0 * @param {string} str The string to convert. * @returns {string} Returns the kebab cased string. * @example * * kebabCase('foo bar') // 'foo-bar' * kebabCase('foo-bar') // 'foo-bar' * kebabCase('FOO__ bar') // 'foo-bar' */ declare function kebabCase(str: string): string; /** * Convert string to camel case, but the first character of string to upper case * @since 0.1.0 * @param {string} str The string to convert. * @returns {string} Returns the pascal cased string. * @example * * camelCase('foo bar') // 'FooBar' * camelCase('foo-bar') // 'FooBar' * camelCase('FOO__bar') // 'FooBar' */ declare function pascalCase(str: string): string; /** * Convert string to snake case. https://developer.mozilla.org/en-US/docs/Glossary/Snake_case * @since 0.1.0 * @param {string} str The string to convert. * @returns {string} Returns the snake cased string. * @example * * snakeCase('foo bar') // 'foo_bar' * snakeCase('foo-bar') // 'foo_bar' * snakeCase('FOO__ bar') // 'foo_bar' */ declare function snakeCase(str: string): string; type ArrayLike$1 = { [index: number]: T; length: number; }; type Dictionary = { [key: string]: T; }; type ArrayLikeValue = T extends ArrayLike$1 ? U : never; type DictionaryValue = T extends Dictionary ? U : never; type Collection = ArrayLike$1 | Dictionary; type CollectionValue = T extends ArrayLike$1 ? U : T extends Dictionary ? U : never; export { type AriaRole, type ArrayLike$1 as ArrayLike, type ArrayLikeValue, type Collection, type CollectionValue, type Dictionary, type DictionaryValue, type Evt, type EvtListener, assign, assignIn, average, between, bind$, camelCase, capitalize, chunk, clamp, create$, debounce, difference, entries, entriesIn, every, filter, find, find$, findAll$, findKey, findLastKey, forEach, forEachRight, get, groupBy, has, intersection, is, isArray, isArrayLike, isBlank, isBoolean, isDate, isDateLike, isElement, isEmpty, isEqual, isError, isFunction, isMap, isNull, isNullish, isNumber, isObject, isPlainObject, isRegExp, isSet, isString, isSymbol, isUndefined, isWeakMap, isWeakSet, kebabCase, keys, keysIn, map, off, omit, on, pascalCase, pick, range, reduce, reduceRight, set, shuffle, sleep, snakeCase, some, sum, tagType, throttle, times, useStorage, values, valuesIn };