Skip to content

Commit c81b8de

Browse files
moniuchbenlesh
authored andcommitted
update jsdoc examples (audit* through distinct*) (#3768)
* docs(jsdoc): audit* - update example to use pipe() * docs(jsdoc): buffer* - update example to use pipe() * docs(jsdoc): catchError - update example to use pipe() * docs(jsdoc): concat* - update example to use pipe() * docs(jsdoc): count - update example to use pipe() * docs(jsdoc): debounce* - update example to use pipe() * docs(jsdoc): defaultIfEmpty - update example to use pipe() * docs(jsdoc): delay* - update example to use pipe() * docs(jsdoc): dematerialize - update example to use pipe() * docs(jsdoc): distinct* - update example to use pipe()
1 parent 1cd284a commit c81b8de

21 files changed

+124
-105
lines changed

src/internal/operators/audit.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ import { subscribeToResult } from '../util/subscribeToResult';
3131
* repeats for the next source value.
3232
*
3333
* @example <caption>Emit clicks at a rate of at most one click per second</caption>
34-
* var clicks = Rx.Observable.fromEvent(document, 'click');
35-
* var result = clicks.audit(ev => Rx.Observable.interval(1000));
34+
* const clicks = fromEvent(document, 'click');
35+
* const result = clicks.pipe(audit(ev => Rx.Observable.interval(1000)));
3636
* result.subscribe(x => console.log(x));
3737
*
3838
* @see {@link auditTime}

src/internal/operators/auditTime.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ import { MonoTypeOperatorFunction, SchedulerLike } from '../types';
2525
* Optionally takes a {@link IScheduler} for managing timers.
2626
*
2727
* @example <caption>Emit clicks at a rate of at most one click per second</caption>
28-
* var clicks = Rx.Observable.fromEvent(document, 'click');
29-
* var result = clicks.auditTime(1000);
28+
* const clicks = fromEvent(document, 'click');
29+
* const result = clicks.pipe(auditTime(1000));
3030
* result.subscribe(x => console.log(x));
3131
*
3232
* @see {@link audit}

src/internal/operators/buffer.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ import { OperatorFunction } from '../types';
2020
* `closingNotifier` emits.
2121
*
2222
* @example <caption>On every click, emit array of most recent interval events</caption>
23-
* var clicks = Rx.Observable.fromEvent(document, 'click');
24-
* var interval = Rx.Observable.interval(1000);
25-
* var buffered = interval.buffer(clicks);
23+
* const clicks = fromEvent(document, 'click');
24+
* const interval = interval(1000);
25+
* const buffered = interval.pipe(buffer(clicks));
2626
* buffered.subscribe(x => console.log(x));
2727
*
2828
* @see {@link bufferCount}

src/internal/operators/bufferCount.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ import { OperatorFunction, TeardownLogic } from '../types';
1919
* and when each buffer closes and is emitted.
2020
*
2121
* @example <caption>Emit the last two click events as an array</caption>
22-
* var clicks = Rx.Observable.fromEvent(document, 'click');
23-
* var buffered = clicks.bufferCount(2);
22+
* const clicks = fromEvent(document, 'click');
23+
* const buffered = clicks.pipe(bufferCount(2));
2424
* buffered.subscribe(x => console.log(x));
2525
*
2626
* @example <caption>On every click, emit the last two click events as an array</caption>
27-
* var clicks = Rx.Observable.fromEvent(document, 'click');
28-
* var buffered = clicks.bufferCount(2, 1);
27+
* const clicks = fromEvent(document, 'click');
28+
* const buffered = clicks.pipe(bufferCount(2, 1));
2929
* buffered.subscribe(x => console.log(x));
3030
*
3131
* @see {@link buffer}

src/internal/operators/bufferTime.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ export function bufferTime<T>(bufferTimeSpan: number, bufferCreationInterval: nu
3030
* `bufferTimeSpan` milliseconds or when it contains `maxBufferSize` elements.
3131
*
3232
* @example <caption>Every second, emit an array of the recent click events</caption>
33-
* var clicks = Rx.Observable.fromEvent(document, 'click');
34-
* var buffered = clicks.bufferTime(1000);
33+
* const clicks = fromEvent(document, 'click');
34+
* const buffered = clicks.pipe(bufferTime(1000));
3535
* buffered.subscribe(x => console.log(x));
3636
*
3737
* @example <caption>Every 5 seconds, emit the click events from the next 2 seconds</caption>
38-
* var clicks = Rx.Observable.fromEvent(document, 'click');
39-
* var buffered = clicks.bufferTime(2000, 5000);
38+
* const clicks = fromEvent(document, 'click');
39+
* const buffered = clicks.pipe(bufferTime(2000, 5000));
4040
* buffered.subscribe(x => console.log(x));
4141
*
4242
* @see {@link buffer}

src/internal/operators/bufferToggle.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ import { OperatorFunction, SubscribableOrPromise } from '../types';
2222
* a Subscribable or Promise returned by the `closingSelector` function emits.
2323
*
2424
* @example <caption>Every other second, emit the click events from the next 500ms</caption>
25-
* var clicks = Rx.Observable.fromEvent(document, 'click');
26-
* var openings = Rx.Observable.interval(1000);
27-
* var buffered = clicks.bufferToggle(openings, i =>
28-
* i % 2 ? Rx.Observable.interval(500) : Rx.Observable.empty()
29-
* );
25+
* const clicks = fromEvent(document, 'click');
26+
* const openings = interval(1000);
27+
* const buffered = clicks.pipe(bufferToggle(openings, i =>
28+
* i % 2 ? interval(500) : empty()
29+
* ));
3030
* buffered.subscribe(x => console.log(x));
3131
*
3232
* @see {@link buffer}

src/internal/operators/bufferWhen.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ import { OperatorFunction } from '../types';
2424
* the buffer, it immediately opens a new buffer and repeats the process.
2525
*
2626
* @example <caption>Emit an array of the last clicks every [1-5] random seconds</caption>
27-
* var clicks = Rx.Observable.fromEvent(document, 'click');
28-
* var buffered = clicks.bufferWhen(() =>
29-
* Rx.Observable.interval(1000 + Math.random() * 4000)
30-
* );
27+
* const clicks = fromEvent(document, 'click');
28+
* const buffered = clicks.pipe(bufferWhen(() =>
29+
* interval(1000 + Math.random() * 4000)
30+
* ));
3131
* buffered.subscribe(x => console.log(x));
3232
*
3333
* @see {@link buffer}

src/internal/operators/catchError.ts

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,43 +13,46 @@ import { ObservableInput, OperatorFunction, MonoTypeOperatorFunction } from '../
1313
*
1414
* @example <caption>Continues with a different Observable when there's an error</caption>
1515
*
16-
* Observable.of(1, 2, 3, 4, 5)
17-
* .map(n => {
18-
* if (n == 4) {
19-
* throw 'four!';
20-
* }
21-
* return n;
22-
* })
23-
* .catch(err => Observable.of('I', 'II', 'III', 'IV', 'V'))
16+
* of(1, 2, 3, 4, 5).pipe(
17+
* map(n => {
18+
* if (n == 4) {
19+
* throw 'four!';
20+
* }
21+
* return n;
22+
* }),
23+
* catchError(err => of('I', 'II', 'III', 'IV', 'V')),
24+
* )
2425
* .subscribe(x => console.log(x));
2526
* // 1, 2, 3, I, II, III, IV, V
2627
*
2728
* @example <caption>Retries the caught source Observable again in case of error, similar to retry() operator</caption>
2829
*
29-
* Observable.of(1, 2, 3, 4, 5)
30-
* .map(n => {
31-
* if (n === 4) {
32-
* throw 'four!';
33-
* }
34-
* return n;
35-
* })
36-
* .catch((err, caught) => caught)
37-
* .take(30)
30+
* of(1, 2, 3, 4, 5).pipe(
31+
* map(n => {
32+
* if (n === 4) {
33+
* throw 'four!';
34+
* }
35+
* return n;
36+
* }),
37+
* catchError((err, caught) => caught),
38+
* take(30),
39+
* )
3840
* .subscribe(x => console.log(x));
3941
* // 1, 2, 3, 1, 2, 3, ...
4042
*
4143
* @example <caption>Throws a new error when the source Observable throws an error</caption>
4244
*
43-
* Observable.of(1, 2, 3, 4, 5)
44-
* .map(n => {
45-
* if (n == 4) {
46-
* throw 'four!';
47-
* }
48-
* return n;
49-
* })
50-
* .catch(err => {
51-
* throw 'error in source. Details: ' + err;
52-
* })
45+
* of(1, 2, 3, 4, 5).pipe(
46+
* map(n => {
47+
* if (n == 4) {
48+
* throw 'four!';
49+
* }
50+
* return n;
51+
* }),
52+
* catchError(err => {
53+
* throw 'error in source. Details: ' + err;
54+
* }),
55+
* )
5356
* .subscribe(
5457
* x => console.log(x),
5558
* err => console.log(err)

src/internal/operators/concatAll.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@ export function concatAll<R>(): OperatorFunction<any, R>;
2828
* to `1`.
2929
*
3030
* @example <caption>For each click event, tick every second from 0 to 3, with no concurrency</caption>
31-
* var clicks = Rx.Observable.fromEvent(document, 'click');
32-
* var higherOrder = clicks.map(ev => Rx.Observable.interval(1000).take(4));
33-
* var firstOrder = higherOrder.concatAll();
31+
* const clicks = fromEvent(document, 'click');
32+
* const higherOrder = clicks.pipe(
33+
* map(ev => interval(1000).pipe(take(4))),
34+
* );
35+
* const firstOrder = higherOrder.pipe(concatAll());
3436
* firstOrder.subscribe(x => console.log(x));
3537
*
3638
* // Results in the following:

src/internal/operators/concatMap.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ export function concatMap<T, I, R>(project: (value: T, index: number) => Observ
3333
* to `1`.
3434
*
3535
* @example <caption>For each click event, tick every second from 0 to 3, with no concurrency</caption>
36-
* var clicks = Rx.Observable.fromEvent(document, 'click');
37-
* var result = clicks.concatMap(ev => Rx.Observable.interval(1000).take(4));
36+
* const clicks = fromEvent(document, 'click');
37+
* const result = clicks.pipe(
38+
* concatMap(ev => interval(1000).pipe(take(4)),
39+
* );
3840
* result.subscribe(x => console.log(x));
3941
*
4042
* // Results in the following:

src/internal/operators/concatMapTo.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ export function concatMapTo<T, I, R>(observable: ObservableInput<I>, resultSelec
3333
* set to `1`.
3434
*
3535
* @example <caption>For each click event, tick every second from 0 to 3, with no concurrency</caption>
36-
* var clicks = Rx.Observable.fromEvent(document, 'click');
37-
* var result = clicks.concatMapTo(Rx.Observable.interval(1000).take(4));
36+
* const clicks = fromEvent(document, 'click');
37+
* const result = clicks.pipe(
38+
* concatMapTo(interval(1000).pipe(take(4))),
39+
* );
3840
* result.subscribe(x => console.log(x));
3941
*
4042
* // Results in the following:

src/internal/operators/count.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ import { Subscriber } from '../Subscriber';
2222
* source values that matched `true` with the `predicate`.
2323
*
2424
* @example <caption>Counts how many seconds have passed before the first click happened</caption>
25-
* var seconds = Rx.Observable.interval(1000);
26-
* var clicks = Rx.Observable.fromEvent(document, 'click');
27-
* var secondsBeforeClick = seconds.takeUntil(clicks);
28-
* var result = secondsBeforeClick.count();
25+
* const seconds = interval(1000);
26+
* const clicks = fromEvent(document, 'click');
27+
* const secondsBeforeClick = seconds.pipe(takeUntil(clicks));
28+
* const result = secondsBeforeClick.pipe(count());
2929
* result.subscribe(x => console.log(x));
3030
*
3131
* @example <caption>Counts how many odd numbers are there between 1 and 7</caption>
32-
* var numbers = Rx.Observable.range(1, 7);
33-
* var result = numbers.count(i => i % 2 === 1);
32+
* const numbers = range(1, 7);
33+
* const result = numbers.pipe(count(i => i % 2 === 1));
3434
* result.subscribe(x => console.log(x));
3535
*
3636
* // Results in:

src/internal/operators/debounce.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ import { subscribeToResult } from '../util/subscribeToResult';
3232
* same time as they did on the source Observable.
3333
*
3434
* @example <caption>Emit the most recent click after a burst of clicks</caption>
35-
* var clicks = Rx.Observable.fromEvent(document, 'click');
36-
* var result = clicks.debounce(() => Rx.Observable.interval(1000));
35+
* const clicks = fromEvent(document, 'click');
36+
* const result = clicks.pipe(debounce(() => interval(1000)));
3737
* result.subscribe(x => console.log(x));
3838
*
3939
* @see {@link audit}

src/internal/operators/debounceTime.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ import { MonoTypeOperatorFunction, SchedulerLike, TeardownLogic } from '../types
2929
* managing timers.
3030
*
3131
* @example <caption>Emit the most recent click after a burst of clicks</caption>
32-
* var clicks = Rx.Observable.fromEvent(document, 'click');
33-
* var result = clicks.debounceTime(1000);
32+
* const clicks = fromEvent(document, 'click');
33+
* const result = clicks.pipe(debounceTime(1000));
3434
* result.subscribe(x => console.log(x));
3535
*
3636
* @see {@link auditTime}

src/internal/operators/defaultIfEmpty.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ export function defaultIfEmpty<T, R>(defaultValue?: R): OperatorFunction<T, T |
2222
* having emitted any `next` value).
2323
*
2424
* @example <caption>If no clicks happen in 5 seconds, then emit "no clicks"</caption>
25-
* var clicks = Rx.Observable.fromEvent(document, 'click');
26-
* var clicksBeforeFive = clicks.takeUntil(Rx.Observable.interval(5000));
27-
* var result = clicksBeforeFive.defaultIfEmpty('no clicks');
25+
* const clicks = fromEvent(document, 'click');
26+
* const clicksBeforeFive = clicks.pipe(takeUntil(interval(5000)));
27+
* const result = clicksBeforeFive.pipe(defaultIfEmpty('no clicks'));
2828
* result.subscribe(x => console.log(x));
2929
*
3030
* @see {@link empty}

src/internal/operators/delay.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ import { MonoTypeOperatorFunction, PartialObserver, SchedulerAction, SchedulerLi
2323
* Observable execution until the given date occurs.
2424
*
2525
* @example <caption>Delay each click by one second</caption>
26-
* var clicks = Rx.Observable.fromEvent(document, 'click');
27-
* var delayedClicks = clicks.delay(1000); // each click emitted after 1 second
26+
* const clicks = fromEvent(document, 'click');
27+
* const delayedClicks = clicks.pipe(delay(1000)); // each click emitted after 1 second
2828
* delayedClicks.subscribe(x => console.log(x));
2929
*
3030
* @example <caption>Delay all clicks until a future date happens</caption>
31-
* var clicks = Rx.Observable.fromEvent(document, 'click');
32-
* var date = new Date('March 15, 2050 12:00:00'); // in the future
33-
* var delayedClicks = clicks.delay(date); // click emitted only after that date
31+
* const clicks = fromEvent(document, 'click');
32+
* const date = new Date('March 15, 2050 12:00:00'); // in the future
33+
* const delayedClicks = clicks.pipe(delay(date)); // click emitted only after that date
3434
* delayedClicks.subscribe(x => console.log(x));
3535
*
3636
* @see {@link debounceTime}

src/internal/operators/delayWhen.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ export function delayWhen<T>(delayDurationSelector: (value: T) => Observable<any
3939
* Observable is subscribed.
4040
*
4141
* @example <caption>Delay each click by a random amount of time, between 0 and 5 seconds</caption>
42-
* var clicks = Rx.Observable.fromEvent(document, 'click');
43-
* var delayedClicks = clicks.delayWhen(event =>
44-
* Rx.Observable.interval(Math.random() * 5000)
42+
* const clicks = fromEvent(document, 'click');
43+
* const delayedClicks = clicks.pipe(
44+
* delayWhen(event => interval(Math.random() * 5000)),
4545
* );
4646
* delayedClicks.subscribe(x => console.log(x));
4747
*

src/internal/operators/dematerialize.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ import { OperatorFunction } from '../types';
2222
* Use this operator in conjunction with {@link materialize}.
2323
*
2424
* @example <caption>Convert an Observable of Notifications to an actual Observable</caption>
25-
* var notifA = new Rx.Notification('N', 'A');
26-
* var notifB = new Rx.Notification('N', 'B');
27-
* var notifE = new Rx.Notification('E', void 0,
25+
* const notifA = new Rx.Notification('N', 'A');
26+
* const notifB = new Rx.Notification('N', 'B');
27+
* const notifE = new Rx.Notification('E', void 0,
2828
* new TypeError('x.toUpperCase is not a function')
2929
* );
30-
* var materialized = Rx.Observable.of(notifA, notifB, notifE);
31-
* var upperCase = materialized.dematerialize();
30+
* const materialized = of(notifA, notifB, notifE);
31+
* const upperCase = materialized.pipe(dematerialize());
3232
* upperCase.subscribe(x => console.log(x), e => console.error(e));
3333
*
3434
* // Results in:

src/internal/operators/distinct.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ import { MonoTypeOperatorFunction, TeardownLogic } from '../types';
2121
* that the internal `Set` can be "flushed", basically clearing it of values.
2222
*
2323
* @example <caption>A simple example with numbers</caption>
24-
* Observable.of(1, 1, 2, 2, 2, 1, 2, 3, 4, 3, 2, 1)
25-
* .distinct()
24+
* of(1, 1, 2, 2, 2, 1, 2, 3, 4, 3, 2, 1).pipe(
25+
* distinct(),
26+
* )
2627
* .subscribe(x => console.log(x)); // 1, 2, 3, 4
2728
*
2829
* @example <caption>An example using a keySelector function</caption>
@@ -31,12 +32,14 @@ import { MonoTypeOperatorFunction, TeardownLogic } from '../types';
3132
* name: string
3233
* }
3334
*
34-
* Observable.of<Person>(
35+
* of<Person>(
3536
* { age: 4, name: 'Foo'},
3637
* { age: 7, name: 'Bar'},
37-
* { age: 5, name: 'Foo'})
38-
* .distinct((p: Person) => p.name)
39-
* .subscribe(x => console.log(x));
38+
* { age: 5, name: 'Foo'},
39+
* ).pipe(
40+
* distinct((p: Person) => p.name),
41+
* )
42+
* .subscribe(x => console.log(x));
4043
*
4144
* // displays:
4245
* // { age: 4, name: 'Foo' }

src/internal/operators/distinctUntilChanged.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ export function distinctUntilChanged<T, K>(compare: (x: K, y: K) => boolean, key
1818
* If a comparator function is not provided, an equality check is used by default.
1919
*
2020
* @example <caption>A simple example with numbers</caption>
21-
* Observable.of(1, 1, 2, 2, 2, 1, 1, 2, 3, 3, 4)
22-
* .distinctUntilChanged()
21+
* of(1, 1, 2, 2, 2, 1, 1, 2, 3, 3, 4).pipe(
22+
* distinctUntilChanged(),
23+
* )
2324
* .subscribe(x => console.log(x)); // 1, 2, 1, 2, 3, 4
2425
*
2526
* @example <caption>An example using a compare function</caption>
@@ -28,13 +29,15 @@ export function distinctUntilChanged<T, K>(compare: (x: K, y: K) => boolean, key
2829
* name: string
2930
* }
3031
*
31-
* Observable.of<Person>(
32+
* of<Person>(
3233
* { age: 4, name: 'Foo'},
3334
* { age: 7, name: 'Bar'},
34-
* { age: 5, name: 'Foo'})
35-
* { age: 6, name: 'Foo'})
36-
* .distinctUntilChanged((p: Person, q: Person) => p.name === q.name)
37-
* .subscribe(x => console.log(x));
35+
* { age: 5, name: 'Foo'},
36+
* { age: 6, name: 'Foo'},
37+
* ).pipe(
38+
* distinctUntilChanged((p: Person, q: Person) => p.name === q.name),
39+
* )
40+
* .subscribe(x => console.log(x));
3841
*
3942
* // displays:
4043
* // { age: 4, name: 'Foo' }

0 commit comments

Comments
 (0)