message: refactor(audit): smaller impl
diff: -import { Operator } from '../Operator';
  +/** @prettier */
  import { Subscriber } from '../Subscriber';
  import { Observable } from '../Observable';
  -import { Subscription } from '../Subscription';
  -import { MonoTypeOperatorFunction, SubscribableOrPromise, TeardownLogic } from '../types';
  +import { MonoTypeOperatorFunction, SubscribableOrPromise } from '../types';
  import { lift } from '../util/lift';
  -import { SimpleOuterSubscriber, SimpleInnerSubscriber, innerSubscribe } from '../innerSubscribe';
  +import { from } from '../observable/from';
  +import { OperatorSubscriber } from './OperatorSubscriber';
  /**
  * Ignores source values for a duration determined by another Observable, then
  @@ -53,75 +53,34 @@ import { SimpleOuterSubscriber, SimpleInnerSubscriber, innerSubscribe } from '..
  * @name audit
  */
  export function audit<T>(durationSelector: (value: T) => SubscribableOrPromise<any>): MonoTypeOperatorFunction<T> {
  - return function auditOperatorFunction(source: Observable<T>) {
  - return lift(source, new AuditOperator(durationSelector));
  - };
  -}
  -
  -class AuditOperator<T> implements Operator<T, T> {
  - constructor(private durationSelector: (value: T) => SubscribableOrPromise<any>) {
  - }
  -
  - call(subscriber: Subscriber<T>, source: any): TeardownLogic {
  - return source.subscribe(new AuditSubscriber<T, T>(subscriber, this.durationSelector));
  - }
  -}
  -
  -/**
  - * We need this JSDoc comment for affecting ESDoc.
  - * @ignore
  - * @extends {Ignored}
  - */
  -class AuditSubscriber<T, R> extends SimpleOuterSubscriber<T, R> {
  -
  - private value: T | null = null;
  - private hasValue: boolean = false;
  - private throttled: Subscription | null = null;
  + return (source: Observable<T>) =>
  + lift(source, function (this: Subscriber<T>, source: Observable<T>) {
  + const subscriber = this;
  + let hasValue = false;
  + let lastValue: T | null = null;
  + let durationSubscriber: Subscriber<any> | null = null;
  - constructor(destination: Subscriber<T>,
  - private durationSelector: (value: T) => SubscribableOrPromise<any>) {
  - super(destination);
  - }
  -
  - protected _next(value: T): void {
  - this.value = value;
  - this.hasValue = true;
  - if (!this.throttled) {
  - let duration;
  - try {
  - const { durationSelector } = this;
  - duration = durationSelector(value);
  - } catch (err) {
  - return this.destination.error(err);
  - }
  - const innerSubscription = innerSubscribe(duration, new SimpleInnerSubscriber(this));
  - if (!innerSubscription || innerSubscription.closed) {
  - this.clearThrottle();
  - } else {
  - this.add(this.throttled = innerSubscription);
  - }
  - }
  - }
  -
  - clearThrottle() {
  - const { value, hasValue, throttled } = this;
  - if (throttled) {
  - this.remove(throttled);
  - this.throttled = null;
  - throttled.unsubscribe();
  - }
  + const endDuration = () => {
  + durationSubscriber?.unsubscribe();
  + durationSubscriber = null;
  if (hasValue) {
  - this.value = null;
  - this.hasValue = false;
  - this.destination.next(value);
  - }
  - }
  -
  - notifyNext(): void {
  - this.clearThrottle();
  + hasValue = false;
  + const value = lastValue!;
  + lastValue = null;
  + subscriber.next(value);
  }
  + };
  - notifyComplete(): void {
  - this.clearThrottle();
  + source.subscribe(
  + new OperatorSubscriber(subscriber, (value) => {
  + hasValue = true;
  + lastValue = value;
  + if (!durationSubscriber) {
  + from(durationSelector(value)).subscribe(
  + (durationSubscriber = new OperatorSubscriber(subscriber, endDuration, undefined, endDuration))
  + );
  }
  + })
  + );
  + });
  }
  