import type { BaseBlockModel } from '@revesuite/store'; import type { Detail } from './types.js'; /** * Whether the block supports rendering its children. */ export declare function supportsChildren(model: BaseBlockModel): boolean; export declare function isEmpty(model: BaseBlockModel): boolean; export declare function almostEqual(a: number, b: number, epsilon?: number): boolean; export declare function createEvent(type: T, detail: Detail): CustomEvent>; export declare function noop(): void; /** * @example * ```ts * const log = (message: string) => console.log(`[${new Date().toISOString()}] ${message}`); * * const throttledLog = throttle(log, 1000); * * throttledLog("Hello, world!"); * throttledLog("Hello, world!"); * throttledLog("Hello, world!"); * throttledLog("Hello, world!"); * throttledLog("Hello, world!"); * ``` */ export declare function throttle void>(fn: (...args: Args) => void, limit: number, options?: { leading?: boolean; trailing?: boolean; }): T; export declare const debounce: void>(fn: T, limit: number, { leading, trailing }?: { leading?: boolean | undefined; trailing?: boolean | undefined; }) => T; /** * This function takes a value value, a minimum value min, and a maximum value max, * and returns the value of value clamped to the range [min, max]. * * This means that if value is less than min, the function will return min; * if value is greater than max, the function will return max; * otherwise, the function will return value. * * @example * ```ts * const x = clamp(10, 0, 5); // x will be 5 * const y = clamp(3, 0, 5); // y will be 3 * const z = clamp(-1, 0, 5); // z will be 0 * ``` */ export declare const clamp: (value: number, min: number, max: number) => number; /** * * @example * ```ts * const items = [ * {name: 'a', classroom: 'c1'}, * {name: 'b', classroom: 'c2'}, * {name: 'a', classroom: 't0'} * ] * const counted = countBy(items1, i => i.name); * // counted: { a: 2, b: 1} * ``` */ export declare function countBy(items: T[], key: (item: T) => string | number): Record; /** * @example * ```ts * const items = [{n: 1}, {n: 2}] * const max = maxBy(items, i => i.n); * // max: {n: 2} * ``` */ export declare function maxBy(items: T[], value: (item: T) => number): T | null; export declare function isControlledKeyboardEvent(e: KeyboardEvent): boolean; export declare function isPrintableKeyEvent(event: KeyboardEvent): boolean; /** * Checks if there are at least `n` elements in the array that match the given condition. * * @param arr - The input array of elements. * @param matchFn - A function that takes an element of the array and returns a boolean value * indicating if the element matches the desired condition. * @param n - The minimum number of matching elements required. * @returns A boolean value indicating if there are at least `n` matching elements in the array. * * @example * const arr = [1, 2, 3, 4, 5]; * const isEven = (num: number): boolean => num % 2 === 0; * console.log(atLeastNMatches(arr, isEven, 2)); // Output: true */ export declare function atLeastNMatches(arr: T[], matchFn: (element: T) => boolean, n: number): boolean; /** * Groups an array of elements based on a provided key function. * * @example * interface Student { * name: string; * age: number; * } * const students: Student[] = [ * { name: 'Alice', age: 25 }, * { name: 'Bob', age: 23 }, * { name: 'Cathy', age: 25 }, * ]; * const groupedByAge = groupBy(students, (student) => student.age.toString()); * console.log(groupedByAge); * // Output: { * '23': [ { name: 'Bob', age: 23 } ], * '25': [ { name: 'Alice', age: 25 }, { name: 'Cathy', age: 25 } ] * } */ export declare function groupBy(arr: T[], key: string | ((item: T) => string)): Record; /** * Checks if the name is a fuzzy match of the query. * * @example * ```ts * const name = 'John Smith'; * const query = 'js'; * const isMatch = isFuzzyMatch(name, query); * // isMatch: true * ``` */ export declare function isFuzzyMatch(name: string, query: string): boolean; export declare function toHex(color: string): string; export declare function capitalize(s: string): string; export declare function uncapitalize(s: string): string; //# sourceMappingURL=std.d.ts.map