source: node_modules/es-toolkit/dist/compat/array/size.d.mts

Last change on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 1.2 KB
Line 
1/**
2 * Returns the length of an array, string, or object.
3 *
4 * This function takes an array, string, or object and returns its length.
5 * For arrays and strings, it returns the number of elements or characters, respectively.
6 * For objects, it returns the number of enumerable properties.
7 *
8 * @template T - The type of the input value.
9 * @param {T[] | object | string | Map<unknown, T> | Set<T> | null | undefined } target - The value whose size is to be determined. It can be an array, string, or object.
10 * @returns {number} The size of the input value.
11 *
12 * @example
13 * const arr = [1, 2, 3];
14 * const arrSize = size(arr);
15 * // arrSize will be 3
16 *
17 * const str = 'hello';
18 * const strSize = size(str);
19 * // strSize will be 5
20 *
21 * const obj = { a: 1, b: 2, c: 3 };
22 * const objSize = size(obj);
23 * // objSize will be 3
24 *
25 * const emptyArr = [];
26 * const emptyArrSize = size(emptyArr);
27 * // emptyArrSize will be 0
28 *
29 * const emptyStr = '';
30 * const emptyStrSize = size(emptyStr);
31 * // emptyStrSize will be 0
32 *
33 * const emptyObj = {};
34 * const emptyObjSize = size(emptyObj);
35 * // emptyObjSize will be 0
36 */
37declare function size(collection: object | string | null | undefined): number;
38
39export { size };
Note: See TracBrowser for help on using the repository browser.