Merge pull request #34630 from rharriso/master

Allow SeamlessImmutable/ImmutableArray.concat to accept an array argument
This commit is contained in:
Benjamin Lichtman
2019-04-12 09:17:31 -07:00
committed by GitHub
2 changed files with 9 additions and 2 deletions
+1 -1
View File
@@ -105,7 +105,7 @@ declare namespace SeamlessImmutable {
map<TTarget>(mapFuction: (item: T) => TTarget): Immutable<TTarget[]>;
filter(filterFunction: (item: T) => boolean): Immutable<T[]>;
slice(start?: number, end?: number): Immutable<T[]>;
concat(...arr: T[]): Immutable<T[]>;
concat(...arr: Array<T|T[]>): Immutable<T[]>;
reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): Immutable<T>;
reduce<TTarget>(callbackfn: (previousValue: TTarget, currentValue: T, currentIndex: number, array: T[]) => TTarget, initialValue?: TTarget): Immutable<TTarget>;
reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): Immutable<T>;
@@ -120,7 +120,14 @@ interface ExtendedUser extends User {
// concat. Call the mutable array's 'concat' with the same args to ensure compatability. Make sure the output array is immutable.
array.asMutable().concat({ firstName: 'Happy', lastName: 'Cat' });
const concat: Immutable.Immutable<User[]> = array.concat({ firstName: 'Happy', lastName: 'Cat' });
const concat: Immutable.Immutable<User[]> = array
.concat({ firstName: 'Happy', lastName: 'Cat' }, { firstName: 'Silly', lastName: 'Cat' })
.concat([{firstName: 'saucy', lastName: 'Cat'}], {firstName: 'Fussy', lastName: 'Cat'})
.concat([
{firstName: 'Fancy', lastName: 'Cat'},
{firstName: 'Sassy', lastName: 'Cat'}],
[{firstName: 'Bossy', lastName: 'Cat'}
]);
concat.asMutable();
// reduce. Call the mutable array's 'reduce' with the same function to ensure compatability. Make sure the output array is immutable.