Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 13 additions & 20 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@

module.exports = function newArray(start, end) {
var n0 = typeof start === 'number',
n1 = typeof end === 'number'
start = +start;
end = +end;
if (!isNaN(start) && isNaN(end)) {
end = start;
start = 0;
} else if (isNaN(start) && isNaN(end)) {
start = end = 0;
}

if (n0 && !n1) {
end = start
start = 0
} else if (!n0 && !n1) {
start = 0
end = 0
}
const len = end - start;
if (len < 0) throw new Error("array length must be positive");

start = start|0
end = end|0
var len = end-start
if (len<0)
throw new Error('array length must be positive')

var a = new Array(len)
for (var i=0, c=start; i<len; i++, c++)
a[i] = c
return a
}
const a = new Array(len).fill(start).map((x, y) => x + y);
return a;
};