main
Last change
on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
676 bytes
|
Line | |
---|
1 | import arrayShuffle from './_arrayShuffle.js';
|
---|
2 | import baseShuffle from './_baseShuffle.js';
|
---|
3 | import isArray from './isArray.js';
|
---|
4 |
|
---|
5 | /**
|
---|
6 | * Creates an array of shuffled values, using a version of the
|
---|
7 | * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
|
---|
8 | *
|
---|
9 | * @static
|
---|
10 | * @memberOf _
|
---|
11 | * @since 0.1.0
|
---|
12 | * @category Collection
|
---|
13 | * @param {Array|Object} collection The collection to shuffle.
|
---|
14 | * @returns {Array} Returns the new shuffled array.
|
---|
15 | * @example
|
---|
16 | *
|
---|
17 | * _.shuffle([1, 2, 3, 4]);
|
---|
18 | * // => [4, 1, 3, 2]
|
---|
19 | */
|
---|
20 | function shuffle(collection) {
|
---|
21 | var func = isArray(collection) ? arrayShuffle : baseShuffle;
|
---|
22 | return func(collection);
|
---|
23 | }
|
---|
24 |
|
---|
25 | export default shuffle;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.