Skip to content

Commit

Permalink
Remove Enumerable.prototype.lift
Browse files Browse the repository at this point in the history
  • Loading branch information
emonkak committed Aug 21, 2019
1 parent 43dae25 commit 9346d80
Show file tree
Hide file tree
Showing 37 changed files with 37 additions and 41 deletions.
2 changes: 1 addition & 1 deletion src/extensions/buffer.ts
Expand Up @@ -2,7 +2,7 @@ import bufferFn from '../buffer';
import { Enumerable } from '../internal/Enumerable';

function buffer<TSource>(this: Enumerable<TSource>, count: number, skip?: number): Enumerable<TSource[]> {
return this.lift<TSource[]>(bufferFn.call(this.source, count, skip));
return new Enumerable<TSource[]>(bufferFn.call(this.source, count, skip));
}

Enumerable.prototype.buffer = buffer;
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/catch.ts
Expand Up @@ -2,7 +2,7 @@ import catchFn from '../catch';
import { Enumerable } from '../internal/Enumerable';

function _catch<TSource, TException>(this: Enumerable<TSource>, handler: (exception: TException) => Iterable<TSource>): Enumerable<TSource> {
return this.lift<TSource>(catchFn.call(this.source, handler));
return new Enumerable<TSource>(catchFn.call(this.source, handler));
}

Enumerable.prototype.catch = _catch;
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/concat.ts
Expand Up @@ -2,7 +2,7 @@ import concatFn from '../concat';
import { Enumerable } from '../internal/Enumerable';

function concat<TSource>(this: Enumerable<TSource>, second: Iterable<TSource>): Enumerable<TSource> {
return this.lift<TSource>(concatFn.call(this.source, second));
return new Enumerable<TSource>(concatFn.call(this.source, second));
}

Enumerable.prototype.concat = concat;
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/defaultIfEmpty.ts
Expand Up @@ -2,7 +2,7 @@ import defaultIfEmptyFn from '../defaultIfEmpty';
import { Enumerable } from '../internal/Enumerable';

function defaultIfEmpty<TSource>(this: Enumerable<TSource>, defaultValue: TSource): Enumerable<TSource> {
return this.lift<TSource>(defaultIfEmptyFn.call(this.source, defaultValue));
return new Enumerable<TSource>(defaultIfEmptyFn.call(this.source, defaultValue));
}

Enumerable.prototype.defaultIfEmpty = defaultIfEmpty;
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/distinct.ts
Expand Up @@ -4,7 +4,7 @@ import { Enumerable } from '../internal/Enumerable';
function distinct<TSource>(this: Enumerable<TSource>): Enumerable<TSource>;
function distinct<TSource, TKey>(this: Enumerable<TSource>, keySelector: (element: TSource) => TKey): Enumerable<TSource>;
function distinct<TSource, TKey>(this: Enumerable<TSource>, keySelector?: (element: TSource) => TKey): Enumerable<TSource> {
return this.lift<TSource>(distinctFn.call(this.source, keySelector));
return new Enumerable<TSource>(distinctFn.call(this.source, keySelector));
}

Enumerable.prototype.distinct = distinct;
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/distinctUntilChanged.ts
Expand Up @@ -4,7 +4,7 @@ import { Enumerable } from '../internal/Enumerable';
function distinctUntilChanged<TSource>(this: Enumerable<TSource>): Enumerable<TSource>;
function distinctUntilChanged<TSource, TKey>(this: Enumerable<TSource>, keySelector: (element: TSource) => TKey): Enumerable<TSource>;
function distinctUntilChanged<TSource, TKey>(this: Enumerable<TSource>, keySelector?: (element: TSource) => TKey): Enumerable<TSource> {
return this.lift<TSource>(distinctUntilChangedFn.call(this.source, keySelector));
return new Enumerable<TSource>(distinctUntilChangedFn.call(this.source, keySelector));
}

Enumerable.prototype.distinctUntilChanged = distinctUntilChanged;
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/do.ts
Expand Up @@ -2,7 +2,7 @@ import doFn from '../do';
import { Enumerable } from '../internal/Enumerable';

function _do<TSource>(this: Enumerable<TSource>, action: (element: TSource) => void): Enumerable<TSource> {
return this.lift<TSource>(doFn.call(this.source, action));
return new Enumerable<TSource>(doFn.call(this.source, action));
}

Enumerable.prototype.do = _do;
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/doWhile.ts
Expand Up @@ -2,7 +2,7 @@ import doWhileFn from '../doWhile';
import { Enumerable } from '../internal/Enumerable';

function doWhile<TSource>(this: Enumerable<TSource>, condition: () => boolean): Enumerable<TSource> {
return this.lift<TSource>(doWhileFn.call(this.source, condition));
return new Enumerable<TSource>(doWhileFn.call(this.source, condition));
}

Enumerable.prototype.doWhile = doWhile;
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/except.ts
Expand Up @@ -2,7 +2,7 @@ import exceptFn from '../except';
import { Enumerable } from '../internal/Enumerable';

function except<TSource>(this: Enumerable<TSource>, second: Iterable<TSource>): Enumerable<TSource> {
return this.lift<TSource>(exceptFn.call(this.source, second));
return new Enumerable<TSource>(exceptFn.call(this.source, second));
}

Enumerable.prototype.except = except;
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/finally.ts
Expand Up @@ -2,7 +2,7 @@ import finallyFn from '../finally';
import { Enumerable } from '../internal/Enumerable';

function _finally<TSource>(this: Enumerable<TSource>, finallyAction: () => void): Enumerable<TSource> {
return this.lift<TSource>(finallyFn.call(this.source, finallyAction));
return new Enumerable<TSource>(finallyFn.call(this.source, finallyAction));
}

Enumerable.prototype.finally = _finally;
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/groupBy.ts
Expand Up @@ -4,7 +4,7 @@ import { Enumerable } from '../internal/Enumerable';
function groupBy<TSource, TKey>(this: Enumerable<TSource>, keySelector: (element: TSource) => TKey): Enumerable<[TKey, TSource]>;
function groupBy<TSource, TKey, TElement>(this: Enumerable<TSource>, keySelector: (element: TSource) => TKey, elementSelector: (element: TSource) => TElement): Enumerable<[TKey, TElement]>;
function groupBy<TSource, TKey, TElement, TResult>(this: Enumerable<TSource>, keySelector: (element: TSource) => TKey, elementSelector?: (element: TSource) => TElement, resultSelector?: (key: TKey, elements: TElement[]) => TResult): Enumerable<TResult> {
return this.lift<TResult>(groupByFn.call(this.source, keySelector, elementSelector, resultSelector));
return new Enumerable<TResult>(groupByFn.call(this.source, keySelector, elementSelector, resultSelector));
}

Enumerable.prototype.groupBy = groupBy;
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/groupJoin.ts
Expand Up @@ -2,7 +2,7 @@ import groupJoinFn from '../groupJoin';
import { Enumerable } from '../internal/Enumerable';

function groupJoin<TOuter, TInner, TKey, TResult>(this: Enumerable<TOuter>, inner: Iterable<TInner>, outerKeySelector: (element: TOuter) => TKey, innerKeySelector: (element: TInner) => TKey, resultSelector: (outer: TOuter, inner: TInner[]) => TResult): Enumerable<TResult> {
return this.lift<TResult>(groupJoinFn.call(this.source, inner, outerKeySelector, innerKeySelector, resultSelector));
return new Enumerable<TResult>(groupJoinFn.call(this.source, inner, outerKeySelector, innerKeySelector, resultSelector));
}

Enumerable.prototype.groupJoin = groupJoin;
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/ignoreElements.ts
Expand Up @@ -2,7 +2,7 @@ import ignoreElementsFn from '../ignoreElements';
import { Enumerable } from '../internal/Enumerable';

function ignoreElements<TSource>(this: Enumerable<TSource>): Enumerable<TSource> {
return this.lift<TSource>(ignoreElementsFn.call(this.source));
return new Enumerable<TSource>(ignoreElementsFn.call(this.source));
}

Enumerable.prototype.ignoreElements = ignoreElements;
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/intersect.ts
Expand Up @@ -2,7 +2,7 @@ import intersectFn from '../intersect';
import { Enumerable } from '../internal/Enumerable';

function intersect<TSource>(this: Enumerable<TSource>, second: Iterable<TSource>): Enumerable<TSource> {
return this.lift<TSource>(intersectFn.call(this.source, second));
return new Enumerable<TSource>(intersectFn.call(this.source, second));
}

Enumerable.prototype.intersect = intersect;
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/join.ts
Expand Up @@ -2,7 +2,7 @@ import joinFn from '../join';
import { Enumerable } from '../internal/Enumerable';

function join<TOuter, TInner, TKey, TResult>(this: Enumerable<TOuter>, inner: Iterable<TInner>, outerKeySelector: (element: TOuter) => TKey, innerKeySelector: (element: TInner) => TKey, resultSelector: (outer: TOuter, inner: TInner) => TResult): Enumerable<TResult> {
return this.lift<TResult>(joinFn.call(this.source, inner, outerKeySelector, innerKeySelector, resultSelector));
return new Enumerable<TResult>(joinFn.call(this.source, inner, outerKeySelector, innerKeySelector, resultSelector));
}

Enumerable.prototype.join = join;
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/maxBy.ts
Expand Up @@ -2,7 +2,7 @@ import maxByFn from '../maxBy';
import { Enumerable } from '../internal/Enumerable';

function maxBy<TSource, TKey>(this: Enumerable<TSource>, keySelector: (element: TSource) => TKey): Enumerable<TSource> {
return this.lift<TSource>(maxByFn.call(this.source, keySelector));
return new Enumerable<TSource>(maxByFn.call(this.source, keySelector));
}

Enumerable.prototype.maxBy = maxBy;
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/memoize.ts
Expand Up @@ -2,7 +2,7 @@ import memoizeFn from '../memoize';
import { Enumerable } from '../internal/Enumerable';

function memoize<TSource>(this: Enumerable<TSource>): Enumerable<TSource> {
return this.lift<TSource>(memoizeFn.call(this.source));
return new Enumerable<TSource>(memoizeFn.call(this.source));
}

Enumerable.prototype.memoize = memoize;
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/minBy.ts
Expand Up @@ -2,7 +2,7 @@ import minByFn from '../minBy';
import { Enumerable } from '../internal/Enumerable';

function minBy<TSource, TKey>(this: Enumerable<TSource>, keySelector: (element: TSource) => TKey): Enumerable<TSource> {
return this.lift<TSource>(minByFn.call(this.source, keySelector));
return new Enumerable<TSource>(minByFn.call(this.source, keySelector));
}

Enumerable.prototype.minBy = minBy;
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/onErrorResumeNext.ts
Expand Up @@ -2,7 +2,7 @@ import onErrorResumeNextFn from '../onErrorResumeNext';
import { Enumerable } from '../internal/Enumerable';

function onErrorResumeNext<TSource>(this: Enumerable<TSource>, second: Iterable<TSource>[]): Enumerable<TSource> {
return this.lift<TSource>(onErrorResumeNextFn.call(this.source, second));
return new Enumerable<TSource>(onErrorResumeNextFn.call(this.source, second));
}

Enumerable.prototype.onErrorResumeNext = onErrorResumeNext;
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/repeat.ts
Expand Up @@ -2,7 +2,7 @@ import repeatFn from '../repeat';
import { Enumerable } from '../internal/Enumerable';

function repeat<TSource>(this: Enumerable<TSource>, count?: number): Enumerable<TSource> {
return this.lift<TSource>(repeatFn.call(this.source, count));
return new Enumerable<TSource>(repeatFn.call(this.source, count));
}

Enumerable.prototype.repeat = repeat;
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/retry.ts
Expand Up @@ -2,7 +2,7 @@ import retryFn from '../retry';
import { Enumerable } from '../internal/Enumerable';

function retry<TSource>(this: Enumerable<TSource>, retryCount?: number): Enumerable<TSource> {
return this.lift<TSource>(retryFn.call(this.source, retryCount));
return new Enumerable<TSource>(retryFn.call(this.source, retryCount));
}

Enumerable.prototype.retry = retry;
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/reverse.ts
Expand Up @@ -2,7 +2,7 @@ import reverseFn from '../reverse';
import { Enumerable } from '../internal/Enumerable';

function reverse<TSource>(this: Enumerable<TSource>): Enumerable<TSource> {
return this.lift<TSource>(reverseFn.call(this.source));
return new Enumerable<TSource>(reverseFn.call(this.source));
}

Enumerable.prototype.reverse = reverse;
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/scan.ts
Expand Up @@ -2,7 +2,7 @@ import scanFn from '../scan';
import { Enumerable } from '../internal/Enumerable';

function scan<TSource, TAccumulate>(this: Enumerable<TSource>, seed: TAccumulate, func: (result: TAccumulate, element: TSource) => TAccumulate): Enumerable<TAccumulate> {
return this.lift<TAccumulate>(scanFn.call(this.source, seed, func));
return new Enumerable<TAccumulate>(scanFn.call(this.source, seed, func));
}

Enumerable.prototype.scan = scan;
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/select.ts
Expand Up @@ -2,7 +2,7 @@ import selectFn from '../select';
import { Enumerable } from '../internal/Enumerable';

function select<TSource, TResult>(this: Enumerable<TSource>, selector: (element: TSource) => TResult): Enumerable<TResult> {
return this.lift<TResult>(selectFn.call(this.source, selector));
return new Enumerable<TResult>(selectFn.call(this.source, selector));
}

Enumerable.prototype.select = select;
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/selectMany.ts
Expand Up @@ -2,7 +2,7 @@ import selectManyFn from '../selectMany';
import { Enumerable } from '../internal/Enumerable';

function selectMany<TSource, TResult>(this: Enumerable<TSource>, collectionSelector: (element: TSource) => Iterable<TResult>): Enumerable<TResult> {
return this.lift<TResult>(selectManyFn.call(this.source, collectionSelector));
return new Enumerable<TResult>(selectManyFn.call(this.source, collectionSelector));
}

Enumerable.prototype.selectMany = selectMany;
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/skip.ts
Expand Up @@ -2,7 +2,7 @@ import skipFn from '../skip';
import { Enumerable } from '../internal/Enumerable';

function skip<TSource>(this: Enumerable<TSource>, count: number): Enumerable<TSource> {
return this.lift<TSource>(skipFn.call(this.source, count));
return new Enumerable<TSource>(skipFn.call(this.source, count));
}

Enumerable.prototype.skip = skip;
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/skipLast.ts
Expand Up @@ -2,7 +2,7 @@ import skipLastFn from '../skipLast';
import { Enumerable } from '../internal/Enumerable';

function skipLast<TSource>(this: Enumerable<TSource>, count: number): Enumerable<TSource> {
return this.lift<TSource>(skipLastFn.call(this.source, count));
return new Enumerable<TSource>(skipLastFn.call(this.source, count));
}

Enumerable.prototype.skipLast = skipLast;
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/skipWhile.ts
Expand Up @@ -2,7 +2,7 @@ import skipWhileFn from '../skipWhile';
import { Enumerable } from '../internal/Enumerable';

function skipWhile<TSource>(this: Enumerable<TSource>, predicate: (element: TSource) => boolean): Enumerable<TSource> {
return this.lift<TSource>(skipWhileFn.call(this.source, predicate));
return new Enumerable<TSource>(skipWhileFn.call(this.source, predicate));
}

Enumerable.prototype.skipWhile = skipWhile;
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/startWith.ts
Expand Up @@ -2,7 +2,7 @@ import startWithFn from '../startWith';
import { Enumerable } from '../internal/Enumerable';

function startWith<TSource>(this: Enumerable<TSource>, ...elements: TSource[]): Enumerable<TSource> {
return this.lift<TSource>(startWithFn.apply(this.source, elements));
return new Enumerable<TSource>(startWithFn.apply(this.source, elements));
}

Enumerable.prototype.startWith = startWith;
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/take.ts
Expand Up @@ -2,7 +2,7 @@ import takeFn from '../take';
import { Enumerable } from '../internal/Enumerable';

function take<TSource>(this: Enumerable<TSource>, count: number): Enumerable<TSource> {
return this.lift<TSource>(takeFn.call(this.source, count));
return new Enumerable<TSource>(takeFn.call(this.source, count));
}

Enumerable.prototype.take = take;
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/takeLast.ts
Expand Up @@ -2,7 +2,7 @@ import takeLastFn from '../takeLast';
import { Enumerable } from '../internal/Enumerable';

function takeLast<TSource>(this: Enumerable<TSource>, count: number): Enumerable<TSource> {
return this.lift<TSource>(takeLastFn.call(this.source, count));
return new Enumerable<TSource>(takeLastFn.call(this.source, count));
}

Enumerable.prototype.takeLast = takeLast;
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/takeWhile.ts
Expand Up @@ -2,7 +2,7 @@ import takeWhileFn from '../takeWhile';
import { Enumerable } from '../internal/Enumerable';

function takeWhile<TSource>(this: Enumerable<TSource>, predicate: (element: TSource) => boolean): Enumerable<TSource> {
return this.lift<TSource>(takeWhileFn.call(this.source, predicate));
return new Enumerable<TSource>(takeWhileFn.call(this.source, predicate));
}

Enumerable.prototype.takeWhile = takeWhile;
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/union.ts
Expand Up @@ -2,7 +2,7 @@ import unionFn from '../union';
import { Enumerable } from '../internal/Enumerable';

function union<TSource>(this: Enumerable<TSource>, second: Iterable<TSource>): Enumerable<TSource> {
return this.lift<TSource>(unionFn.call(this.source, second));
return new Enumerable<TSource>(unionFn.call(this.source, second));
}

Enumerable.prototype.union = union;
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/where.ts
Expand Up @@ -2,7 +2,7 @@ import whereFn from '../where';
import { Enumerable } from '../internal/Enumerable';

function where<TSource>(this: Enumerable<TSource>, predicate: (item: TSource) => boolean): Enumerable<TSource> {
return this.lift<TSource>(whereFn.call(this.source, predicate));
return new Enumerable<TSource>(whereFn.call(this.source, predicate));
}

Enumerable.prototype.where = where;
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/while.ts
Expand Up @@ -2,7 +2,7 @@ import whileFn from '../while';
import { Enumerable } from '../internal/Enumerable';

function _while<TSource>(this: Enumerable<TSource>, condition: () => boolean): Enumerable<TSource> {
return this.lift<TSource>(whileFn.call(this.source, condition));
return new Enumerable<TSource>(whileFn.call(this.source, condition));
}

Enumerable.prototype.while = _while;
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/zip.ts
Expand Up @@ -2,7 +2,7 @@ import zipFn from '../zip';
import { Enumerable } from '../internal/Enumerable';

function zip<TFirst, TSecond, TResult>(this: Enumerable<TFirst>, second: Iterable<TSecond>, resultSelector: (first: TFirst, second: TSecond) => TResult): Enumerable<TResult> {
return this.lift<TResult>(zipFn.call(this.source, second, resultSelector));
return new Enumerable<TResult>(zipFn.call(this.source, second, resultSelector));
}

Enumerable.prototype.zip = zip;
Expand Down
6 changes: 1 addition & 5 deletions src/internal/Enumerable.ts
Expand Up @@ -22,14 +22,10 @@ export class Enumerable<TSource> implements Iterable<TSource> {
pipe<T1, T2, T3, T4, T5, T6, T7, T8>(op1: Operator<TSource, T1>, op2: Operator<T1, T2>, op3: Operator<T2, T3>, op4: Operator<T3, T4>, op5: Operator<T4, T5>, op6: Operator<T5, T6>, op7: Operator<T6, T7>, op8: Operator<T7, T8>): Enumerable<T8>;
pipe<T1, T2, T3, T4, T5, T6, T7, T8, T9>(op1: Operator<TSource, T1>, op2: Operator<T1, T2>, op3: Operator<T2, T3>, op4: Operator<T3, T4>, op5: Operator<T4, T5>, op6: Operator<T5, T6>, op7: Operator<T6, T7>, op8: Operator<T7, T8>, op9: Operator<T8, T9>): Enumerable<T9>;
pipe<TResult>(...operators: Operator<any, any>[]): Enumerable<TResult> {
return this.lift(operators.reduce((source, operator) => operator(source), this.source));
return new Enumerable(operators.reduce((source, operator) => operator(source), this.source));
}

let<TResult>(func: (source: Iterable<TSource>) => TResult): TResult {
return func(this.source);
}

lift<TResult>(source: Iterable<TResult>): Enumerable<TResult> {
return new Enumerable(source);
}
}

0 comments on commit 9346d80

Please sign in to comment.