|
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.1 KB
|
| Line | |
|---|
| 1 | /**
|
|---|
| 2 | * Gets a random element from collection.
|
|---|
| 3 | *
|
|---|
| 4 | * @template T
|
|---|
| 5 | * @param {readonly [T, ...T[]]} collection - The collection to sample.
|
|---|
| 6 | * @returns {T} Returns the random element.
|
|---|
| 7 | *
|
|---|
| 8 | * @example
|
|---|
| 9 | * sample([1, 2, 3, 4]);
|
|---|
| 10 | * // => 2
|
|---|
| 11 | */
|
|---|
| 12 | declare function sample<T>(collection: readonly [T, ...T[]]): T;
|
|---|
| 13 | /**
|
|---|
| 14 | * Gets a random element from collection.
|
|---|
| 15 | *
|
|---|
| 16 | * @template T
|
|---|
| 17 | * @param {Record<string, T> | Record<number, T> | null | undefined} collection - The collection to sample.
|
|---|
| 18 | * @returns {T | undefined} Returns the random element.
|
|---|
| 19 | *
|
|---|
| 20 | * @example
|
|---|
| 21 | * sample({ 'a': 1, 'b': 2, 'c': 3 });
|
|---|
| 22 | * // => 2
|
|---|
| 23 | */
|
|---|
| 24 | declare function sample<T>(collection: Record<string, T> | Record<number, T> | null | undefined): T | undefined;
|
|---|
| 25 | /**
|
|---|
| 26 | * Gets a random element from collection.
|
|---|
| 27 | *
|
|---|
| 28 | * @template T
|
|---|
| 29 | * @param {T | null | undefined} collection - The collection to sample.
|
|---|
| 30 | * @returns {T[keyof T] | undefined} Returns the random element.
|
|---|
| 31 | *
|
|---|
| 32 | * @example
|
|---|
| 33 | * sample({ 'a': 1, 'b': 2, 'c': 3 });
|
|---|
| 34 | * // => 2
|
|---|
| 35 | */
|
|---|
| 36 | declare function sample<T extends object>(collection: T | null | undefined): T[keyof T] | undefined;
|
|---|
| 37 |
|
|---|
| 38 | export { sample };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.