UNPKG

@resk/core

Version:

An innovative TypeScript framework that empowers developers to build applications with a fully decorator-based architecture for efficient resource management. By combining the power of decorators with a resource-oriented design, DecorRes enhances code cla

19 lines (18 loc) 863 B
/** * Returns a default array based on the provided arguments. * If there is only one argument, it returns the argument if it's an array, or an empty array if it's not. * If there are multiple arguments, it returns the first non-empty array found, or the first array if all are empty. * If no arrays are found, it returns an empty array. * * @template T The type of elements in the array. * @param args Variable number of arguments to check for arrays. * @returns The default array based on the provided arguments. * * @example * defaultArray([1, 2, 3]); // returns [1, 2, 3] * defaultArray(1, 2, 3); // returns [] * defaultArray([1, 2, 3], [4, 5, 6]); // returns [1, 2, 3] * defaultArray([], [4, 5, 6]); // returns [4, 5, 6] * defaultArray([], []); // returns [] */ export declare function defaultArray<T extends any = any>(...args: any[]): T[];