From 8e778be8f622f009bc9aaac3a5b3321b1e9c1805 Mon Sep 17 00:00:00 2001 From: Ben Lesh Date: Mon, 21 Jun 2021 11:32:53 -0500 Subject: [PATCH 1/3] feat: operators are all exported at the top level, from "rxjs". Related #6242 --- spec/index-spec.ts | 110 +++++++++++++++++++++++++++++++++++++++++++++ src/index.ts | 108 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 218 insertions(+) diff --git a/spec/index-spec.ts b/spec/index-spec.ts index 0b469a36d1..c21c2d1e7d 100644 --- a/spec/index-spec.ts +++ b/spec/index-spec.ts @@ -1,3 +1,4 @@ +/** @prettier */ import * as index from '../src/index'; import { expect } from 'chai'; @@ -79,6 +80,115 @@ describe('index', () => { expect(index.zip).to.exist; }); + it('should export all of the operators', () => { + expect(index.audit).to.exist; + expect(index.auditTime).to.exist; + expect(index.buffer).to.exist; + expect(index.bufferCount).to.exist; + expect(index.bufferTime).to.exist; + expect(index.bufferToggle).to.exist; + expect(index.bufferWhen).to.exist; + expect(index.catchError).to.exist; + expect(index.combineAll).to.exist; + expect(index.combineLatestAll).to.exist; + expect(index.combineLatestWith).to.exist; + expect(index.concatAll).to.exist; + expect(index.concatMap).to.exist; + expect(index.concatMapTo).to.exist; + expect(index.concatWith).to.exist; + expect(index.connect).to.exist; + expect(index.count).to.exist; + expect(index.debounce).to.exist; + expect(index.debounceTime).to.exist; + expect(index.defaultIfEmpty).to.exist; + expect(index.delay).to.exist; + expect(index.delayWhen).to.exist; + expect(index.dematerialize).to.exist; + expect(index.distinct).to.exist; + expect(index.distinctUntilChanged).to.exist; + expect(index.distinctUntilKeyChanged).to.exist; + expect(index.elementAt).to.exist; + expect(index.endWith).to.exist; + expect(index.every).to.exist; + expect(index.exhaust).to.exist; + expect(index.exhaustAll).to.exist; + expect(index.exhaustMap).to.exist; + expect(index.expand).to.exist; + expect(index.filter).to.exist; + expect(index.finalize).to.exist; + expect(index.find).to.exist; + expect(index.findIndex).to.exist; + expect(index.first).to.exist; + expect(index.groupBy).to.exist; + expect(index.ignoreElements).to.exist; + expect(index.isEmpty).to.exist; + expect(index.last).to.exist; + expect(index.map).to.exist; + expect(index.mapTo).to.exist; + expect(index.materialize).to.exist; + expect(index.max).to.exist; + expect(index.mergeAll).to.exist; + expect(index.flatMap).to.exist; + expect(index.mergeMap).to.exist; + expect(index.mergeMapTo).to.exist; + expect(index.mergeScan).to.exist; + expect(index.mergeWith).to.exist; + expect(index.min).to.exist; + expect(index.multicast).to.exist; + expect(index.observeOn).to.exist; + expect(index.pairwise).to.exist; + expect(index.pluck).to.exist; + expect(index.publish).to.exist; + expect(index.publishBehavior).to.exist; + expect(index.publishLast).to.exist; + expect(index.publishReplay).to.exist; + expect(index.raceWith).to.exist; + expect(index.reduce).to.exist; + expect(index.repeat).to.exist; + expect(index.repeatWhen).to.exist; + expect(index.retry).to.exist; + expect(index.retryWhen).to.exist; + expect(index.refCount).to.exist; + expect(index.sample).to.exist; + expect(index.sampleTime).to.exist; + expect(index.scan).to.exist; + expect(index.sequenceEqual).to.exist; + expect(index.share).to.exist; + expect(index.shareReplay).to.exist; + expect(index.single).to.exist; + expect(index.skip).to.exist; + expect(index.skipLast).to.exist; + expect(index.skipUntil).to.exist; + expect(index.skipWhile).to.exist; + expect(index.startWith).to.exist; + expect(index.subscribeOn).to.exist; + expect(index.switchAll).to.exist; + expect(index.switchMap).to.exist; + expect(index.switchMapTo).to.exist; + expect(index.switchScan).to.exist; + expect(index.take).to.exist; + expect(index.takeLast).to.exist; + expect(index.takeUntil).to.exist; + expect(index.takeWhile).to.exist; + expect(index.tap).to.exist; + expect(index.throttle).to.exist; + expect(index.throttleTime).to.exist; + expect(index.throwIfEmpty).to.exist; + expect(index.timeInterval).to.exist; + expect(index.timeout).to.exist; + expect(index.timeoutWith).to.exist; + expect(index.timestamp).to.exist; + expect(index.toArray).to.exist; + expect(index.window).to.exist; + expect(index.windowCount).to.exist; + expect(index.windowTime).to.exist; + expect(index.windowToggle).to.exist; + expect(index.windowWhen).to.exist; + expect(index.withLatestFrom).to.exist; + expect(index.zipAll).to.exist; + expect(index.zipWith).to.exist; + }); + it('should expose configuration', () => { expect(index.config).to.exist; }); diff --git a/src/index.ts b/src/index.ts index 1e28bda97d..fc418731e3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -98,3 +98,111 @@ export * from './internal/types'; /* Config */ export { config, GlobalConfig } from './internal/config'; + +/* Operators */ +export { audit } from './internal/operators/audit'; +export { auditTime } from './internal/operators/auditTime'; +export { buffer } from './internal/operators/buffer'; +export { bufferCount } from './internal/operators/bufferCount'; +export { bufferTime } from './internal/operators/bufferTime'; +export { bufferToggle } from './internal/operators/bufferToggle'; +export { bufferWhen } from './internal/operators/bufferWhen'; +export { catchError } from './internal/operators/catchError'; +export { combineAll } from './internal/operators/combineAll'; +export { combineLatestAll } from './internal/operators/combineLatestAll'; +export { combineLatestWith } from './internal/operators/combineLatestWith'; +export { concatAll } from './internal/operators/concatAll'; +export { concatMap } from './internal/operators/concatMap'; +export { concatMapTo } from './internal/operators/concatMapTo'; +export { concatWith } from './internal/operators/concatWith'; +export { connect } from './internal/operators/connect'; +export { count } from './internal/operators/count'; +export { debounce } from './internal/operators/debounce'; +export { debounceTime } from './internal/operators/debounceTime'; +export { defaultIfEmpty } from './internal/operators/defaultIfEmpty'; +export { delay } from './internal/operators/delay'; +export { delayWhen } from './internal/operators/delayWhen'; +export { dematerialize } from './internal/operators/dematerialize'; +export { distinct } from './internal/operators/distinct'; +export { distinctUntilChanged } from './internal/operators/distinctUntilChanged'; +export { distinctUntilKeyChanged } from './internal/operators/distinctUntilKeyChanged'; +export { elementAt } from './internal/operators/elementAt'; +export { endWith } from './internal/operators/endWith'; +export { every } from './internal/operators/every'; +export { exhaust } from './internal/operators/exhaust'; +export { exhaustAll } from './internal/operators/exhaustAll'; +export { exhaustMap } from './internal/operators/exhaustMap'; +export { expand } from './internal/operators/expand'; +export { filter } from './internal/operators/filter'; +export { finalize } from './internal/operators/finalize'; +export { find } from './internal/operators/find'; +export { findIndex } from './internal/operators/findIndex'; +export { first } from './internal/operators/first'; +export { groupBy } from './internal/operators/groupBy'; +export { ignoreElements } from './internal/operators/ignoreElements'; +export { isEmpty } from './internal/operators/isEmpty'; +export { last } from './internal/operators/last'; +export { map } from './internal/operators/map'; +export { mapTo } from './internal/operators/mapTo'; +export { materialize } from './internal/operators/materialize'; +export { max } from './internal/operators/max'; +export { mergeAll } from './internal/operators/mergeAll'; +export { flatMap } from './internal/operators/flatMap'; +export { mergeMap } from './internal/operators/mergeMap'; +export { mergeMapTo } from './internal/operators/mergeMapTo'; +export { mergeScan } from './internal/operators/mergeScan'; +export { mergeWith } from './internal/operators/mergeWith'; +export { min } from './internal/operators/min'; +export { multicast } from './internal/operators/multicast'; +export { observeOn } from './internal/operators/observeOn'; +export { pairwise } from './internal/operators/pairwise'; +export { pluck } from './internal/operators/pluck'; +export { publish } from './internal/operators/publish'; +export { publishBehavior } from './internal/operators/publishBehavior'; +export { publishLast } from './internal/operators/publishLast'; +export { publishReplay } from './internal/operators/publishReplay'; +export { raceWith } from './internal/operators/raceWith'; +export { reduce } from './internal/operators/reduce'; +export { repeat } from './internal/operators/repeat'; +export { repeatWhen } from './internal/operators/repeatWhen'; +export { retry } from './internal/operators/retry'; +export { retryWhen } from './internal/operators/retryWhen'; +export { refCount } from './internal/operators/refCount'; +export { sample } from './internal/operators/sample'; +export { sampleTime } from './internal/operators/sampleTime'; +export { scan } from './internal/operators/scan'; +export { sequenceEqual } from './internal/operators/sequenceEqual'; +export { share } from './internal/operators/share'; +export { shareReplay } from './internal/operators/shareReplay'; +export { single } from './internal/operators/single'; +export { skip } from './internal/operators/skip'; +export { skipLast } from './internal/operators/skipLast'; +export { skipUntil } from './internal/operators/skipUntil'; +export { skipWhile } from './internal/operators/skipWhile'; +export { startWith } from './internal/operators/startWith'; +export { subscribeOn } from './internal/operators/subscribeOn'; +export { switchAll } from './internal/operators/switchAll'; +export { switchMap } from './internal/operators/switchMap'; +export { switchMapTo } from './internal/operators/switchMapTo'; +export { switchScan } from './internal/operators/switchScan'; +export { take } from './internal/operators/take'; +export { takeLast } from './internal/operators/takeLast'; +export { takeUntil } from './internal/operators/takeUntil'; +export { takeWhile } from './internal/operators/takeWhile'; +export { tap } from './internal/operators/tap'; +export { throttle } from './internal/operators/throttle'; +export { throttleTime } from './internal/operators/throttleTime'; +export { throwIfEmpty } from './internal/operators/throwIfEmpty'; +export { timeInterval } from './internal/operators/timeInterval'; +export { timeout } from './internal/operators/timeout'; +export { timeoutWith } from './internal/operators/timeoutWith'; +export { timestamp } from './internal/operators/timestamp'; +export { toArray } from './internal/operators/toArray'; +export { window } from './internal/operators/window'; +export { windowCount } from './internal/operators/windowCount'; +export { windowTime } from './internal/operators/windowTime'; +export { windowToggle } from './internal/operators/windowToggle'; +export { windowWhen } from './internal/operators/windowWhen'; +export { withLatestFrom } from './internal/operators/withLatestFrom'; +export { zipAll } from './internal/operators/zipAll'; +export { zipWith } from './internal/operators/zipWith'; From 376345e9d58c147957765b187d986fbcc19bdacc Mon Sep 17 00:00:00 2001 From: Ben Lesh Date: Mon, 21 Jun 2021 11:39:18 -0500 Subject: [PATCH 2/3] chore: update golden files --- api_guard/dist/types/index.d.ts | 314 +++++++++++++++++++++++++++++++- 1 file changed, 313 insertions(+), 1 deletion(-) diff --git a/api_guard/dist/types/index.d.ts b/api_guard/dist/types/index.d.ts index 0bd40f38b6..138caaa115 100644 --- a/api_guard/dist/types/index.d.ts +++ b/api_guard/dist/types/index.d.ts @@ -25,6 +25,10 @@ export declare class AsyncSubject extends Subject { next(value: T): void; } +export declare function audit(durationSelector: (value: T) => ObservableInput): MonoTypeOperatorFunction; + +export declare function auditTime(duration: number, scheduler?: SchedulerLike): MonoTypeOperatorFunction; + export declare class BehaviorSubject extends Subject { get value(): T; constructor(_value: T); @@ -38,6 +42,22 @@ export declare function bindCallback void, resultSelector: (...args: any[]) => any, scheduler?: SchedulerLike): (...args: any[]) => Observable; export declare function bindNodeCallback(callbackFunc: (...args: [...A, (err: any, ...res: R) => void]) => void, schedulerLike?: SchedulerLike): (...arg: A) => Observable; +export declare function buffer(closingNotifier: Observable): OperatorFunction; + +export declare function bufferCount(bufferSize: number, startBufferEvery?: number | null): OperatorFunction; + +export declare function bufferTime(bufferTimeSpan: number, scheduler?: SchedulerLike): OperatorFunction; +export declare function bufferTime(bufferTimeSpan: number, bufferCreationInterval: number | null | undefined, scheduler?: SchedulerLike): OperatorFunction; +export declare function bufferTime(bufferTimeSpan: number, bufferCreationInterval: number | null | undefined, maxBufferSize: number, scheduler?: SchedulerLike): OperatorFunction; + +export declare function bufferToggle(openings: ObservableInput, closingSelector: (value: O) => ObservableInput): OperatorFunction; + +export declare function bufferWhen(closingSelector: () => ObservableInput): OperatorFunction; + +export declare function catchError>(selector: (err: any, caught: Observable) => O): OperatorFunction>; + +export declare const combineAll: typeof combineLatestAll; + export declare function combineLatest(arg: T): Observable; export declare function combineLatest(sources: []): Observable; export declare function combineLatest(sources: readonly [...ObservableInputTuple]): Observable; @@ -55,6 +75,13 @@ export declare function combineLatest; }>; +export declare function combineLatestAll(): OperatorFunction, T[]>; +export declare function combineLatestAll(): OperatorFunction; +export declare function combineLatestAll(project: (...values: T[]) => R): OperatorFunction, R>; +export declare function combineLatestAll(project: (...values: Array) => R): OperatorFunction; + +export declare function combineLatestWith(...otherSources: [...ObservableInputTuple]): OperatorFunction>; + export interface CompleteNotification { kind: 'C'; } @@ -69,8 +96,22 @@ export interface CompletionObserver { export declare function concat(...inputs: [...ObservableInputTuple]): Observable; export declare function concat(...inputsAndScheduler: [...ObservableInputTuple, SchedulerLike]): Observable; +export declare function concatAll>(): OperatorFunction>; + +export declare function concatMap>(project: (value: T, index: number) => O): OperatorFunction>; +export declare function concatMap>(project: (value: T, index: number) => O, resultSelector: undefined): OperatorFunction>; +export declare function concatMap>(project: (value: T, index: number) => O, resultSelector: (outerValue: T, innerValue: ObservedValueOf, outerIndex: number, innerIndex: number) => R): OperatorFunction; + +export declare function concatMapTo>(observable: O): OperatorFunction>; +export declare function concatMapTo>(observable: O, resultSelector: undefined): OperatorFunction>; +export declare function concatMapTo>(observable: O, resultSelector: (outerValue: T, innerValue: ObservedValueOf, outerIndex: number, innerIndex: number) => R): OperatorFunction; + +export declare function concatWith(...otherSources: [...ObservableInputTuple]): OperatorFunction; + export declare const config: GlobalConfig; +export declare function connect>(selector: (shared: Observable) => O, config?: ConnectConfig): OperatorFunction>; + export declare function connectable(source: ObservableInput, config?: ConnectableConfig): ConnectableObservableLike; export declare class ConnectableObservable extends Observable { @@ -88,8 +129,33 @@ export declare class ConnectableObservable extends Observable { export declare type Cons = ((arg: X, ...rest: Y) => any) extends (...args: infer U) => any ? U : never; +export declare function count(predicate?: (value: T, index: number) => boolean): OperatorFunction; + +export declare function debounce(durationSelector: (value: T) => ObservableInput): MonoTypeOperatorFunction; + +export declare function debounceTime(dueTime: number, scheduler?: SchedulerLike): MonoTypeOperatorFunction; + +export declare function defaultIfEmpty(defaultValue: R): OperatorFunction; + export declare function defer>(observableFactory: () => R): Observable>; +export declare function delay(due: number | Date, scheduler?: SchedulerLike): MonoTypeOperatorFunction; + +export declare function delayWhen(delayDurationSelector: (value: T, index: number) => Observable, subscriptionDelay: Observable): MonoTypeOperatorFunction; +export declare function delayWhen(delayDurationSelector: (value: T, index: number) => Observable): MonoTypeOperatorFunction; + +export declare function dematerialize>(): OperatorFunction>; + +export declare function distinct(keySelector?: (value: T) => K, flushes?: Observable): MonoTypeOperatorFunction; + +export declare function distinctUntilChanged(comparator?: (previous: T, current: T) => boolean): MonoTypeOperatorFunction; +export declare function distinctUntilChanged(comparator: (previous: K, current: K) => boolean, keySelector: (value: T) => K): MonoTypeOperatorFunction; + +export declare function distinctUntilKeyChanged(key: keyof T): MonoTypeOperatorFunction; +export declare function distinctUntilKeyChanged(key: K, compare: (x: T[K], y: T[K]) => boolean): MonoTypeOperatorFunction; + +export declare function elementAt(index: number, defaultValue?: D): OperatorFunction; + export declare function empty(scheduler?: SchedulerLike): Observable; export declare const EMPTY: Observable; @@ -99,6 +165,10 @@ export interface EmptyError extends Error { export declare const EmptyError: EmptyErrorCtor; +export declare function endWith(scheduler: SchedulerLike): MonoTypeOperatorFunction; +export declare function endWith(...valuesAndScheduler: [...A, SchedulerLike]): OperatorFunction>; +export declare function endWith(...values: A): OperatorFunction>; + export interface ErrorNotification { error: any; kind: 'E'; @@ -111,13 +181,57 @@ export interface ErrorObserver { next?: (value: T) => void; } +export declare function every(predicate: BooleanConstructor): OperatorFunction extends never ? false : boolean>; +export declare function every(predicate: BooleanConstructor, thisArg: any): OperatorFunction extends never ? false : boolean>; +export declare function every(predicate: (this: A, value: T, index: number, source: Observable) => boolean, thisArg: A): OperatorFunction; +export declare function every(predicate: (value: T, index: number, source: Observable) => boolean): OperatorFunction; + +export declare const exhaust: typeof exhaustAll; + +export declare function exhaustAll>(): OperatorFunction>; + +export declare function exhaustMap>(project: (value: T, index: number) => O): OperatorFunction>; +export declare function exhaustMap>(project: (value: T, index: number) => O, resultSelector: undefined): OperatorFunction>; +export declare function exhaustMap(project: (value: T, index: number) => ObservableInput, resultSelector: (outerValue: T, innerValue: I, outerIndex: number, innerIndex: number) => R): OperatorFunction; + +export declare function expand>(project: (value: T, index: number) => O, concurrent?: number, scheduler?: SchedulerLike): OperatorFunction>; +export declare function expand>(project: (value: T, index: number) => O, concurrent: number | undefined, scheduler: SchedulerLike): OperatorFunction>; + export declare type FactoryOrValue = T | (() => T); export declare type Falsy = null | undefined | false | 0 | -0 | 0n | ''; +export declare function filter(predicate: (this: A, value: T, index: number) => value is S, thisArg: A): OperatorFunction; +export declare function filter(predicate: (value: T, index: number) => value is S): OperatorFunction; +export declare function filter(predicate: BooleanConstructor): OperatorFunction>; +export declare function filter(predicate: (this: A, value: T, index: number) => boolean, thisArg: A): MonoTypeOperatorFunction; +export declare function filter(predicate: (value: T, index: number) => boolean): MonoTypeOperatorFunction; + +export declare function finalize(callback: () => void): MonoTypeOperatorFunction; + +export declare function find(predicate: BooleanConstructor): OperatorFunction>; +export declare function find(predicate: (this: A, value: T, index: number, source: Observable) => value is S, thisArg: A): OperatorFunction; +export declare function find(predicate: (value: T, index: number, source: Observable) => value is S): OperatorFunction; +export declare function find(predicate: (this: A, value: T, index: number, source: Observable) => boolean, thisArg: A): OperatorFunction; +export declare function find(predicate: (value: T, index: number, source: Observable) => boolean): OperatorFunction; + +export declare function findIndex(predicate: BooleanConstructor): OperatorFunction; +export declare function findIndex(predicate: BooleanConstructor, thisArg: any): OperatorFunction; +export declare function findIndex(predicate: (this: A, value: T, index: number, source: Observable) => boolean, thisArg: A): OperatorFunction; +export declare function findIndex(predicate: (value: T, index: number, source: Observable) => boolean): OperatorFunction; + +export declare function first(predicate?: null, defaultValue?: D): OperatorFunction; +export declare function first(predicate: BooleanConstructor): OperatorFunction>; +export declare function first(predicate: BooleanConstructor, defaultValue: D): OperatorFunction | D>; +export declare function first(predicate: (value: T, index: number, source: Observable) => value is S, defaultValue?: S): OperatorFunction; +export declare function first(predicate: (value: T, index: number, source: Observable) => value is S, defaultValue: D): OperatorFunction; +export declare function first(predicate: (value: T, index: number, source: Observable) => boolean, defaultValue?: D): OperatorFunction; + export declare function firstValueFrom(source: Observable, config: FirstValueFromConfig): Promise; export declare function firstValueFrom(source: Observable): Promise; +export declare const flatMap: typeof mergeMap; + export declare function forkJoin(arg: T): Observable; export declare function forkJoin(scheduler: null | undefined): Observable; export declare function forkJoin(sources: readonly []): Observable; @@ -164,6 +278,14 @@ export interface GlobalConfig { useDeprecatedSynchronousErrorHandling: boolean; } +export declare function groupBy(key: (value: T) => K, options: BasicGroupByOptions): OperatorFunction>; +export declare function groupBy(key: (value: T) => K, options: GroupByOptionsWithElement): OperatorFunction>; +export declare function groupBy(key: (value: T) => value is K): OperatorFunction | GroupedObservable>>; +export declare function groupBy(key: (value: T) => K): OperatorFunction>; +export declare function groupBy(key: (value: T) => K, element: void, duration: (grouped: GroupedObservable) => Observable): OperatorFunction>; +export declare function groupBy(key: (value: T) => K, element?: (value: T) => R, duration?: (grouped: GroupedObservable) => Observable): OperatorFunction>; +export declare function groupBy(key: (value: T) => K, element?: (value: T) => R, duration?: (grouped: GroupedObservable) => Observable, connector?: () => Subject): OperatorFunction>; + export interface GroupedObservable extends Observable { readonly key: K; } @@ -172,6 +294,8 @@ export declare type Head = ((...args: X) => any) exten export declare function identity(x: T): T; +export declare function ignoreElements(): OperatorFunction; + export declare function iif(condition: () => boolean, trueResult: ObservableInput, falseResult: ObservableInput): Observable; export interface InteropObservable { @@ -180,19 +304,57 @@ export interface InteropObservable { export declare function interval(period?: number, scheduler?: SchedulerLike): Observable; +export declare function isEmpty(): OperatorFunction; + export declare function isObservable(obj: any): obj is Observable; +export declare function last(predicate: BooleanConstructor): OperatorFunction>; +export declare function last(predicate: BooleanConstructor, defaultValue: D): OperatorFunction | D>; +export declare function last(predicate?: null, defaultValue?: D): OperatorFunction; +export declare function last(predicate: (value: T, index: number, source: Observable) => value is S, defaultValue?: S): OperatorFunction; +export declare function last(predicate: (value: T, index: number, source: Observable) => boolean, defaultValue?: D): OperatorFunction; + export declare function lastValueFrom(source: Observable, config: LastValueFromConfig): Promise; export declare function lastValueFrom(source: Observable): Promise; +export declare function map(project: (value: T, index: number) => R): OperatorFunction; +export declare function map(project: (this: A, value: T, index: number) => R, thisArg: A): OperatorFunction; + +export declare function mapTo(value: R): OperatorFunction; +export declare function mapTo(value: R): OperatorFunction; + +export declare function materialize(): OperatorFunction & ObservableNotification>; + +export declare function max(comparer?: (x: T, y: T) => number): MonoTypeOperatorFunction; + export declare function merge(...sources: [...ObservableInputTuple]): Observable; export declare function merge(...sourcesAndConcurrency: [...ObservableInputTuple, number?]): Observable; export declare function merge(...sourcesAndScheduler: [...ObservableInputTuple, SchedulerLike?]): Observable; export declare function merge(...sourcesAndConcurrencyAndScheduler: [...ObservableInputTuple, number?, SchedulerLike?]): Observable; +export declare function mergeAll>(concurrent?: number): OperatorFunction>; + +export declare function mergeMap>(project: (value: T, index: number) => O, concurrent?: number): OperatorFunction>; +export declare function mergeMap>(project: (value: T, index: number) => O, resultSelector: undefined, concurrent?: number): OperatorFunction>; +export declare function mergeMap>(project: (value: T, index: number) => O, resultSelector: (outerValue: T, innerValue: ObservedValueOf, outerIndex: number, innerIndex: number) => R, concurrent?: number): OperatorFunction; + +export declare function mergeMapTo>(innerObservable: O, concurrent?: number): OperatorFunction>; +export declare function mergeMapTo>(innerObservable: O, resultSelector: (outerValue: T, innerValue: ObservedValueOf, outerIndex: number, innerIndex: number) => R, concurrent?: number): OperatorFunction; + +export declare function mergeScan(accumulator: (acc: R, value: T, index: number) => ObservableInput, seed: R, concurrent?: number): OperatorFunction; + +export declare function mergeWith(...otherSources: [...ObservableInputTuple]): OperatorFunction; + +export declare function min(comparer?: (x: T, y: T) => number): MonoTypeOperatorFunction; + export interface MonoTypeOperatorFunction extends OperatorFunction { } +export declare function multicast(subject: Subject): UnaryFunction, ConnectableObservable>; +export declare function multicast>(subject: Subject, selector: (shared: Observable) => O): OperatorFunction>; +export declare function multicast(subjectFactory: () => Subject): UnaryFunction, ConnectableObservable>; +export declare function multicast>(subjectFactory: () => Subject, selector: (shared: Observable) => O): OperatorFunction>; + export declare function never(): Observable; export declare const NEVER: Observable; @@ -249,7 +411,7 @@ export interface ObjectUnsubscribedError extends Error { export declare const ObjectUnsubscribedError: ObjectUnsubscribedErrorCtor; -export declare const observable: string | symbol; +export declare const observable: string | typeof Symbol.observable; export declare class Observable implements Subscribable { operator: Operator | undefined; @@ -298,6 +460,8 @@ export declare type ObservedValueTupleFromArray = { export declare type ObservedValueUnionFromArray = X extends Array> ? T : never; +export declare function observeOn(scheduler: SchedulerLike, delay?: number): MonoTypeOperatorFunction; + export interface Observer { complete: () => void; error: (err: any) => void; @@ -328,6 +492,8 @@ export declare function pairs>(obj: O, schedul export declare function pairs(iterable: Iterable, scheduler?: SchedulerLike): Observable<[string, T]>; export declare function pairs(n: number | bigint | boolean | ((...args: any[]) => any) | symbol, scheduler?: SchedulerLike): Observable<[never, never]>; +export declare function pairwise(): OperatorFunction; + export declare type PartialObserver = NextObserver | ErrorObserver | CompletionObserver; export declare function partition(source: ObservableInput, predicate: (this: A, value: T, index: number) => value is U, thisArg: A): [Observable, Observable>]; @@ -347,6 +513,26 @@ export declare function pipe(fn1: UnaryFunction export declare function pipe(fn1: UnaryFunction, fn2: UnaryFunction, fn3: UnaryFunction, fn4: UnaryFunction, fn5: UnaryFunction, fn6: UnaryFunction, fn7: UnaryFunction, fn8: UnaryFunction, fn9: UnaryFunction): UnaryFunction; export declare function pipe(fn1: UnaryFunction, fn2: UnaryFunction, fn3: UnaryFunction, fn4: UnaryFunction, fn5: UnaryFunction, fn6: UnaryFunction, fn7: UnaryFunction, fn8: UnaryFunction, fn9: UnaryFunction, ...fns: UnaryFunction[]): UnaryFunction; +export declare function pluck(k1: K1): OperatorFunction; +export declare function pluck(k1: K1, k2: K2): OperatorFunction; +export declare function pluck(k1: K1, k2: K2, k3: K3): OperatorFunction; +export declare function pluck(k1: K1, k2: K2, k3: K3, k4: K4): OperatorFunction; +export declare function pluck(k1: K1, k2: K2, k3: K3, k4: K4, k5: K5): OperatorFunction; +export declare function pluck(k1: K1, k2: K2, k3: K3, k4: K4, k5: K5, k6: K6): OperatorFunction; +export declare function pluck(k1: K1, k2: K2, k3: K3, k4: K4, k5: K5, k6: K6, ...rest: string[]): OperatorFunction; +export declare function pluck(...properties: string[]): OperatorFunction; + +export declare function publish(): UnaryFunction, ConnectableObservable>; +export declare function publish>(selector: (shared: Observable) => O): OperatorFunction>; + +export declare function publishBehavior(initialValue: T): UnaryFunction, ConnectableObservable>; + +export declare function publishLast(): UnaryFunction, ConnectableObservable>; + +export declare function publishReplay(bufferSize?: number, windowTime?: number, timestampProvider?: TimestampProvider): MonoTypeOperatorFunction; +export declare function publishReplay>(bufferSize: number | undefined, windowTime: number | undefined, selector: (shared: Observable) => O, timestampProvider?: TimestampProvider): OperatorFunction>; +export declare function publishReplay>(bufferSize: number | undefined, windowTime: number | undefined, selector: undefined, timestampProvider: TimestampProvider): OperatorFunction>; + export declare const queue: QueueScheduler; export declare const queueScheduler: QueueScheduler; @@ -354,6 +540,8 @@ export declare const queueScheduler: QueueScheduler; export declare function race(inputs: [...ObservableInputTuple]): Observable; export declare function race(...inputs: [...ObservableInputTuple]): Observable; +export declare function raceWith(...otherSources: [...ObservableInputTuple]): OperatorFunction; + export declare function range(start: number, count?: number): Observable; export declare function range(start: number, count: number | undefined, scheduler: SchedulerLike): Observable; @@ -361,11 +549,34 @@ export interface ReadableStreamLike { getReader(): ReadableStreamDefaultReaderLike; } +export declare function reduce(accumulator: (acc: A | V, value: V, index: number) => A): OperatorFunction; +export declare function reduce(accumulator: (acc: A, value: V, index: number) => A, seed: A): OperatorFunction; +export declare function reduce(accumulator: (acc: A | S, value: V, index: number) => A, seed: S): OperatorFunction; + +export declare function refCount(): MonoTypeOperatorFunction; + +export declare function repeat(count?: number): MonoTypeOperatorFunction; + +export declare function repeatWhen(notifier: (notifications: Observable) => Observable): MonoTypeOperatorFunction; + export declare class ReplaySubject extends Subject { constructor(_bufferSize?: number, _windowTime?: number, _timestampProvider?: TimestampProvider); next(value: T): void; } +export declare function retry(count?: number): MonoTypeOperatorFunction; +export declare function retry(config: RetryConfig): MonoTypeOperatorFunction; + +export declare function retryWhen(notifier: (errors: Observable) => Observable): MonoTypeOperatorFunction; + +export declare function sample(notifier: Observable): MonoTypeOperatorFunction; + +export declare function sampleTime(period: number, scheduler?: SchedulerLike): MonoTypeOperatorFunction; + +export declare function scan(accumulator: (acc: A | V, value: V, index: number) => A): OperatorFunction; +export declare function scan(accumulator: (acc: A, value: V, index: number) => A, seed: A): OperatorFunction; +export declare function scan(accumulator: (acc: A | S, value: V, index: number) => A, seed: S): OperatorFunction; + export declare function scheduled(input: ObservableInput, scheduler: SchedulerLike): Observable; export declare class Scheduler implements SchedulerLike { @@ -383,11 +594,37 @@ export interface SchedulerLike extends TimestampProvider { schedule(work: (this: SchedulerAction, state?: T) => void, delay?: number, state?: T): Subscription; } +export declare function sequenceEqual(compareTo: Observable, comparator?: (a: T, b: T) => boolean): OperatorFunction; + export interface SequenceError extends Error { } export declare const SequenceError: SequenceErrorCtor; +export declare function share(): MonoTypeOperatorFunction; +export declare function share(options: ShareConfig): MonoTypeOperatorFunction; + +export declare function shareReplay(config: ShareReplayConfig): MonoTypeOperatorFunction; +export declare function shareReplay(bufferSize?: number, windowTime?: number, scheduler?: SchedulerLike): MonoTypeOperatorFunction; + +export declare function single(predicate: BooleanConstructor): OperatorFunction>; +export declare function single(predicate?: (value: T, index: number, source: Observable) => boolean): MonoTypeOperatorFunction; + +export declare function skip(count: number): MonoTypeOperatorFunction; + +export declare function skipLast(skipCount: number): MonoTypeOperatorFunction; + +export declare function skipUntil(notifier: Observable): MonoTypeOperatorFunction; + +export declare function skipWhile(predicate: BooleanConstructor): OperatorFunction extends never ? never : T>; +export declare function skipWhile(predicate: (value: T, index: number) => true): OperatorFunction; +export declare function skipWhile(predicate: (value: T, index: number) => boolean): MonoTypeOperatorFunction; + +export declare function startWith(value: null): OperatorFunction; +export declare function startWith(value: undefined): OperatorFunction; +export declare function startWith(...valuesAndScheduler: [...A, SchedulerLike]): OperatorFunction>; +export declare function startWith(...values: A): OperatorFunction>; + export declare class Subject extends Observable implements SubscriptionLike { closed: boolean; hasError: boolean; @@ -414,6 +651,8 @@ export interface Subscribable { export declare type SubscribableOrPromise = Subscribable | Subscribable | PromiseLike | InteropObservable; +export declare function subscribeOn(scheduler: SchedulerLike, delay?: number): MonoTypeOperatorFunction; + export declare class Subscriber extends Subscription implements Observer { protected destination: Subscriber | Observer; protected isStopped: boolean; @@ -442,29 +681,78 @@ export interface SubscriptionLike extends Unsubscribable { unsubscribe(): void; } +export declare function switchAll>(): OperatorFunction>; + +export declare function switchMap>(project: (value: T, index: number) => O): OperatorFunction>; +export declare function switchMap>(project: (value: T, index: number) => O, resultSelector: undefined): OperatorFunction>; +export declare function switchMap>(project: (value: T, index: number) => O, resultSelector: (outerValue: T, innerValue: ObservedValueOf, outerIndex: number, innerIndex: number) => R): OperatorFunction; + +export declare function switchMapTo>(observable: O): OperatorFunction>; +export declare function switchMapTo>(observable: O, resultSelector: undefined): OperatorFunction>; +export declare function switchMapTo>(observable: O, resultSelector: (outerValue: T, innerValue: ObservedValueOf, outerIndex: number, innerIndex: number) => R): OperatorFunction; + +export declare function switchScan>(accumulator: (acc: R, value: T, index: number) => O, seed: R): OperatorFunction>; + export declare type Tail = ((...args: X) => any) extends (arg: any, ...rest: infer U) => any ? U : never; +export declare function take(count: number): MonoTypeOperatorFunction; + +export declare function takeLast(count: number): MonoTypeOperatorFunction; + +export declare function takeUntil(notifier: ObservableInput): MonoTypeOperatorFunction; + +export declare function takeWhile(predicate: BooleanConstructor): OperatorFunction extends never ? never : T>; +export declare function takeWhile(predicate: BooleanConstructor, inclusive: false): OperatorFunction extends never ? never : T>; +export declare function takeWhile(predicate: BooleanConstructor, inclusive: true): MonoTypeOperatorFunction; +export declare function takeWhile(predicate: (value: T, index: number) => value is S): OperatorFunction; +export declare function takeWhile(predicate: (value: T, index: number) => value is S, inclusive: false): OperatorFunction; +export declare function takeWhile(predicate: (value: T, index: number) => boolean, inclusive?: boolean): MonoTypeOperatorFunction; + +export declare function tap(observer?: Partial>): MonoTypeOperatorFunction; +export declare function tap(next: (value: T) => void): MonoTypeOperatorFunction; +export declare function tap(next?: ((value: T) => void) | null, error?: ((error: any) => void) | null, complete?: (() => void) | null): MonoTypeOperatorFunction; + export declare type TeardownLogic = Subscription | Unsubscribable | (() => void) | void; +export declare function throttle(durationSelector: (value: T) => ObservableInput, { leading, trailing }?: ThrottleConfig): MonoTypeOperatorFunction; + +export declare function throttleTime(duration: number, scheduler?: SchedulerLike, config?: import("./throttle").ThrottleConfig): MonoTypeOperatorFunction; + export declare function throwError(errorFactory: () => any): Observable; export declare function throwError(error: any): Observable; export declare function throwError(errorOrErrorFactory: any, scheduler: SchedulerLike): Observable; +export declare function throwIfEmpty(errorFactory?: () => any): MonoTypeOperatorFunction; + +export declare function timeInterval(scheduler?: SchedulerLike): OperatorFunction>; + export interface TimeInterval { interval: number; value: T; } +export declare function timeout, M = unknown>(config: TimeoutConfig & { + with: (info: TimeoutInfo) => O; +}): OperatorFunction>; +export declare function timeout(config: Omit, 'with'>): OperatorFunction; +export declare function timeout(first: Date, scheduler?: SchedulerLike): MonoTypeOperatorFunction; +export declare function timeout(each: number, scheduler?: SchedulerLike): MonoTypeOperatorFunction; + export interface TimeoutError extends Error { info: TimeoutInfo | null; } export declare const TimeoutError: TimeoutErrorCtor; +export declare function timeoutWith(dueBy: Date, switchTo: ObservableInput, scheduler?: SchedulerLike): OperatorFunction; +export declare function timeoutWith(waitFor: number, switchTo: ObservableInput, scheduler?: SchedulerLike): OperatorFunction; + export declare function timer(due: number | Date, scheduler?: SchedulerLike): Observable<0>; export declare function timer(startDue: number | Date, intervalDuration: number, scheduler?: SchedulerLike): Observable; export declare function timer(dueTime: number | Date, unused: undefined, scheduler?: SchedulerLike): Observable<0>; +export declare function timestamp(timestampProvider?: TimestampProvider): OperatorFunction>; + export interface Timestamp { timestamp: number; value: T; @@ -474,6 +762,8 @@ export interface TimestampProvider { now(): number; } +export declare function toArray(): OperatorFunction; + export declare type TruthyTypesOf = T extends Falsy ? never : T; export interface UnaryFunction { @@ -521,7 +811,29 @@ export declare class VirtualTimeScheduler extends AsyncScheduler { static frameTimeFactor: number; } +export declare function window(windowBoundaries: Observable): OperatorFunction>; + +export declare function windowCount(windowSize: number, startWindowEvery?: number): OperatorFunction>; + +export declare function windowTime(windowTimeSpan: number, scheduler?: SchedulerLike): OperatorFunction>; +export declare function windowTime(windowTimeSpan: number, windowCreationInterval: number, scheduler?: SchedulerLike): OperatorFunction>; +export declare function windowTime(windowTimeSpan: number, windowCreationInterval: number | null | void, maxWindowSize: number, scheduler?: SchedulerLike): OperatorFunction>; + +export declare function windowToggle(openings: ObservableInput, closingSelector: (openValue: O) => ObservableInput): OperatorFunction>; + +export declare function windowWhen(closingSelector: () => ObservableInput): OperatorFunction>; + +export declare function withLatestFrom(...inputs: [...ObservableInputTuple]): OperatorFunction; +export declare function withLatestFrom(...inputs: [...ObservableInputTuple, (...value: [T, ...O]) => R]): OperatorFunction; + export declare function zip(sources: [...ObservableInputTuple]): Observable; export declare function zip(sources: [...ObservableInputTuple], resultSelector: (...values: A) => R): Observable; export declare function zip(...sources: [...ObservableInputTuple]): Observable; export declare function zip(...sourcesAndResultSelector: [...ObservableInputTuple, (...values: A) => R]): Observable; + +export declare function zipAll(): OperatorFunction, T[]>; +export declare function zipAll(): OperatorFunction; +export declare function zipAll(project: (...values: T[]) => R): OperatorFunction, R>; +export declare function zipAll(project: (...values: Array) => R): OperatorFunction; + +export declare function zipWith(...otherInputs: [...ObservableInputTuple]): OperatorFunction>; From 6e2d39176c82931eddf47640a23ca360923ad06e Mon Sep 17 00:00:00 2001 From: Ben Lesh Date: Mon, 21 Jun 2021 11:47:41 -0500 Subject: [PATCH 3/3] chore: fix symbol type on symbol observable --- api_guard/dist/types/index.d.ts | 2 +- src/internal/symbol/observable.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/api_guard/dist/types/index.d.ts b/api_guard/dist/types/index.d.ts index 138caaa115..0a8d005684 100644 --- a/api_guard/dist/types/index.d.ts +++ b/api_guard/dist/types/index.d.ts @@ -411,7 +411,7 @@ export interface ObjectUnsubscribedError extends Error { export declare const ObjectUnsubscribedError: ObjectUnsubscribedErrorCtor; -export declare const observable: string | typeof Symbol.observable; +export declare const observable: string | symbol; export declare class Observable implements Subscribable { operator: Operator | undefined; diff --git a/src/internal/symbol/observable.ts b/src/internal/symbol/observable.ts index 35e7c27da6..ecd9f8897f 100644 --- a/src/internal/symbol/observable.ts +++ b/src/internal/symbol/observable.ts @@ -1,2 +1,2 @@ /** Symbol.observable or a string "@@observable". Used for interop */ -export const observable = (() => (typeof Symbol === 'function' && Symbol.observable) || '@@observable')(); +export const observable: string | symbol = (() => (typeof Symbol === 'function' && Symbol.observable) || '@@observable')();