repl.txt (1817B)
1 2 {{alias}}( arr[, options] ) 3 Shuffles elements of an array-like object. 4 5 Parameters 6 ---------- 7 arr: ArrayLike 8 Array-like object to shuffle. 9 10 options: Object (optional) 11 Options. 12 13 options.copy: string (optional) 14 String indicating whether to return a copy (`deep`,`shallow` or `none`). 15 Default: `'shallow'`. 16 17 Returns 18 ------- 19 out: ArrayLike 20 Shuffled array-like object. 21 22 Examples 23 -------- 24 > var data = [ 1, 2, 3 ]; 25 > var out = {{alias}}( data ) 26 e.g., [ 3, 1, 2 ] 27 > out = {{alias}}( data, { 'copy': 'none' }); 28 > var bool = ( data === out ) 29 true 30 31 32 {{alias}}.factory( [options] ) 33 Returns a function to shuffle elements of array-like objects. 34 35 Parameters 36 ---------- 37 options: Object (optional) 38 Options. 39 40 options.seed: integer (optional) 41 Integer-valued seed. 42 43 options.copy: string (optional) 44 String indicating whether to return a copy (`deep`,`shallow` or `none`). 45 Default: `'shallow'`. 46 47 Returns 48 ------- 49 fcn: Function 50 Shuffle function. 51 52 Examples 53 -------- 54 > var myshuffle = {{alias}}.factory(); 55 56 // Set a seed: 57 > myshuffle = {{alias}}.factory({ 'seed': 239 }); 58 > var arr = [ 0, 1, 2, 3, 4 ]; 59 > var out = myshuffle( arr ) 60 e.g., [ 3, 4, 1, 0, 2 ] 61 62 // Use a different copy strategy: 63 > myshuffle = {{alias}}.factory({ 'copy': 'none', 'seed': 867 }); 64 65 // Created shuffle function mutates input array by default: 66 > arr = [ 1, 2, 3, 4, 5, 6 ]; 67 > out = myshuffle( arr ); 68 > var bool = ( arr === out ) 69 true 70 // Default option can be overridden: 71 > arr = [ 1, 2, 3, 4 ]; 72 > out = myshuffle( arr, { 'copy': 'shallow' }); 73 > bool = ( arr === out ) 74 false 75 76 See Also 77 -------- 78