-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
37 lines (26 loc) · 771 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
var isObject = require('lodash.isobject');
var isArray = require('lodash.isarray');
var random = require('./helpers/randomize-array.js');
module.exports = function(iterable) {
var entries;
var ret;
switch (true) {
case isArray(iterable):
ret = random(iterable.slice());
break;
case isObject(iterable):
ret = {};
entries = random(Object.keys(iterable));
for (var i = 0; i < entries.length; i++) {
ret[i] = iterable[i];
}
break;
case typeof iterable === 'string':
ret = random(iterable.split('')).join('');
break;
default:
ret = iterable;
break;
}
return ret;
};