Skip to main content

Arrays

equals#

Check if two arrays are equal.

const td = require('types-doodler');
const options = { array1: [1, 2, 3, 4, 5], array2: [3, 4, 5, 1, 2], ordered: true };
const equals = td.arrays.equals(options);
console.log(equals); // true
PropertyDescriptionTypeDefaultRequired
array1First array.array✔️
array2Second array.array✔️
orderedSorts both arrays before comparison.booleanfalse

random#

Get one or more random elements from a provided array. Those returned elements could be repeated.

const td = require('types-doodler');
const options = { array: [1, 2, 3, 4, 5], quantity: 3 };
const random = td.arrays.random(options);
console.log(random); // [1, 1, 4]
PropertyDescriptionTypeDefaultRequired
arraySource array.array✔️
quantityAmount of random elements to be returned.number1

shuffle#

Shuffles the provided array.

const td = require('types-doodler');
const options = { array: [1, 2, 3, 4, 5] };
const shuffle = td.arrays.shuffle(options);
console.log(shuffle); // [4, 2, 3, 5, 1]
PropertyDescriptionTypeDefaultRequired
arrayArray to be shuffled.array✔️