this repo has no description
at main 1.0 kB view raw
1/** 2 * Creates an array containing multiple copies of the elements of another array. 3 * 4 * For example, if A = [Q, W, E, R, T, Y], then calling repeating(A, 3) would return 5 * [Q, W, E, R, T, Y, Q, W, E, R, T, Y, Q, W, E, R, T, Y] 6 * 7 * @param elements The elements that will be repeated 8 * @param times The number of times all of the elements should appear in the new array. 9 */ 10export function arrayByRepeating(elements, times) { 11 if (times <= 0) { 12 return []; 13 } 14 let newArray = []; 15 for (let i = 0; i < times; i++) { 16 newArray = newArray.concat(elements); 17 } 18 return newArray; 19} 20export function partition(array, predicate) { 21 const part1 = []; 22 const part2 = []; 23 array.forEach((item) => (predicate(item) ? part1.push(item) : part2.push(item))); 24 return [part1, part2]; 25} 26export function isEmpty(elements) { 27 return elements.length === 0; 28} 29export function isNotEmpty(elements) { 30 return !isEmpty(elements); 31} 32//# sourceMappingURL=array-util.js.map