diff --git a/src/__benchmarks__/index.ts b/src/__benchmarks__/index.ts index ecb05b4..a25fae3 100644 --- a/src/__benchmarks__/index.ts +++ b/src/__benchmarks__/index.ts @@ -8,120 +8,46 @@ import { sumBenchmark } from './sum'; import { listBenchmark } from './list'; import { queueBenchmark } from './queue'; import { xorBenchmark } from './xor'; -import { IEnumerable } from '../types'; -import { ArrayEnumerable } from '../enumerables/ArrayEnumerable'; -import { BasicEnumerable } from '../enumerables/BasicEnumerable'; -import { from } from '../functions/from'; -declare global { - // eslint-disable-next-line @typescript-eslint/no-empty-interface - interface Array extends Omit, 'forEach' | 'toString' | 'any'> {} - // eslint-disable-next-line @typescript-eslint/no-empty-interface - interface Map extends Omit, 'forEach' | 'toString' | 'any'> {} - // eslint-disable-next-line @typescript-eslint/no-empty-interface - interface Set extends Omit, 'forEach' | 'toString' | 'any'> {} - // eslint-disable-next-line @typescript-eslint/no-empty-interface - interface String extends Omit, 'forEach' | 'toString' | 'any'> {} -} - -const arrEnumProps = ArrayEnumerable.prototype; -const enumProps = BasicEnumerable.prototype; -const arrProps = Array.prototype; -const nativeProps = new Set(Object.getOwnPropertyNames(arrProps)); -const protos = [ - [Array.prototype, Array.name], - [Map.prototype, Map.name], - [Set.prototype, Set.name], - [String.prototype, String.name] -]; -const nativeProtos = new Set(protos.map(([p]) => Object.getOwnPropertyNames(p)).flat()); - -const enumPropNames = Object.getOwnPropertyNames(enumProps); -const arrEnumPropNames = Object.getOwnPropertyNames(arrEnumProps); +const args = process.argv.slice(2); -for (const [proto, protoName] of protos) { - for (const prop of enumPropNames) { - if (!nativeProtos.has(prop)) { - (proto as any)[prop as any] = function (...params: any[]) { - return (from(this) as any)[prop as any](...params); - }; - } else { - console.log(`${prop} is a collision on ${protoName}!!!`); - } - } +if (args.length === 0) { + throw new Error('Benchmark name must be passed.'); } -// declare global { -// interface Array { -// where(predicate: (item: T) => boolean): IEnumerable; -// // take(amount: number): Array; -// } -// } - -// const arrProto = Array.prototype; - -// arrProto.where = function (predicate: (item: T) => boolean): IEnumerable { -// return from(this as unknown as T[]).where(predicate); -// }; - -//arrProto.slice; - -console.log( - [1, 2, 3] - .pipe(x => console.log(x)) - .where(e => e % 2 === 1) - .take(1) - .toArray() -); - -console.log( - new Map([ - [1, 'a'], - [2, 'b'] - ]) - .where(([k, v]) => k === 2) - .select(([_, v]) => v) - .toArray() -); -// const args = process.argv.slice(2); - -// if (args.length === 0) { -// throw new Error('Benchmark name must be passed.'); -// } - -// const benchmark = args[0]; - -// switch (benchmark.toLowerCase()) { -// case 'any': -// anyBenchmark(); -// break; -// case 'all': -// allBenchmark(); -// break; -// case 'where': -// whereBenchmark(); -// break; -// case 'complex': -// complexBenchmark(); -// break; -// case 'count': -// countBenchmark(); -// break; -// case 'select': -// selectBenchmark(); -// break; -// case 'sum': -// sumBenchmark(); -// break; -// case 'list': -// listBenchmark(); -// break; -// case 'queue': -// queueBenchmark(); -// break; -// case 'xor': -// xorBenchmark(); -// break; -// default: -// throw new Error(`${benchmark} is not a valid benchmark name.`); -// } +const benchmark = args[0]; + +switch (benchmark.toLowerCase()) { + case 'any': + anyBenchmark(); + break; + case 'all': + allBenchmark(); + break; + case 'where': + whereBenchmark(); + break; + case 'complex': + complexBenchmark(); + break; + case 'count': + countBenchmark(); + break; + case 'select': + selectBenchmark(); + break; + case 'sum': + sumBenchmark(); + break; + case 'list': + listBenchmark(); + break; + case 'queue': + queueBenchmark(); + break; + case 'xor': + xorBenchmark(); + break; + default: + throw new Error(`${benchmark} is not a valid benchmark name.`); +} diff --git a/src/__tests__/concat.ts b/src/__tests__/concatenate.ts similarity index 76% rename from src/__tests__/concat.ts rename to src/__tests__/concatenate.ts index 4de283f..20d81ca 100644 --- a/src/__tests__/concat.ts +++ b/src/__tests__/concatenate.ts @@ -3,7 +3,7 @@ import { getEnumerables } from '../__test-utilities__/utilities'; describe.each([...getEnumerables()])('concat', (src, enumerable) => { it('should return an Enumerable', () => { - const result = enumerable(src([1, 2, 3])).concat([4, 5, 6]); + const result = enumerable(src([1, 2, 3])).concatenate([4, 5, 6]); expect(result).toBeInstanceOf(BasicEnumerable); }); @@ -20,7 +20,7 @@ describe.each([...getEnumerables()])('concat', (src, enumerable) => { [[], [1, 1], [1, 1]], [[1, 1], [], [1, 1]] ])('should add elements to end of sequence', (first, second, expected) => { - const result = enumerable(src(first)).concat(src(second)).toArray(); + const result = enumerable(src(first)).concatenate(src(second)).toArray(); expect(result).toEqual(expected); }); @@ -28,7 +28,7 @@ describe.each([...getEnumerables()])('concat', (src, enumerable) => { it('should concat several collections', () => { const items = [1, 2, 3]; - const result = from(items).concat([4, 5], [], [6], [7, 8, 9]).toArray(); + const result = from(items).concatenate([4, 5], [], [6], [7, 8, 9]).toArray(); expect(result).toEqual([1, 2, 3, 4, 5, 6, 7, 8, 9]); }); diff --git a/src/__tests__/join.ts b/src/__tests__/innerJoin.ts similarity index 94% rename from src/__tests__/join.ts rename to src/__tests__/innerJoin.ts index 255b166..386f30e 100644 --- a/src/__tests__/join.ts +++ b/src/__tests__/innerJoin.ts @@ -1,10 +1,10 @@ -import { join } from '../functions/join'; +import { innerJoin } from '../functions/innerJoin'; import { BasicEnumerable } from '../enumerables/BasicEnumerable'; import { getEnumerables } from '../__test-utilities__/utilities'; describe.each([...getEnumerables()])('join', (src, enumerable) => { it.each([[1, 2, 3], new Set([1, 2, 3]), '123', new Map()])('should return an Enumerable', collection => { - const result = join( + const result = innerJoin( collection, [], x => x, @@ -34,7 +34,7 @@ describe.each([...getEnumerables()])('join', (src, enumerable) => { const pets = enumerable(src([barley, boots, whiskers, daisy, scratchy])); const result = people - .join( + .innerJoin( pets, person => person, pet => pet.owner, @@ -69,7 +69,7 @@ describe.each([...getEnumerables()])('join', (src, enumerable) => { const pets = enumerable(src([barley, boots, whiskers, daisy, scratchy])); const result = people - .join( + .innerJoin( pets, person => person, pet => pet.owner, @@ -86,3 +86,5 @@ describe.each([...getEnumerables()])('join', (src, enumerable) => { ]); }); }); + +new Map().forEach; diff --git a/src/__tests__/reverse.ts b/src/__tests__/reverseImmutable.ts similarity index 73% rename from src/__tests__/reverse.ts rename to src/__tests__/reverseImmutable.ts index 23e61ac..891b598 100644 --- a/src/__tests__/reverse.ts +++ b/src/__tests__/reverseImmutable.ts @@ -3,7 +3,7 @@ import { getEnumerables } from '../__test-utilities__/utilities'; describe.each([...getEnumerables()])('reverse', (src, enumerable, addSrc) => { it('should return an Enumberable', () => { - const result = enumerable(src([1, 2, 3])).reverse(); + const result = enumerable(src([1, 2, 3])).reverseImmutable(); expect(result).toBeInstanceOf(BasicEnumerable); }); @@ -11,7 +11,7 @@ describe.each([...getEnumerables()])('reverse', (src, enumerable, addSrc) => { it('should reverse the elements', () => { const items = src([1, 2, 3]); - const result = enumerable(items).reverse().toArray(); + const result = enumerable(items).reverseImmutable().toArray(); expect(result).toEqual([3, 2, 1]); }); @@ -19,7 +19,7 @@ describe.each([...getEnumerables()])('reverse', (src, enumerable, addSrc) => { it('should not mutate src', () => { const items = src([1, 2, 3]); - const _ = enumerable(items).reverse().toArray(); + const _ = enumerable(items).reverseImmutable().toArray(); expect([...items]).toEqual([1, 2, 3]); }); @@ -27,7 +27,7 @@ describe.each([...getEnumerables()])('reverse', (src, enumerable, addSrc) => { it('should have deferred execution', () => { const items = src([1, 2, 3]); - const result = enumerable(items).reverse(); + const result = enumerable(items).reverseImmutable(); addSrc(items, 4, 5); diff --git a/src/enumerables/BasicEnumerable.ts b/src/enumerables/BasicEnumerable.ts index 6fdf9cb..110ed60 100644 --- a/src/enumerables/BasicEnumerable.ts +++ b/src/enumerables/BasicEnumerable.ts @@ -4,7 +4,7 @@ import { any } from '../functions/any'; import { applyAppend } from '../functions/applicators/applyAppend'; import { applyAsEnumerable } from '../functions/applicators/applyAsEnumerable'; import { applyChunk } from '../functions/applicators/applyChunk'; -import { applyConcat } from '../functions/applicators/applyConcat'; +import { applyConcatenate } from '../functions/applicators/applyConcatenate'; import { applyDefaultIfEmpty } from '../functions/applicators/applyDefaultIfEmpty'; import { applyDistinct } from '../functions/applicators/applyDistinct'; import { applyExcept } from '../functions/applicators/applyExcept'; @@ -13,7 +13,7 @@ import { applyFullJoinHeterogeneous, applyFullJoinHomogeneous } from '../functio import { applyGroupBy } from '../functions/applicators/applyGroupBy'; import { applyGroupJoin } from '../functions/applicators/applyGroupJoin'; import { applyIntersect } from '../functions/applicators/applyIntersect'; -import { applyJoin } from '../functions/applicators/applyJoin'; +import { applyInnerJoin } from '../functions/applicators/applyInnerJoin'; import { applyLeftJoinHeterogeneous, applyLeftJoinHomogeneous } from '../functions/applicators/applyLeftJoin'; import { applyMax } from '../functions/applicators/applyMax'; import { applyMin } from '../functions/applicators/applyMin'; @@ -22,7 +22,7 @@ import { applyOrderBy } from '../functions/applicators/applyOrderBy'; import { applyPipe } from '../functions/applicators/applyPipe'; import { applyPrepend } from '../functions/applicators/applyPrepend'; import { applyQuantile } from '../functions/applicators/applyQuantile'; -import { applyReverse } from '../functions/applicators/applyReverse'; +import { applyReverseImmutable } from '../functions/applicators/applyReverseImmutable'; import { applyRightJoinHeterogeneous, applyRightJoinHomogeneous } from '../functions/applicators/applyRightJoin'; import { applySelect, applySelectMany } from '../functions/applicators/applySelect'; import { applyShuffle } from '../functions/applicators/applyShuffle'; @@ -332,27 +332,27 @@ export class BasicEnumerable implements IEnumerable { * @example * ```typescript * const numbers = [1, 2]; - * const moreNumbers = from(numbers).concat([3, 4, 5]); // [1, 2, 3, 4, 5] + * const moreNumbers = from(numbers).concatenate([3, 4, 5]); // [1, 2, 3, 4, 5] * ``` * @param collection The sequence to concatenate to the first sequence. * @returns An IEnumerable that contains the concatenated elements of the two input sequences. */ - public concat(collection: Iterable): IEnumerable; + public concatenate(collection: Iterable): IEnumerable; /** * Concatenates two or more sequences. * @example * ```typescript * const numbers = [1, 2]; - * const evenMoreNumbers = from(numbers).concat([3, 4], [5, 6]); // [1, 2, 3, 4, 5, 6] + * const evenMoreNumbers = from(numbers).concatenate([3, 4], [5, 6]); // [1, 2, 3, 4, 5, 6] * ``` * @param collections The sequences to concatenate to the first sequence. * @returns An IEnumerable that contains the concatenated elements of the two or more input sequences. */ - public concat(...collections: Iterable[]): IEnumerable; + public concatenate(...collections: Iterable[]): IEnumerable; - public concat(...collections: Iterable[]): IEnumerable { - return applyConcat(this.factory, this, collections); + public concatenate(...collections: Iterable[]): IEnumerable { + return applyConcatenate(this.factory, this, collections); } /** @@ -1239,7 +1239,7 @@ export class BasicEnumerable implements IEnumerable { * const people = from([magnus, terry, adam, john]); * const pets = from([barley, boots, whiskers, daisy, scratchy]); * - * const result = people.join( + * const result = people.innerJoin( * pets, * person => person, * pet => pet.owner, @@ -1263,7 +1263,7 @@ export class BasicEnumerable implements IEnumerable { * @param resultSelector A function to create a result element from two matching elements. * @returns An IEnumerable that has elements of type TResult that are obtained by performing an inner join on two sequences. */ - public join( + public innerJoin( inner: Iterable, outerKeySelector: (item: TSource) => TKey, innerKeySelector: (item: TInner) => TKey, @@ -1288,7 +1288,7 @@ export class BasicEnumerable implements IEnumerable { * const people = from([magnus, terry, adam, john]); * const pets = from([barley, boots, whiskers, daisy, scratchy]); * - * const result = people.join( + * const result = people.innerJoin( * pets, * person => person, * pet => pet.owner, @@ -1314,7 +1314,7 @@ export class BasicEnumerable implements IEnumerable { * @param equalityComparer A function to compare keys. * @returns An IEnumerable that has elements of type TResult that are obtained by performing an inner join on two sequences. */ - public join( + public innerJoin( inner: Iterable, outerKeySelector: (item: TSource) => TKey, innerKeySelector: (item: TInner) => TKey, @@ -1322,14 +1322,22 @@ export class BasicEnumerable implements IEnumerable { equalityComparer: EqualityComparer ): IEnumerable; - public join( + public innerJoin( inner: Iterable, outerKeySelector: (item: TSource) => TKey, innerKeySelector: (item: TInner) => TKey, resultSelector: (item: TSource, inner: TInner) => TResult, equalityComparer?: EqualityComparer ): IEnumerable { - return applyJoin(this.factory, this, inner, outerKeySelector, innerKeySelector, resultSelector, equalityComparer); + return applyInnerJoin( + this.factory, + this, + inner, + outerKeySelector, + innerKeySelector, + resultSelector, + equalityComparer + ); } /** @@ -1618,8 +1626,8 @@ export class BasicEnumerable implements IEnumerable { * Inverts the order of the elements in a sequence. * @returns A sequence whose elements correspond to those of the input sequence in reverse order. */ - public reverse(): IEnumerable { - return applyReverse(this.factory, this); + public reverseImmutable(): IEnumerable { + return applyReverseImmutable(this.factory, this); } /** diff --git a/src/functions/applicators/applyConcat.ts b/src/functions/applicators/applyConcatenate.ts similarity index 94% rename from src/functions/applicators/applyConcat.ts rename to src/functions/applicators/applyConcatenate.ts index 137d5a1..ebd2f9a 100644 --- a/src/functions/applicators/applyConcat.ts +++ b/src/functions/applicators/applyConcatenate.ts @@ -1,6 +1,6 @@ import { IEnumerable, IEnumerableFactory } from '../../types'; -export function applyConcat( +export function applyConcatenate( factory: IEnumerableFactory, src: Iterable, collections: Iterable[] diff --git a/src/functions/applicators/applyJoin.ts b/src/functions/applicators/applyInnerJoin.ts similarity index 95% rename from src/functions/applicators/applyJoin.ts rename to src/functions/applicators/applyInnerJoin.ts index 7dc914d..639d43b 100644 --- a/src/functions/applicators/applyJoin.ts +++ b/src/functions/applicators/applyInnerJoin.ts @@ -1,6 +1,6 @@ import { EqualityComparer, IEnumerable, IEnumerableFactory } from '../../types'; -export function applyJoin( +export function applyInnerJoin( factory: IEnumerableFactory, outer: Iterable, inner: Iterable, diff --git a/src/functions/applicators/applyReverse.ts b/src/functions/applicators/applyReverseImmutable.ts similarity index 67% rename from src/functions/applicators/applyReverse.ts rename to src/functions/applicators/applyReverseImmutable.ts index 2c5820f..ebdc4ba 100644 --- a/src/functions/applicators/applyReverse.ts +++ b/src/functions/applicators/applyReverseImmutable.ts @@ -1,6 +1,9 @@ import { IEnumerable, IEnumerableFactory } from '../../types'; -export function applyReverse(factory: IEnumerableFactory, src: Iterable): IEnumerable { +export function applyReverseImmutable( + factory: IEnumerableFactory, + src: Iterable +): IEnumerable { function* generator(): Generator { const items = [...src]; diff --git a/src/functions/bindLinqToNativeType.ts b/src/functions/bindLinqToNativeType.ts new file mode 100644 index 0000000..1a961da --- /dev/null +++ b/src/functions/bindLinqToNativeType.ts @@ -0,0 +1,19 @@ +import { BasicEnumerable } from '../enumerables/BasicEnumerable'; +import { from } from './from'; + +export function bindLinqToNativeTypes(): void { + const enumProps = BasicEnumerable.prototype; + const protos = [Array.prototype, Set.prototype, Map.prototype, String.prototype]; + + const enumPropNames = Object.getOwnPropertyNames(enumProps); + + for (const proto of protos) { + for (const prop of enumPropNames) { + if ((proto as any)[prop] === undefined) { + (proto as any)[prop as any] = function (...params: any[]) { + return (from(this) as any)[prop as any](...params); + }; + } + } + } +} diff --git a/src/functions/concat.ts b/src/functions/concatenate.ts similarity index 56% rename from src/functions/concat.ts rename to src/functions/concatenate.ts index 6cb284b..4ea0b4e 100644 --- a/src/functions/concat.ts +++ b/src/functions/concatenate.ts @@ -1,35 +1,38 @@ import { EnumerableFactory } from '../utilities/EnumerableFactory'; import { IEnumerable } from '../types'; -import { applyConcat } from './applicators/applyConcat'; +import { applyConcatenate } from './applicators/applyConcatenate'; /** * Concatenates two sequences. * @example * ```typescript * const numbers = [1, 2]; - * const moreNumbers = from(numbers).concat([3, 4, 5]); // [1, 2, 3, 4, 5] + * const moreNumbers = from(numbers).concatenate([3, 4, 5]); // [1, 2, 3, 4, 5] * ``` * @typeparam TSource The type of the source iterable. * @param src The source iterable. * @param collection The sequence to concatenate to the first sequence. * @returns An IEnumerable that contains the concatenated elements of the two input sequences. */ -export function concat(src: Iterable, collection: Iterable): IEnumerable; +export function concatenate(src: Iterable, collection: Iterable): IEnumerable; /** * Concatenates two sequences. * @example * ```typescript * const numbers = [1, 2]; - * const evenMoreNumbers = from(numbers).concat([3, 4], [5, 6]); // [1, 2, 3, 4, 5, 6] + * const evenMoreNumbers = from(numbers).concatenate([3, 4], [5, 6]); // [1, 2, 3, 4, 5, 6] * ``` * @typeparam TSource The type of the source iterable. * @param src The source iterable. * @param collections The sequences to concatenate to the first sequence. * @returns An IEnumerable that contains the concatenated elements of the two or more input sequences. */ -export function concat(src: Iterable, ...collections: Iterable[]): IEnumerable; +export function concatenate(src: Iterable, ...collections: Iterable[]): IEnumerable; -export function concat(src: Iterable, ...collections: Iterable[]): IEnumerable { - return applyConcat(new EnumerableFactory(), src, collections); +export function concatenate( + src: Iterable, + ...collections: Iterable[] +): IEnumerable { + return applyConcatenate(new EnumerableFactory(), src, collections); } diff --git a/src/functions/join.ts b/src/functions/innerJoin.ts similarity index 94% rename from src/functions/join.ts rename to src/functions/innerJoin.ts index 88eec8b..71fd148 100644 --- a/src/functions/join.ts +++ b/src/functions/innerJoin.ts @@ -1,7 +1,7 @@ import { EnumerableFactory } from '../utilities/EnumerableFactory'; import { IEnumerable } from '../types'; import { EqualityComparer } from '../types'; -import { applyJoin } from './applicators/applyJoin'; +import { applyInnerJoin } from './applicators/applyInnerJoin'; /** * Performs an inner join by correlating the elements of two sequences based on matching keys. @@ -49,7 +49,7 @@ import { applyJoin } from './applicators/applyJoin'; * @param equalityComparer A function to compare keys. * @returns An Enumerable that has elements of type TResult that are obtained by performing an inner join on two sequences. */ -export function join( +export function innerJoin( outer: Iterable, inner: Iterable, outerKeySelector: (item: TOuter) => TKey, @@ -57,7 +57,7 @@ export function join( resultSelector: (item: TOuter, inner: TInner) => TResult, equalityComparer?: EqualityComparer ): IEnumerable { - return applyJoin( + return applyInnerJoin( new EnumerableFactory(), outer, inner, diff --git a/src/functions/reverse.ts b/src/functions/reverse.ts deleted file mode 100644 index 1c49bcd..0000000 --- a/src/functions/reverse.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { EnumerableFactory } from '../utilities/EnumerableFactory'; -import { IEnumerable } from '../types'; -import { applyReverse } from './applicators/applyReverse'; - -export function reverse(src: Iterable): IEnumerable { - return applyReverse(new EnumerableFactory(), src); -} diff --git a/src/functions/reverseImmutable.ts b/src/functions/reverseImmutable.ts new file mode 100644 index 0000000..51deba2 --- /dev/null +++ b/src/functions/reverseImmutable.ts @@ -0,0 +1,7 @@ +import { EnumerableFactory } from '../utilities/EnumerableFactory'; +import { IEnumerable } from '../types'; +import { applyReverseImmutable } from './applicators/applyReverseImmutable'; + +export function reverseImmutable(src: Iterable): IEnumerable { + return applyReverseImmutable(new EnumerableFactory(), src); +} diff --git a/src/global.d.ts b/src/global.d.ts new file mode 100644 index 0000000..021ed70 --- /dev/null +++ b/src/global.d.ts @@ -0,0 +1,12 @@ +/* eslint-disable */ +//@ts-nocheck +import { IEnumerable } from './types'; + +const iterator = Symbol(Symbol.iterator); + +declare global { + interface Array extends Omit, 'forEach' | 'toString' | iterator> {} + interface Map extends Omit, 'forEach' | iterator> {} + interface Set extends Omit, 'forEach' | iterator> {} + interface String extends Omit, 'endsWith' | 'startsWith' | 'split' | 'toString' | iterator> {} +} diff --git a/src/index.ts b/src/index.ts index e31a303..62abf21 100644 --- a/src/index.ts +++ b/src/index.ts @@ -22,7 +22,7 @@ export * from './functions/atLeast'; export * from './functions/atMost'; export * from './functions/average'; export * from './functions/chunk'; -export * from './functions/concat'; +export * from './functions/concatenate'; export * from './functions/contains'; export * from './functions/count'; export * from './functions/defaultIfEmpty'; @@ -40,7 +40,7 @@ export * from './functions/groupBy'; export * from './functions/groupJoin'; export * from './functions/intersect'; export * from './functions/isEnumerable'; -export * from './functions/join'; +export * from './functions/innerJoin'; export * from './functions/last'; export * from './functions/leftJoin'; export * from './functions/max'; @@ -52,7 +52,7 @@ export * from './functions/prepend'; export * from './functions/quantile'; export * from './functions/range'; export * from './functions/repeat'; -export * from './functions/reverse'; +export * from './functions/reverseImmutable'; export * from './functions/rightJoin'; export * from './functions/select'; export * from './functions/sequenceEqual'; diff --git a/src/types.ts b/src/types.ts index 7de5057..aaa2c6e 100644 --- a/src/types.ts +++ b/src/types.ts @@ -246,24 +246,24 @@ export interface IEnumerable extends Iterable { * @example * ```typescript * const numbers = [1, 2]; - * const moreNumbers = from(numbers).concat([3, 4, 5]); // [1, 2, 3, 4, 5] + * const moreNumbers = from(numbers).concatenate([3, 4, 5]); // [1, 2, 3, 4, 5] * ``` * @param collection The sequence to concatenate to the first sequence. * @returns An IEnumerable that contains the concatenated elements of the two input sequences. */ - concat(collection: Iterable): IEnumerable; + concatenate(collection: Iterable): IEnumerable; /** * Concatenates two sequences. * @example * ```typescript * const numbers = [1, 2]; - * const evenMoreNumbers = from(numbers).concat([3, 4], [5, 6]); // [1, 2, 3, 4, 5, 6] + * const evenMoreNumbers = from(numbers).concatenate([3, 4], [5, 6]); // [1, 2, 3, 4, 5, 6] * ``` * @param collections The sequences to concatenate to the first sequence. * @returns An IEnumerable that contains the concatenated elements of the two or more input sequences. */ - concat(...collections: Iterable[]): IEnumerable; + concatenate(...collections: Iterable[]): IEnumerable; /** * Determines whether a sequence contains a specified element. @@ -1020,7 +1020,7 @@ export interface IEnumerable extends Iterable { * const people = from([magnus, terry, adam, john]); * const pets = from([barley, boots, whiskers, daisy, scratchy]); * - * const result = people.join( + * const result = people.innerJoin( * pets, * person => person, * pet => pet.owner, @@ -1044,7 +1044,7 @@ export interface IEnumerable extends Iterable { * @param resultSelector A function to create a result element from two matching elements. * @returns An IEnumerable that has elements of type TResult that are obtained by performing an inner join on two sequences. */ - join( + innerJoin( inner: Iterable, outerKeySelector: (item: TSource) => TKey, innerKeySelector: (item: TInner) => TKey, @@ -1069,7 +1069,7 @@ export interface IEnumerable extends Iterable { * const people = from([magnus, terry, adam, john]); * const pets = from([barley, boots, whiskers, daisy, scratchy]); * - * const result = people.join( + * const result = people.innerJoin( * pets, * person => person, * pet => pet.owner, @@ -1095,7 +1095,7 @@ export interface IEnumerable extends Iterable { * @param equalityComparer A function to compare keys. * @returns An IEnumerable that has elements of type TResult that are obtained by performing an inner join on two sequences. */ - join( + innerJoin( inner: Iterable, outerKeySelector: (item: TSource) => TKey, innerKeySelector: (item: TInner) => TKey, @@ -1309,7 +1309,7 @@ export interface IEnumerable extends Iterable { * Inverts the order of the elements in a sequence. * @returns A sequence whose elements correspond to those of the input sequence in reverse order. */ - reverse(): IEnumerable; + reverseImmutable(): IEnumerable; /** * Performs a right outer join on two heterogeneous sequences.