Return a random item / array of items from an input array.
0.1.0
piupiu.RandomItemInArray: MockFactory<any>
(boolean)
: Returns a random item from input array.
(boolean[])
: Returns anArray
of random items from input array.
piupiu.RandomItemInArray.getOne();
// undefined
piupiu.RandomItemInArray.getOne({
options: {
array: [1, 2, 3, 4]
}
});
// 3
piupiu.RandomItemInArray.getArray({
length: 2,
options: {
array: [1, 2, 3, 4]
}
});
// [1, 3]