Skip to content

Commit

Permalink
Added remaining array transitions
Browse files Browse the repository at this point in the history
  • Loading branch information
taras committed Apr 6, 2019
1 parent b0a2ca2 commit cd5bedb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
4 changes: 4 additions & 0 deletions types/microstates.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ declare module "microstates" {
slice(start?: number, end?: number): ArrayType<T>
sort(fn: (a: any, b: any) => number): ArrayType<T>
filter(fn: (member: T) => boolean): ArrayType<T>
map(fn: (member: T) => T): ArrayType<T>
remove(item: any): ArrayType<T>
clear(): ArrayType<T>
initialize(value: any): ArrayType<T>
}

interface ArrayTypeConstructor {
Expand Down
20 changes: 20 additions & 0 deletions types/types.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,24 @@ describe('ArrayType', () => {
a.filter((item) => (item.state + '!!!') === 'hello!!!')
)
});
it('has map transition that returns ArrayType', () => {
expectType<ArrayType<StringType>>(
a.map(item => item.concat('!!!'))
)
});
it('has remove transition that returns ArrayType', () => {
expectType<ArrayType<StringType>>(
a.remove('hello')
)
});
it('has clear transition that returns ArrayType', () => {
expectType<ArrayType<StringType>>(
a.clear()
)
});
it('has initialize transition taht returns ArrayType', () => {
expectType<ArrayType<StringType>>(
a.initialize('foo')
)
});
});

0 comments on commit cd5bedb

Please sign in to comment.