source: node_modules/d3-hierarchy/src/array.js

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

Prototype 1.1

  • Property mode set to 100644
File size: 410 bytes
Line 
1export default function(x) {
2 return typeof x === "object" && "length" in x
3 ? x // Array, TypedArray, NodeList, array-like
4 : Array.from(x); // Map, Set, iterable, string, or anything else
5}
6
7export function shuffle(array, random) {
8 let m = array.length,
9 t,
10 i;
11
12 while (m) {
13 i = random() * m-- | 0;
14 t = array[m];
15 array[m] = array[i];
16 array[i] = t;
17 }
18
19 return array;
20}
Note: See TracBrowser for help on using the repository browser.