-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
77 changed files
with
162 additions
and
180 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 |
---|---|---|
@@ -1,8 +1,6 @@ | ||
language: node_js | ||
node_js: | ||
- '6' | ||
- '5' | ||
- '4' | ||
before_script: | ||
- $(npm bin)/tsc --version | ||
script: | ||
|
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 was deleted.
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
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
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
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 |
---|---|---|
@@ -1,20 +1,20 @@ | ||
import * as assert from 'assert'; | ||
import buffer from '../src/buffer'; | ||
import Enumerable from '../src/'; | ||
|
||
describe('buffer()', () => { | ||
it('should generates a sequence of non-overlapping adjacent buffers over the source sequence', () => { | ||
const xs = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; | ||
assert.deepEqual(Array.from(buffer.call(xs, 3)), [[0, 1, 2], [3, 4, 5], [6, 7, 8], [9]]); | ||
assert.deepEqual(Array.from(buffer.call(xs, 5)), [[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]]); | ||
assert.deepEqual(Array.from(buffer.call([], 5)), []); | ||
assert.deepEqual(Array.from(buffer.call(xs, 3, 2)), [[0, 1, 2], [2, 3, 4], [4, 5, 6], [6, 7, 8], [8, 9]]); | ||
assert.deepEqual(Array.from(buffer.call(xs, 3, 4)), [[0, 1, 2], [4, 5, 6], [8, 9]]); | ||
assert.deepEqual(new Enumerable(xs).buffer(3).toArray(), [[0, 1, 2], [3, 4, 5], [6, 7, 8], [9]]); | ||
assert.deepEqual(new Enumerable(xs).buffer(5).toArray(), [[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]]); | ||
assert.deepEqual(new Enumerable([]).buffer(5).toArray(), []); | ||
assert.deepEqual(new Enumerable(xs).buffer(3, 2).toArray(), [[0, 1, 2], [2, 3, 4], [4, 5, 6], [6, 7, 8], [8, 9]]); | ||
assert.deepEqual(new Enumerable(xs).buffer(3, 4).toArray(), [[0, 1, 2], [4, 5, 6], [8, 9]]); | ||
}); | ||
|
||
it('should throws the exception if "count" or "skip" arguments is less than or equal to 0', () => { | ||
assert.throws(() => Array.from(buffer.call([], 0)), RangeError); | ||
assert.throws(() => Array.from(buffer.call([], 1, 0)), RangeError); | ||
assert.throws(() => Array.from(buffer.call([], 0, 1)), RangeError); | ||
assert.throws(() => Array.from(buffer.call([], 0, 0)), RangeError); | ||
assert.throws(() => new Enumerable([]).buffer(0).toArray(), RangeError); | ||
assert.throws(() => new Enumerable([]).buffer(1, 0).toArray(), RangeError); | ||
assert.throws(() => new Enumerable([]).buffer(0, 1).toArray(), RangeError); | ||
assert.throws(() => new Enumerable([]).buffer(0, 0).toArray(), RangeError); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -1,10 +1,10 @@ | ||
import * as assert from 'assert'; | ||
import concat from '../src/concat'; | ||
import Enumerable from '../src/'; | ||
|
||
describe('concat()', () => { | ||
it('should concatenates two sequences', () => { | ||
assert.deepEqual(Array.from(concat.call([], [])), []); | ||
assert.deepEqual(Array.from(concat.call([1, 2, 3], [4, 5, 6])), [1, 2, 3, 4, 5, 6]); | ||
assert.deepEqual(Array.from(concat.call([1, 2, 3], [4, 5, 6], [7, 8, 9])), [1, 2, 3, 4, 5, 6, 7, 8, 9]); | ||
assert.deepEqual(new Enumerable([]).concat([]).toArray(), []); | ||
assert.deepEqual(new Enumerable([1, 2, 3]).concat([4, 5, 6]).toArray(), [1, 2, 3, 4, 5, 6]); | ||
assert.deepEqual(new Enumerable([1, 2, 3]).concat([4, 5, 6], [7, 8, 9]).toArray(), [1, 2, 3, 4, 5, 6, 7, 8, 9]); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -1,12 +1,12 @@ | ||
import * as assert from 'assert'; | ||
import defaultIfEmpty from '../src/defaultIfEmpty'; | ||
import Enumerable from '../src/'; | ||
|
||
describe('defaultIfEmpty()', () => { | ||
it('should returns the elements of the specified sequence', () => { | ||
assert.deepEqual(Array.from(defaultIfEmpty.call([1, 2, 3], 123)), [1, 2, 3]); | ||
assert.deepEqual(new Enumerable([1, 2, 3]).defaultIfEmpty(123).toArray(), [1, 2, 3]); | ||
}); | ||
|
||
it('should returns the specified value in a singleton collection if the sequence is empty', () => { | ||
assert.deepEqual(Array.from(defaultIfEmpty.call([], 123)), [123]); | ||
assert.deepEqual(new Enumerable([]).defaultIfEmpty(123).toArray(), [123]); | ||
}); | ||
}); |
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
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 |
---|---|---|
@@ -1,43 +1,40 @@ | ||
import * as assert from 'assert'; | ||
import elementAtOrDefault from '../src/elementAtOrDefault'; | ||
import orderBy from '../src/orderBy'; | ||
import skip from '../src/skip'; | ||
import take from '../src/take'; | ||
import Enumerable from '../src/'; | ||
|
||
describe('elementAtOrDefault()', () => { | ||
it('should returns the element at a specified index in a sequence', () => { | ||
const xs = [1, 2, 3, 4]; | ||
|
||
assert.strictEqual(elementAtOrDefault.call(xs, 0), 1); | ||
assert.strictEqual(elementAtOrDefault.call(xs, 1), 2); | ||
assert.strictEqual(elementAtOrDefault.call(xs, 2), 3); | ||
assert.strictEqual(elementAtOrDefault.call(xs, 3), 4); | ||
assert.strictEqual(new Enumerable(xs).elementAtOrDefault(0), 1); | ||
assert.strictEqual(new Enumerable(xs).elementAtOrDefault(1), 2); | ||
assert.strictEqual(new Enumerable(xs).elementAtOrDefault(2), 3); | ||
assert.strictEqual(new Enumerable(xs).elementAtOrDefault(3), 4); | ||
}); | ||
|
||
it('should returns a default value if the index is out of range', () => { | ||
const xs = [1, 2, 3, 4]; | ||
|
||
assert.strictEqual(elementAtOrDefault.call(xs, 4, 123), 123); | ||
assert.strictEqual(elementAtOrDefault.call(xs, 4), null); | ||
assert.strictEqual(new Enumerable(xs).elementAtOrDefault(4, 123), 123); | ||
assert.strictEqual(new Enumerable(xs).elementAtOrDefault(4), null); | ||
}); | ||
|
||
it('should works with orderBy()', () => { | ||
const xs = [3, 2, 4, 1]; | ||
|
||
assert.strictEqual(elementAtOrDefault.call(orderBy.call(xs), 0), 1); | ||
assert.strictEqual(elementAtOrDefault.call(orderBy.call(xs), 1), 2); | ||
assert.strictEqual(elementAtOrDefault.call(orderBy.call(xs), 2), 3); | ||
assert.strictEqual(elementAtOrDefault.call(orderBy.call(xs), 3), 4); | ||
assert.strictEqual(elementAtOrDefault.call(take.call(orderBy.call(xs), 2), 0), 1); | ||
assert.strictEqual(elementAtOrDefault.call(take.call(orderBy.call(xs), 2), 1), 2); | ||
assert.strictEqual(elementAtOrDefault.call(skip.call(orderBy.call(xs), 2), 0), 3); | ||
assert.strictEqual(elementAtOrDefault.call(skip.call(orderBy.call(xs), 2), 1), 4); | ||
assert.strictEqual(elementAtOrDefault.call(skip.call(take.call(orderBy.call(xs), 2), 1), 0), 2); | ||
assert.strictEqual(elementAtOrDefault.call(take.call(skip.call(orderBy.call(xs), 2), 1), 0), 3); | ||
assert.strictEqual(new Enumerable(xs).orderBy().elementAtOrDefault(0), 1); | ||
assert.strictEqual(new Enumerable(xs).orderBy().elementAtOrDefault(1), 2); | ||
assert.strictEqual(new Enumerable(xs).orderBy().elementAtOrDefault(2), 3); | ||
assert.strictEqual(new Enumerable(xs).orderBy().elementAtOrDefault(3), 4); | ||
assert.strictEqual(new Enumerable(xs).orderBy().take(2).elementAtOrDefault(0), 1); | ||
assert.strictEqual(new Enumerable(xs).orderBy().take(2).elementAtOrDefault(1), 2); | ||
assert.strictEqual(new Enumerable(xs).orderBy().skip(2).elementAtOrDefault(0), 3); | ||
assert.strictEqual(new Enumerable(xs).orderBy().skip(2).elementAtOrDefault(1), 4); | ||
assert.strictEqual(new Enumerable(xs).orderBy().take(2).skip(1).elementAtOrDefault(0), 2); | ||
assert.strictEqual(new Enumerable(xs).orderBy().skip(2).take(1).elementAtOrDefault(0), 3); | ||
|
||
assert.strictEqual(elementAtOrDefault.call(orderBy.call(xs), 4, 123), 123); | ||
assert.strictEqual(elementAtOrDefault.call(take.call(orderBy.call(xs), 2), 3, 123), 123); | ||
assert.strictEqual(elementAtOrDefault.call(skip.call(take.call(orderBy.call(xs), 2), 1), 1, 123), 123); | ||
assert.strictEqual(elementAtOrDefault.call(take.call(skip.call(orderBy.call(xs), 2), 1), 1, 123), 123); | ||
assert.strictEqual(new Enumerable(xs).orderBy().elementAtOrDefault(4, 123), 123); | ||
assert.strictEqual(new Enumerable(xs).orderBy().take(2).elementAtOrDefault(3, 123), 123); | ||
assert.strictEqual(new Enumerable(xs).orderBy().take(2).skip(1).elementAtOrDefault(1, 123), 123); | ||
assert.strictEqual(new Enumerable(xs).orderBy().skip(2).take(1).elementAtOrDefault(1, 123), 123); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -1,42 +1,39 @@ | ||
import * as assert from 'assert'; | ||
import elementAt from '../src/elementAt'; | ||
import orderBy from '../src/orderBy'; | ||
import skip from '../src/skip'; | ||
import take from '../src/take'; | ||
import Enumerable from '../src/'; | ||
|
||
describe('elementAt()', () => { | ||
it('should returns the element at a specified index in a sequence', () => { | ||
const xs = [1, 2, 3, 4]; | ||
|
||
assert.strictEqual(elementAt.call(xs, 0), 1); | ||
assert.strictEqual(elementAt.call(xs, 1), 2); | ||
assert.strictEqual(elementAt.call(xs, 2), 3); | ||
assert.strictEqual(elementAt.call(xs, 3), 4); | ||
assert.strictEqual(new Enumerable(xs).elementAt(0), 1); | ||
assert.strictEqual(new Enumerable(xs).elementAt(1), 2); | ||
assert.strictEqual(new Enumerable(xs).elementAt(2), 3); | ||
assert.strictEqual(new Enumerable(xs).elementAt(3), 4); | ||
}); | ||
|
||
it('should throws the exception if index is out of range', () => { | ||
const xs = [1, 2, 3, 4]; | ||
|
||
assert.throws(() => elementAt.call(xs, 4)); | ||
assert.throws(() => new Enumerable(xs).elementAt(4)); | ||
}); | ||
|
||
it('should works with orderBy()', () => { | ||
const xs = [3, 2, 4, 1]; | ||
|
||
assert.strictEqual(elementAt.call(orderBy.call(xs), 0), 1); | ||
assert.strictEqual(elementAt.call(orderBy.call(xs), 1), 2); | ||
assert.strictEqual(elementAt.call(orderBy.call(xs), 2), 3); | ||
assert.strictEqual(elementAt.call(orderBy.call(xs), 3), 4); | ||
assert.strictEqual(elementAt.call(take.call(orderBy.call(xs), 2), 0), 1); | ||
assert.strictEqual(elementAt.call(take.call(orderBy.call(xs), 2), 1), 2); | ||
assert.strictEqual(elementAt.call(skip.call(orderBy.call(xs), 2), 0), 3); | ||
assert.strictEqual(elementAt.call(skip.call(orderBy.call(xs), 2), 1), 4); | ||
assert.strictEqual(elementAt.call(skip.call(take.call(orderBy.call(xs), 2), 1), 0), 2); | ||
assert.strictEqual(elementAt.call(take.call(skip.call(orderBy.call(xs), 2), 1), 0), 3); | ||
assert.strictEqual(new Enumerable(xs).orderBy().elementAt(0), 1); | ||
assert.strictEqual(new Enumerable(xs).orderBy().elementAt(1), 2); | ||
assert.strictEqual(new Enumerable(xs).orderBy().elementAt(2), 3); | ||
assert.strictEqual(new Enumerable(xs).orderBy().elementAt(3), 4); | ||
assert.strictEqual(new Enumerable(xs).orderBy().take(2).elementAt(0), 1); | ||
assert.strictEqual(new Enumerable(xs).orderBy().take(2).elementAt(1), 2); | ||
assert.strictEqual(new Enumerable(xs).orderBy().skip(2).elementAt(0), 3); | ||
assert.strictEqual(new Enumerable(xs).orderBy().skip(2).elementAt(1), 4); | ||
assert.strictEqual(new Enumerable(xs).orderBy().take(2).skip(1).elementAt(0), 2); | ||
assert.strictEqual(new Enumerable(xs).orderBy().skip(2).take(1).elementAt(0), 3); | ||
|
||
assert.throws(() => elementAt.call(orderBy.call(xs), 4)); | ||
assert.throws(() => elementAt.call(take.call(orderBy.call(xs), 2), 3)); | ||
assert.throws(() => elementAt.call(skip.call(take.call(orderBy.call(xs), 2), 1), 1)); | ||
assert.throws(() => elementAt.call(take.call(skip.call(orderBy.call(xs), 2), 1), 1)); | ||
assert.throws(() => new Enumerable(xs).orderBy().elementAt(4)); | ||
assert.throws(() => new Enumerable(xs).orderBy().take(2).elementAt(3)); | ||
assert.throws(() => new Enumerable(xs).orderBy().take(2).skip(1).elementAt(1)); | ||
assert.throws(() => new Enumerable(xs).orderBy().skip(2).take(1).elementAt(1)); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -1,11 +1,11 @@ | ||
import * as assert from 'assert'; | ||
import except from '../src/except'; | ||
import Enumerable from '../src/'; | ||
|
||
describe('except()', () => { | ||
it('should produces the set difference of two sequences', () => { | ||
assert.deepEqual(Array.from(except.call([], [])), []); | ||
assert.deepEqual(Array.from(except.call([1, 2, 3, 4, 5, 6], [2, 3, 4])), [1, 5, 6]); | ||
assert.deepEqual(Array.from(except.call([1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6], [2, 3, 4])), [1, 5, 6]); | ||
assert.deepEqual(Array.from(except.call([2, 3, 4], [1, 2, 3, 4, 5, 6])), []); | ||
assert.deepEqual(new Enumerable([]).except([]).toArray(), []); | ||
assert.deepEqual(new Enumerable([1, 2, 3, 4, 5, 6]).except([2, 3, 4]).toArray(), [1, 5, 6]); | ||
assert.deepEqual(new Enumerable([1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6]).except([2, 3, 4]).toArray(), [1, 5, 6]); | ||
assert.deepEqual(new Enumerable([2, 3, 4]).except([1, 2, 3, 4, 5, 6]).toArray(), []); | ||
}); | ||
}); |
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
Oops, something went wrong.