Skip to content

Commit

Permalink
feat(chore): wip (ReactiveX#4419)
Browse files Browse the repository at this point in the history
  • Loading branch information
dkosasih committed Apr 10, 2019
1 parent 8561aa1 commit ae813bc
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 17 deletions.
13 changes: 9 additions & 4 deletions package-lock.json

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

Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
import { expect } from 'chai';
import * as Rx from 'rxjs/Rx';
import { Observable, partition } from 'rxjs';
import { hot, cold, expectObservable, expectSubscriptions } from '../helpers/marble-testing';

// TODO: The imports on these tests can't be modernized until we do away with
// the partition "operator" and make it a creation method.
declare function asDiagram(arg: string): Function;

const Observable = Rx.Observable;

/** @test {partition} */
describe('Observable.prototype.partition', () => {
function expectObservableArray(result: Rx.Observable<string>[], expected: string[]) {
function expectObservableArray(result: Observable<string>[], expected: string[]) {
for (let idx = 0; idx < result.length; idx++ ) {
expectObservable(result[idx]).toBe(expected[idx]);
}
Expand All @@ -23,7 +19,7 @@ describe('Observable.prototype.partition', () => {
const expected = ['--1-----3---------5------|',
'----2----------4------6--|'];

const result = e1.partition((x: any) => x % 2 === 1);
const result = partition(e1, (x: any) => x % 2 === 1);

expectObservableArray(result, expected);
expectSubscriptions(e1.subscriptions).toBe([e1subs, e1subs]);
Expand All @@ -39,7 +35,7 @@ describe('Observable.prototype.partition', () => {
return x === 'a';
}

expectObservableArray(e1.partition(predicate), expected);
expectObservableArray(partition(e1, predicate), expected);
expectSubscriptions(e1.subscriptions).toBe([e1subs, e1subs]);
});

Expand All @@ -53,7 +49,7 @@ describe('Observable.prototype.partition', () => {
return index % 2 === 0;
}

expectObservableArray(e1.partition(predicate), expected);
expectObservableArray(partition(e1, predicate), expected);
expectSubscriptions(e1.subscriptions).toBe([e1subs, e1subs]);
});

Expand All @@ -67,7 +63,7 @@ describe('Observable.prototype.partition', () => {
return x === this.value;
}

expectObservableArray(e1.partition(predicate, {value: 'a'}), expected);
expectObservableArray(partition(e1, predicate, {value: 'a'}), expected);
expectSubscriptions(e1.subscriptions).toBe([e1subs, e1subs]);
});

Expand All @@ -81,7 +77,7 @@ describe('Observable.prototype.partition', () => {
return x === 'a';
}

expectObservableArray(e1.partition(predicate), expected);
expectObservableArray(partition(e1, predicate), expected);
expectSubscriptions(e1.subscriptions).toBe([e1subs, e1subs]);
});

Expand All @@ -95,7 +91,7 @@ describe('Observable.prototype.partition', () => {
return x === 'a';
}

expectObservableArray(e1.partition(predicate), expected);
expectObservableArray(partition(e1, predicate), expected);
expectSubscriptions(e1.subscriptions).toBe([e1subs, e1subs]);
});

Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export { never } from './internal/observable/never';
export { of } from './internal/observable/of';
export { onErrorResumeNext } from './internal/observable/onErrorResumeNext';
export { pairs } from './internal/observable/pairs';
export { partition } from './internal/observable/partition';
export { race } from './internal/observable/race';
export { range } from './internal/observable/range';
export { throwError } from './internal/observable/throwError';
Expand Down
2 changes: 1 addition & 1 deletion src/internal/observable/partition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { Observable } from '../Observable';
* ## Example
* Partition a set of numbers into odds and evens observables
* ```ts
* import { partition } from 'rxjs';
* import { of, partition } from 'rxjs';
*
* const observableValues = of(1, 2, 3, 4, 5, 6);
* const [evens$, odds$] = partition(observableValues, (value, index) => value % 2 === 0);
Expand Down

0 comments on commit ae813bc

Please sign in to comment.