-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: listOf now returns List.of<T> (#144)
- Loading branch information
1 parent
ab5aa92
commit fbb0e4f
Showing
3 changed files
with
42 additions
and
16 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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { listFrom, listOf } from './list.factory' | ||
|
||
describe('List Factory', () => { | ||
describe(listFrom.name, () => { | ||
it('should', () => { | ||
const sut = listFrom([1, 2]).filter(a => a > 1) | ||
|
||
expect(sut.toArray()).toEqual([2]) | ||
}) | ||
|
||
it('should handle undefined', () => { | ||
const sut = listFrom<number>().filter(a => a > 1) | ||
|
||
expect(sut.toArray()).toEqual([]) | ||
}) | ||
}) | ||
|
||
describe(listOf.name, () => { | ||
it('should handle nominal', () => { | ||
const sut = listOf(1, 2).filter(a => a > 1) | ||
|
||
expect(sut.toArray()).toEqual([2]) | ||
}) | ||
|
||
it('should handle undefined', () => { | ||
const sut = listOf<number>().filter(a => a > 1) | ||
|
||
expect(sut.toArray()).toEqual([]) | ||
}) | ||
}) | ||
}) | ||
|
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,17 +1,9 @@ | ||
import { List } from './list' | ||
|
||
export function listOf<T>(...args: T[]) { | ||
return List.of(args) | ||
return List.of<T>(...args) | ||
} | ||
|
||
// export function listFrom<T>(value?: T) { | ||
// return List.from<T>() | ||
// } | ||
|
||
// export function none<T>() { | ||
// return Maybe.none<T>() | ||
// } | ||
|
||
// export function some<T>(value: T) { | ||
// return maybe(value) | ||
// } | ||
export function listFrom<T>(value?: Iterable<T>) { | ||
return List.from<T>(value) | ||
} |
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