jsmodern
Version:
An extension to existing JavaScript, influenced by other great languages such as Rust, Dart, Java, Golang, etc.
12 lines • 377 B
JavaScript
export const repeat = {
label: 'repeat',
fn: function arrayRepeat(n) {
const ctx = this;
const len = ctx.length;
const nInt = 'number' !== typeof (n) ? 0 : Number(n);
if (!len || nInt < 1)
return [];
return Array.from(Array(nInt), () => ctx).reduce((p, o) => p.concat(o));
},
};
//# sourceMappingURL=repeat.js.map