import { Enum } from '../types'; /** * Calculates the absolute value of a number. * * @param value - The number to calculate the absolute value of. * @returns The absolute value of the input number. */ declare function absoluteValue(value: number): number; /** * Executes multiple promises and returns an array of settled results. * * @param promises - The promises to execute. * @returns A promise that resolves to an array of fulfilled values. */ declare function promiseAllSettled(...promises: Promise[]): Promise; /** * This function fulfills as soon as one of the promises in the iterable fulfills, with the value of the first promise that fulfills. * ECMA2020 introduced Promise.any() which is a built-in method that does the same thing. * * @param promises - An iterable of unawaited promises to watch. * @returns A promise that resolves with the value of the first promise to be fulfilled or rejects with an array of rejection reasons if the promises rejected. */ declare function promiseAny(promises: Promise[]): Promise; /** * Checks if a value is a valid member of an enum. * * @param enumType - The enum to check against. * @param value - The value to check. * @returns True if the value is a valid member of the enum, false otherwise. */ declare function isInEnum(enumType: Enum, value: string | number): boolean; /** * Extracts values from an array of enums. * * @param values The array of values to extract from. * @param enumType The enum type to filter the values against. * @returns An array of values that are present in the enum. */ declare function extractValuesFromEnumArray(values: T[], enumType: Enum): T[]; /** * Executes a promise-based operation conditionally based on a boolean condition. * * @param operation - The promise-based operation to be executed. * @param condition - The boolean condition that determines whether to execute the operation or use the fallback. * @param fallback - An optional fallback function to be executed if the condition is false. Its result will be returned as a promise. * @returns A promise that resolves to the result of the operation or the fallback function. */ declare function useConditionalPromise(operation: () => Promise, condition: boolean, fallback?: () => any): Promise; /** * Validates the fields to update in an entity object. * * @template T - The type of the entity object. * @param {new () => T} classType - The constructor function of the entity object. * @param {T} entity - The original entity object. * @param {Partial} fieldsToUpdate - The fields to update in the entity object. * @returns {boolean} - Returns true if there are fields to update, false otherwise. * @hazard Dtos should not be used as classType ⚠️. you can use an entity, it will not fail on missing fields in `entity`. */ declare function validateFieldsToUpdate(classType: new () => T, entity: T, fieldsToUpdate: Partial): boolean; /** * Retrieves the attributes of a class instance. * * @template T - The type of the class. * @param classType - The constructor function of the class. * @returns An array of attribute names. * @hazard Dtos should not be used as classType ⚠️. */ declare function getClassAttributes(classType: new () => T): string[]; /** * Executes the given async function in parallel for each item in the array. * Returns a promise that resolves to an array of results. * * @param array - The array of items to process. * @param func - The async function to execute for each item. * @param chunkSize - The number of items to process in each chunk (default: DEFAULT_CHUNK_SIZE). * @returns A promise that resolves to an array of results. */ declare function parallelize(array: T[], func: (item: T) => Promise, chunkSize?: number): Promise; /** * Wraps a synchronise function in a try-catch-finally block and calls the onError and onFinally respectably. * @template T - The return type of the synchronised function * @param fn {() => T} - The function to execute * @param onError {(error: Error) => void} - (Optional) The function to call if an error is thrown. * @param onFinally {() => void} - (Optional) The function to call after the try-catch block */ declare function tryCatch(fn: () => T, onError?: (error: Error) => void, onFinally?: () => void): T; /** * Determines whether the provided value is considered "empty". * * A value is considered empty if it is: * - `null` * - `undefined` * - An empty string (as determined by `isEmptyString`) * - An empty array (as determined by `isArrayEmpty`) * - An empty object (as determined by `isEmptyObject`) * * @param value - The value to check for emptiness. * @returns `true` if the value is empty; otherwise, `false`. */ declare function isEmptyValue(value?: any): boolean; /** * Determines if the provided value is an empty object. * * @param value - The value to check. If omitted, defaults to `undefined`. * @returns `true` if the value is an object with no own enumerable properties; otherwise, `false`. * * @example * isEmptyObject({}); // true * isEmptyObject({ a: 1 }); // false * isEmptyObject([]); // true (arrays are objects with keys) * isEmptyObject(null); // false * isEmptyObject(undefined); // false */ declare function isEmptyObject(value?: any): boolean; /** * Determines whether all values in the provided input are filled (not empty). * * For arrays: checks if all elements are filled. * For objects: checks if all property values are filled. * For primitives: checks if the value itself is filled. * * A value is considered empty if it is: * - `null` * - `undefined` * - An empty string * - An empty array * - An empty object * * @param value - The value to check. Can be an array, object, or any primitive type. * @returns `true` if all values are filled; otherwise, `false`. * * @example * // Arrays * isFullyPopulated([1, 'hello', { a: 1 }]); // true * isFullyPopulated([1, '', { a: 1 }]); // false (empty string) * isFullyPopulated([]); // false (empty array) * * @example * // Objects * isFullyPopulated({ a: 1, b: 'hello' }); // true * isFullyPopulated({ a: 1, b: '' }); // false (empty string) * isFullyPopulated({}); // false (empty object) * * @example * // Primitives * isFullyPopulated('hello'); // true * isFullyPopulated(''); // false * isFullyPopulated(0); // true (0 is considered filled) * isFullyPopulated(null); // false */ declare function isFullyPopulated(value?: any): boolean; /** * Remove undefined properties from an object * @param obj {T} - The object to remove undefined properties from * @param fields {string[]} - Optional fields to pick from the object * @param excludeNulls - When true, also omits null values (uses isNil); defaults to false (uses isUndefined) * @returns - The object without undefined properties */ declare function pickDefinedFields(obj?: T, fields?: string[], excludeNulls?: boolean): Record; export { absoluteValue, extractValuesFromEnumArray, getClassAttributes, isInEnum, parallelize, promiseAllSettled, promiseAny, useConditionalPromise, validateFieldsToUpdate, tryCatch, isEmptyValue, isEmptyObject, isFullyPopulated, pickDefinedFields, };