{"size": 3040, "ext": "js", "max_stars_repo_path": "vendor/RxJS/operator/audit.js", "max_stars_repo_name": "mgechev/closure-compiler-angular-bundling", "max_stars_repo_stars_event_min_datetime": "2016-08-22T21:16:00.000Z", "max_stars_repo_stars_event_max_datetime": "2018-11-27T20:09:49.000Z", "max_issues_repo_path": "vendor/RxJS/operator/audit.js", "max_issues_repo_name": "mgechev/closure-compiler-angular-bundling", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "vendor/RxJS/operator/audit.js", "max_forks_repo_name": "mgechev/closure-compiler-angular-bundling", "max_forks_repo_forks_event_min_datetime": "2016-08-22T21:16:03.000Z", "max_forks_repo_forks_event_max_datetime": "2020-05-15T11:49:31.000Z"}
{"max_stars_count": 9, "max_issues_count": null, "max_forks_count": 7, "avg_line_length": 27.3873873874, "max_line_length": 97, "alphanum_fraction": 0.5753289474}
goog.module('rxjs$operator$audit');
var tryCatch_1 = goog.require('rxjs$util$tryCatch');
var errorObject_1 = goog.require('rxjs$util$errorObject');
var OuterSubscriber_1 = goog.require('rxjs$OuterSubscriber');
var subscribeToResult_1 = goog.require('rxjs$util$subscribeToResult');
/**
 * @method audit
 * @owner Observable
 * @param {?} durationSelector
 * @return {?}
 */
function audit(durationSelector) {
    return this.lift(new AuditOperator(durationSelector));
}
exports.audit = audit;
class AuditOperator {
    /**
     * @param {?} durationSelector
     */
    constructor(durationSelector) {
        this.durationSelector = durationSelector;
    }
    /**
     * @param {?} subscriber
     * @param {?} source
     * @return {?}
     */
    call(subscriber, source) {
        return source._subscribe(new AuditSubscriber(subscriber, this.durationSelector));
    }
    static _tsickle_typeAnnotationsHelper() {
        /** @type {?} */
        AuditOperator.prototype.durationSelector;
    }
}
/**
 * We need this JSDoc comment for affecting ESDoc.
 * @ignore
 * @extends {Ignored}
 */
class AuditSubscriber extends OuterSubscriber_1.OuterSubscriber {
    /**
     * @param {?} destination
     * @param {?} durationSelector
     */
    constructor(destination, durationSelector) {
        super(destination);
        this.durationSelector = durationSelector;
        this.hasValue = false;
    }
    /**
     * @param {?} value
     * @return {?}
     */
    _next(value) {
        this.value = value;
        this.hasValue = true;
        if (!this.throttled) {
            const /** @type {?} */ duration = tryCatch_1.tryCatch(this.durationSelector)(value);
            if (duration === errorObject_1.errorObject) {
                this.destination.error(errorObject_1.errorObject.e);
            }
            else {
                this.add(this.throttled = subscribeToResult_1.subscribeToResult(this, duration));
            }
        }
    }
    /**
     * @return {?}
     */
    clearThrottle() {
        const { value, hasValue, throttled } = this;
        if (throttled) {
            this.remove(throttled);
            this.throttled = null;
            throttled.unsubscribe();
        }
        if (hasValue) {
            this.value = null;
            this.hasValue = false;
            this.destination.next(value);
        }
    }
    /**
     * @param {?} outerValue
     * @param {?} innerValue
     * @param {?} outerIndex
     * @param {?} innerIndex
     * @return {?}
     */
    notifyNext(outerValue, innerValue, outerIndex, innerIndex) {
        this.clearThrottle();
    }
    /**
     * @return {?}
     */
    notifyComplete() {
        this.clearThrottle();
    }
    static _tsickle_typeAnnotationsHelper() {
        /** @type {?} */
        AuditSubscriber.prototype.value;
        /** @type {?} */
        AuditSubscriber.prototype.hasValue;
        /** @type {?} */
        AuditSubscriber.prototype.throttled;
        /** @type {?} */
        AuditSubscriber.prototype.durationSelector;
    }
}
