2023-12-18 13:12:25 +08:00
|
|
|
/*!
|
|
|
|
* repeat-element <https://github.com/jonschlinkert/repeat-element>
|
|
|
|
*
|
|
|
|
* Copyright (c) 2015-present, Jon Schlinkert.
|
|
|
|
* Licensed under the MIT license.
|
|
|
|
*/
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
module.exports = function repeat(ele, num) {
|
2024-01-16 21:26:16 +08:00
|
|
|
if (Array.prototype.fill) {
|
|
|
|
return new Array(num).fill(ele);
|
|
|
|
}
|
|
|
|
|
2023-12-18 13:12:25 +08:00
|
|
|
var arr = new Array(num);
|
|
|
|
|
|
|
|
for (var i = 0; i < num; i++) {
|
|
|
|
arr[i] = ele;
|
|
|
|
}
|
|
|
|
|
|
|
|
return arr;
|
|
|
|
};
|