source: node_modules/es-toolkit/dist/compat/array/sampleSize.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.0 KB
Line 
1/**
2 * Returns a sample element array of a specified size from a collection.
3 *
4 * @template T
5 * @param {Record<string, T> | Record<number, T> | null | undefined} collection - The collection to sample from.
6 * @param {number} [n] - The size of sample.
7 * @returns {T[]} A new array with sample size applied.
8 *
9 * @example
10 * sampleSize([1, 2, 3], 2);
11 * // => [2, 3] (example, actual result will vary)
12 */
13declare function sampleSize<T>(collection: Record<string, T> | Record<number, T> | null | undefined, n?: number): T[];
14/**
15 * Returns a sample element array of a specified size from an object.
16 *
17 * @template T
18 * @param {T | null | undefined} collection - The object to sample from.
19 * @param {number} [n] - The size of sample.
20 * @returns {Array<T[keyof T]>} A new array with sample size applied.
21 *
22 * @example
23 * sampleSize({ a: 1, b: 2, c: 3 }, 2);
24 * // => [2, 3] (example, actual result will vary)
25 */
26declare function sampleSize<T extends object>(collection: T | null | undefined, n?: number): Array<T[keyof T]>;
27
28export { sampleSize };
Note: See TracBrowser for help on using the repository browser.