diff --git a/lib/make/arrays.js b/lib/make/arrays.js index 639461e..0d05fb6 100644 --- a/lib/make/arrays.js +++ b/lib/make/arrays.js @@ -6,13 +6,18 @@ const make = require('../make') const random = require('../random') class arrays extends make { - static filledArray (fn, limit) { - let array = [] - let size = limit || random.number(make.number.tiny()) + 1 + /** + * Returns an array containing random values generated by the supplied function + * @param {Function} fn - Function used to generate values + * @param {number} limit - Length of the array + * @returns {Array} + */ + static filledArray (fn, limit = make.number.tiny()) { + const array = [] - for (let i = 0; i < size; i++) { - let value = random.pick(fn) - if (value !== undefined) { + for (let i = 0; i < limit; i++) { + const value = random.pick(fn) + if (value !== null) { array.push(value) } }