-
-
Notifications
You must be signed in to change notification settings - Fork 32
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
129 changed files
with
4,102 additions
and
4,011 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 |
---|---|---|
|
@@ -4,5 +4,5 @@ | |
"singleQuote": true, | ||
"trailingComma": "all", | ||
"arrowParens": "avoid", | ||
"printWidth": 100 | ||
"printWidth": 80 | ||
} |
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,21 +1,63 @@ | ||
import { A } from '../..' | ||
import { expectType } from 'ts-expect' | ||
|
||
import { A, pipe } from '../..' | ||
|
||
describe('drop', () => { | ||
it('provides correct types', () => { | ||
expectType<ReadonlyArray<number>>(A.drop([1, 2, 3], 4)) | ||
expectType<ReadonlyArray<boolean>>(A.drop([true, true, false], 4)) | ||
}) | ||
|
||
it('returns the same values as the provided array', () => { | ||
expect(A.drop([1, 2, 3], -1)).toEqual([1, 2, 3]) | ||
}) | ||
|
||
it('returns an empty array', () => { | ||
expect(A.drop([], 0)).toEqual([]) | ||
expect(A.drop([1, 2, 3], 4)).toEqual([]) | ||
expect(A.drop([1, 2, 3], 3)).toEqual([]) | ||
expect(A.drop([1], 1)).toEqual([]) | ||
}) | ||
|
||
it('returns a new array that does not contain the first `n` items', () => { | ||
expect(A.drop([], 0)).toEqual([]) | ||
expect(A.drop([1, 2, 3], 0)).toEqual([1, 2, 3]) | ||
expect(A.drop([1], 1)).toEqual([]) | ||
expect(A.drop([1, 2, 3], 1)).toEqual([2, 3]) | ||
expect(A.drop([[1], [2]], 1)).toEqual([[2]]) | ||
expect(A.drop([true, true, false], 2)).toEqual([false]) | ||
}) | ||
|
||
it('*', () => { | ||
expect(A.drop([1], 1)).toEqual([]) | ||
expect(A.drop([1, 2, 3], 4)).toEqual([]) | ||
expect(A.drop([1, 2, 3], 2)).toEqual([3]) | ||
}) | ||
}) | ||
|
||
describe('drop (pipe)', () => { | ||
it('provides correct types', () => { | ||
expectType<ReadonlyArray<number>>(pipe([1, 2, 3], A.drop(4))) | ||
expectType<ReadonlyArray<boolean>>(pipe([true, true, false], A.drop(4))) | ||
}) | ||
|
||
it('returns the same values as the provided array', () => { | ||
expect(pipe([1, 2, 3], A.drop(-1))).toEqual([1, 2, 3]) | ||
}) | ||
|
||
it('returns an empty array', () => { | ||
expect(pipe([], A.drop(0))).toEqual([]) | ||
expect(pipe([1, 2, 3], A.drop(4))).toEqual([]) | ||
expect(pipe([1, 2, 3], A.drop(3))).toEqual([]) | ||
expect(pipe([1], A.drop(1))).toEqual([]) | ||
}) | ||
|
||
it('returns a new array that does not contain the first `n` items', () => { | ||
expect(pipe([1, 2, 3], A.drop(0))).toEqual([1, 2, 3]) | ||
expect(pipe([1, 2, 3], A.drop(1))).toEqual([2, 3]) | ||
expect(pipe([[1], [2]], A.drop(1))).toEqual([[2]]) | ||
expect(pipe([true, true, false], A.drop(2))).toEqual([false]) | ||
}) | ||
|
||
it('*', () => { | ||
expect(pipe([1, 2, 3, 4], A.drop(2))).toEqual([3, 4]) | ||
}) | ||
}) |
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,15 +1,15 @@ | ||
import { A } from '../..' | ||
import { A, O } from '../..' | ||
|
||
describe('get', () => { | ||
it('returns None', () => { | ||
expect(A.get([], 0)).toBeNone() | ||
expect(A.get([1, 2, 3], 3)).toBeNone() | ||
expect(A.get([], 0)).toEqual(O.None) | ||
expect(A.get([1, 2, 3], 3)).toEqual(O.None) | ||
}) | ||
|
||
it('returns Some', () => { | ||
expect(A.get([1, 2, 3], 0)).toBeSome(1) | ||
expect(A.get([0, 2, 3], 0)).toBeSome(0) | ||
expect(A.get([true, true, false], 2)).toBeSome(false) | ||
expect(A.get([[1], [2]], 1)).toBeSome([2]) | ||
expect(A.get([1, 2, 3], 0)).toEqual(O.Some(1)) | ||
expect(A.get([0, 2, 3], 0)).toEqual(O.Some(0)) | ||
expect(A.get([true, true, false], 2)).toEqual(O.Some(false)) | ||
expect(A.get([[1], [2]], 1)).toEqual(O.Some([2])) | ||
}) | ||
}) |
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,19 +1,19 @@ | ||
import { A } from '../..' | ||
import { A, O } from '../..' | ||
|
||
describe('getBy', () => { | ||
it('returns None', () => { | ||
expect(A.getBy([1, 2, 3], n => n === 0)).toBeNone() | ||
expect(A.getBy([false, false, false], state => state)).toBeNone() | ||
expect(A.getBy([1, 2, 3], n => n === 0)).toEqual(O.None) | ||
expect(A.getBy([false, false, false], state => state)).toEqual(O.None) | ||
expect( | ||
A.getBy([{ prop: null }, { prop: false }, { prop: undefined }], obj => Boolean(obj.prop)), | ||
).toBeNone() | ||
).toEqual(O.None) | ||
}) | ||
|
||
it('returns Some', () => { | ||
expect(A.getBy(['a', 'ab', 'bc'], str => str.length === 2)).toBeSome('ab') | ||
expect(A.getBy([1, 2, 3], value => value === 2)).toBeSome(2) | ||
expect(A.getBy(['a', 'ab', 'bc'], str => str.length === 2)).toEqual(O.Some('ab')) | ||
expect(A.getBy([1, 2, 3], value => value === 2)).toEqual(O.Some(2)) | ||
expect( | ||
A.getBy([{ prop: 'ab' }, { prop: 'abc' }, { prop: 'bcd' }], obj => obj.prop.length > 2), | ||
).toBeSome({ prop: 'abc' }) | ||
).toEqual(O.Some({ prop: 'abc' })) | ||
}) | ||
}) |
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,15 +1,15 @@ | ||
import { A } from '../..' | ||
import { A, O } from '../..' | ||
|
||
describe('head', () => { | ||
it('returns None', () => { | ||
expect(A.head([])).toBeNone() | ||
expect(A.head([])).toEqual(O.None) | ||
}) | ||
|
||
it('returns Some', () => { | ||
expect(A.head([1, 2, 3])).toBeSome(1) | ||
expect(A.head([0, 2, 3])).toBeSome(0) | ||
expect(A.head([false, true, true])).toBeSome(false) | ||
expect(A.head([{ prop: 1 }, { prop: 2 }])).toBeSome({ prop: 1 }) | ||
expect(A.head([[1], [2]])).toBeSome([1]) | ||
expect(A.head([1, 2, 3])).toEqual(O.Some(1)) | ||
expect(A.head([0, 2, 3])).toEqual(O.Some(0)) | ||
expect(A.head([false, true, true])).toEqual(O.Some(false)) | ||
expect(A.head([{ prop: 1 }, { prop: 2 }])).toEqual(O.Some({ prop: 1 })) | ||
expect(A.head([[1], [2]])).toEqual(O.Some([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
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.