Skip to content
BSick7 edited this page May 10, 2014 · 8 revisions

All methods are scoped to exjs namespace. The extension method en() is attached to Array.prototype to allow for terse usage.

The IEnumerable pattern is an imitation of C#'s IEnumerable pattern:

interface IEnumerable<T> {
  getEnumerator(): IEnumerator<T>;
}
interface IEnumerator<T> {
  current: T;
  moveNext(): boolean;
}

These interfaces allow enumerable methods to defer until execution is necessary.

interface ISomething {
  member1: any;
}
var arr: ISomething[] = [];
// ...Fill array
var e = arr.en()
  .select(x => x.member1);
// At this point, we have not enumerated
var m1s = e.toArray();
// Now we have enumerated and projected 'member1' to a separate array.

API Reference

Clone this wiki locally