Skip to content

Latest commit

 

History

History
41 lines (34 loc) · 863 Bytes

randomItemInArray.md

File metadata and controls

41 lines (34 loc) · 863 Bytes

piupiu.RandomItemInArray: MockFactory<any>

Return a random item / array of items from an input array.

Source

Since

0.1.0

Description

piupiu.RandomItemInArray: MockFactory<any>

Arguments

.getOne({ options?: {array?: any[]})

(boolean): Returns a random item from input array.

.getArray({ length?: number, options?: {array?: any[]})

(boolean[]): Returns an Array of random items from input array.

Example

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]