-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added exjs.range to create an enumeration of ranges.
- Loading branch information
Showing
8 changed files
with
99 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,5 @@ src/packages | |
node_modules/**/* | ||
.idea* | ||
test/*.js | ||
test/*.js.map | ||
dist/*.js.map |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/// <reference path="enumerable.ts" /> | ||
|
||
module exjs { | ||
function rangeEnumerator (start: number, end: number, increment: number): IEnumerator<number> { | ||
var i = start - increment; | ||
var e = { | ||
current: undefined, | ||
moveNext: function (): boolean { | ||
i += increment; | ||
if (i >= end) | ||
return false; | ||
e.current = i; | ||
return true; | ||
} | ||
}; | ||
return e; | ||
} | ||
|
||
export function range (start: number, end: number, increment?: number): IEnumerable<number> { | ||
start = start || 0; | ||
end = end || 0; | ||
if (start > end) | ||
throw new Error("Start cannot be greater than end."); | ||
if (increment == null) | ||
increment = 1; | ||
var e = new Enumerable<number>(); | ||
e.getEnumerator = () => rangeEnumerator(start, end, increment); | ||
return e; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters