Skip to content

Commit

Permalink
chore: fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
felixfbecker committed Aug 25, 2018
1 parent 1a2dc91 commit ed22469
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 31 deletions.
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package.json
package-lock.json
.nyc_output/
lib/
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"build": "tsc -p .",
"test": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --require ts-node/register mocha \"src/*.test.ts\"",
"prettier": "prettier '**/{*.{js?(on),ts,yml},.*.js?(on),.*.yml}' --write --list-different",
"tslint": "tslint -c tslint.json -p tsconfig.json './src/*.ts'",
"tslint": "tslint -t stylish -c tslint.json -p tsconfig.json './src/*.ts'",
"semantic-release": "semantic-release"
},
"nyc": {
Expand Down Expand Up @@ -52,6 +52,7 @@
"sinon": "^6.1.5",
"ts-node": "^7.0.1",
"tslint": "^5.11.0",
"tslint-config-prettier": "^1.15.0",
"typescript": "^3.0.1"
}
}
6 changes: 3 additions & 3 deletions src/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Object.assign(global, require('abort-controller'))

import { create, defer, toPromise, switchMap, concatMap, mergeMap, forEach } from '.'
import { AssertionError } from 'assert'
import { assert } from 'chai'
import { Observable, of, Subject, Subscriber } from 'rxjs'
import * as sinon from 'sinon'
import { Subscriber, Subject, Observable, of } from 'rxjs'
import { AssertionError } from 'assert'
import { concatMap, create, defer, forEach, mergeMap, switchMap, toPromise } from '.'

describe('Observable factories', () => {
describe('create()', () => {
Expand Down
32 changes: 16 additions & 16 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,6 @@
import { from, Observable, ObservableInput, Subscriber, Subscription, TeardownLogic, OperatorFunction } from 'rxjs'
import { from, Observable, ObservableInput, OperatorFunction, Subscriber, Subscription, TeardownLogic } from 'rxjs'
import { concatMap as rxConcatMap, mergeMap as rxMergeMap, switchMap as rxSwitchMap } from 'rxjs/operators'

export const switchMap = <T, R>(
project: (value: T, index: number, abortSignal: AbortSignal) => ObservableInput<R>
): OperatorFunction<T, R> => source =>
source.pipe(rxSwitchMap((value, index) => defer(abortSignal => project(value, index, abortSignal))))

export const concatMap = <T, R>(
project: (value: T, index: number, abortSignal: AbortSignal) => ObservableInput<R>
): OperatorFunction<T, R> => source =>
source.pipe(rxConcatMap((value, index) => defer(abortSignal => project(value, index, abortSignal))))

export const mergeMap = <T, R>(
project: (value: T, index: number, abortSignal: AbortSignal) => ObservableInput<R>
): OperatorFunction<T, R> => source =>
source.pipe(rxMergeMap((value, index) => defer(abortSignal => project(value, index, abortSignal))))

export const create = <T>(
subscribe?: (subscriber: Subscriber<T>, signal: AbortSignal) => TeardownLogic
): Observable<T> =>
Expand Down Expand Up @@ -81,3 +66,18 @@ export const forEach = <T>(source: Observable<T>, next: (value: T) => void, sign
})
}
})

export const switchMap = <T, R>(
project: (value: T, index: number, abortSignal: AbortSignal) => ObservableInput<R>
): OperatorFunction<T, R> => source =>
source.pipe(rxSwitchMap((value, index) => defer(abortSignal => project(value, index, abortSignal))))

export const concatMap = <T, R>(
project: (value: T, index: number, abortSignal: AbortSignal) => ObservableInput<R>
): OperatorFunction<T, R> => source =>
source.pipe(rxConcatMap((value, index) => defer(abortSignal => project(value, index, abortSignal))))

export const mergeMap = <T, R>(
project: (value: T, index: number, abortSignal: AbortSignal) => ObservableInput<R>
): OperatorFunction<T, R> => source =>
source.pipe(rxMergeMap((value, index) => defer(abortSignal => project(value, index, abortSignal))))
12 changes: 1 addition & 11 deletions tslint.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": ["tslint:recommended", "rxjs-tslint-rules", "tslint-react", "tslint-config-prettier"],
"extends": ["tslint:recommended", "tslint-config-prettier"],
"rules": {
"adjacent-overload-signatures": true,
"array-type": [true, "array"],
Expand Down Expand Up @@ -87,16 +87,6 @@
"prefer-template": [false, "allow-single-concat"],
"quotemark": [true, "single", "jsx-double", "avoid-escape"],
"return-undefined": true,
"rxjs-no-add": {
"severity": "error"
},
"rxjs-no-operator": {
"severity": "error"
},
"rxjs-no-patched": {
"severity": "error"
},
"rxjs-no-wholesale": true,
"space-before-function-paren": [
true,
{
Expand Down

0 comments on commit ed22469

Please sign in to comment.