@tamara027/lerna-terminal
Version:
Powerful cli ui for monorepos
28 lines (22 loc) • 1.19 kB
JavaScript
;
/**
* @param {number} length - the length ot the array
* @param {string|number|Array|Object|Function} value - the value with which the array should be filled
* @returns {void}
**/
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
function getFilledArray() {
var length = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 10;
var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
return Array.apply(undefined, _toConsumableArray(Array(length))).map(function () {
if (Array.isArray(value)) {
return value.concat([]);
}
if ((typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object') {
return Object.assign({}, value);
}
return value;
});
}
module.exports = getFilledArray;