Skip to content

Instantly share code, notes, and snippets.

View kamoroso94's full-sized avatar
:atom:

Kyle Amoroso kamoroso94

:atom:
View GitHub Profile
@kamoroso94
kamoroso94 / range.js
Last active January 26, 2019 06:15
A simple range generator in JavaScript for iterating through a left-closed, right-open interval
function* range(start, end, step) {
if(end === undefined) {
end = start;
start = 0;
}
if(step === 0) throw new RangeError('step must be non-zero');
if(step === undefined) step = Math.sign(end - start);
const dir = Math.sign(step);