Skip to content

Commit

Permalink
refactor(src): remove unneccary usage of '&' from typings
Browse files Browse the repository at this point in the history
  • Loading branch information
tusharmath committed May 6, 2018
1 parent 54e8070 commit bbdfc7c
Show file tree
Hide file tree
Showing 13 changed files with 42 additions and 27 deletions.
4 changes: 3 additions & 1 deletion benchmarks/bm.debounce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export function bm_debounce(suite: Suite) {
return suite.add(
'file -> debounce',
(d: IDeferred) => run(debounce(100, fromArray(a)), d),
{defer: true}
{
defer: true
}
)
}
3 changes: 2 additions & 1 deletion src/operators/Combine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class CombineObservable<T> implements IObservable<T> {
export const combine = curry(
<T>(selector: TSelector<T>, sources: IObservable<any>[]) =>
new CombineObservable(selector, sources)
) as {<T, R>(selector: TSelector<T>, sources: TSource): TResult<R>} & {
) as {
<T, R>(selector: TSelector<T>, sources: TSource): TResult<R>
<T, R>(selector: TSelector<T>): {(sources: TSource): TResult<R>}
}
2 changes: 1 addition & 1 deletion src/operators/Debounce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ export const debounce = curry(
<T>(timeout: number, source: IObservable<T>) => new Debounce(timeout, source)
) as {
<T>(timeout: number, source: IObservable<T>): IObservable<T>
} & {

<T>(timeout: number): {(source: IObservable<T>): IObservable<T>}
}
3 changes: 2 additions & 1 deletion src/operators/Delay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class DelayObservable<T> implements IObservable<T> {
export const delay = curry(
<T>(timeout: number, source: IObservable<T>): IObservable<T> =>
new DelayObservable(timeout, source)
) as {<T>(timeout: number, source: IObservable<T>): IObservable<T>} & {
) as {
<T>(timeout: number, source: IObservable<T>): IObservable<T>
<T>(timeout: number): {(source: IObservable<T>): IObservable<T>}
}
3 changes: 2 additions & 1 deletion src/operators/Filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export const filter = curry(function<T>(
source: TSource<T>
) {
return new FilterObservable(predicate, source)
}) as {<T>(predicate: TPredicate<T>, source: TSource<T>): TResult<T>} & {
}) as {
<T>(predicate: TPredicate<T>, source: TSource<T>): TResult<T>
<T>(predicate: TPredicate<T>): {(source: TSource<T>): TResult<T>}
}
22 changes: 15 additions & 7 deletions src/operators/MergeMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,29 @@ import {just} from '../sources/Create'

export type Project<T, S> = (t: T) => IObservable<S>

// prettier-ignore
export type mergeMapFunctionWithConcurrency = {
<T, S>(concurrency: IObservable<number>, project: Project<T, S>, source: IObservable<T>): IObservable<S>
<T, S>(concurrency: IObservable<number>): {(project: Project<T, S>, source: IObservable<T>): IObservable<S>}
<T, S>(concurrency: IObservable<number>): {(project: Project<T, S>): {(source: IObservable<T>): IObservable<S>}}
<T, S>(
concurrency: IObservable<number>,
project: Project<T, S>,
source: IObservable<T>
): IObservable<S>
<T, S>(concurrency: IObservable<number>): {
(project: Project<T, S>, source: IObservable<T>): IObservable<S>
}
<T, S>(concurrency: IObservable<number>): {
(project: Project<T, S>): {(source: IObservable<T>): IObservable<S>}
}
}

// prettier-ignore
export type mergeMapFunction = {
<T, S>(project: Project<T, S>, source: IObservable<T>): IObservable<S>
<T, S>(project: Project<T, S>, source: IObservable<T>): IObservable<S>
<T, S>(project: Project<T, S>): {(source: IObservable<T>): IObservable<S>}
}
// prettier-ignore
export type joinFunction = <T>(source: IObservable<IObservable<T>>) => IObservable<T>

export type joinFunction = <T>(
source: IObservable<IObservable<T>>
) => IObservable<T>

class ConcurrencyObserver extends ErrorMixin(Virgin)
implements IObserver<number> {
Expand Down
6 changes: 3 additions & 3 deletions src/operators/Reduce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ export const reduce = curry(function<T, R>(
<T, R>(reducer: TReducer<T, R>, seed: TSeed<R>, source: TSource<T>): TResult<
R
>
} & {

<T, R>(reducer: TReducer<T, R>): {
(seed: TSeed<R>, source: TSource<T>): TResult<R>
}
} & {

<T, R>(reducer: TReducer<T, R>, seed: TSeed<R>): {
(source: TSource<T>): TResult<R>
}
} & {

<T, R>(reducer: TReducer<T, R>): {
(seed: TSeed<R>): {(source: TSource<T>): TResult<R>}
}
Expand Down
6 changes: 3 additions & 3 deletions src/operators/Sample.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,15 @@ export const sample = curry(function<T>(
return new SampleObservable(f, sampler, sources)
}) as {
<T>(selector: TSelector<T>, sampler: TSampler, source: TSources): TResult<T>
} & {

<T>(selector: TSelector<T>): {
(sampler: TSampler, source: TSources): TResult<T>
}
} & {

<T>(selector: TSelector<T>, sampler: TSampler): {
(source: TSources): TResult<T>
}
} & {

<T>(selector: TSelector<T>): {
(sampler: TSampler): {(source: TSources): TResult<T>}
}
Expand Down
6 changes: 3 additions & 3 deletions src/operators/Scan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ export const scan = curry(function<T, V>(
<T, R>(reducer: TReducer<T, R>, seed: TSeed<R>, source: TSource<T>): TResult<
R
>
} & {

<T, R>(reducer: TReducer<T, R>): {
(seed: TSeed<R>, source: TSource<T>): TResult<R>
}
} & {

<T, R>(reducer: TReducer<T, R>, seed: TSeed<R>): {
(source: TSource<T>): TResult<R>
}
} & {

<T, R>(reducer: TReducer<T, R>): {
(seed: TSeed<R>): {(source: TSource<T>): TResult<R>}
}
Expand Down
3 changes: 2 additions & 1 deletion src/operators/SkipRepeats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export const skipRepeats = curry(function(
source: IObservable<any>
) {
return new SkipRepeatsObservable(hashFunction, source)
}) as {<T>(cmp: TComparator<T>, source: TSource<T>): TResult<T>} & {
}) as {
<T>(cmp: TComparator<T>, source: TSource<T>): TResult<T>
<T>(cmp: TComparator<T>): {(source: TSource<T>): TResult<T>}
}
6 changes: 3 additions & 3 deletions src/operators/Slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ export const slice = curry(function(
return new SliceObservable(start, count, source)
}) as {
<T>(start: number, count: number, source: IObservable<T>): IObservable<T>
} & {

<T>(start: number): {(count: number, source: IObservable<T>): IObservable<T>}
} & {

<T>(start: number, count: number): {
(source: IObservable<T>): IObservable<T>
}
} & {

<T>(start: number): {
(count: number): {(source: IObservable<T>): IObservable<T>}
}
Expand Down
2 changes: 1 addition & 1 deletion src/operators/Switch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export const switchMap = curry(
<T, K>(mapper: (t: K) => IObservable<T>, source: IObservable<K>): IObservable<
T
>
} & {

<T, K>(mapper: (t: K) => IObservable<T>): {
(source: IObservable<K>): IObservable<T>
}
Expand Down
3 changes: 2 additions & 1 deletion src/sources/FromDOM.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class DOMObservable implements TResult {

export const fromDOM = curry(function(element: EventTarget, name: string) {
return new DOMObservable(name, element)
}) as {(element: EventTarget, name: string): TResult} & {
}) as {
(element: EventTarget, name: string): TResult
(element: EventTarget): {(name: string): TResult}
}

0 comments on commit bbdfc7c

Please sign in to comment.