You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

1 lines
1.8 KiB

{"ast":null,"code":"import { SimpleOuterSubscriber, innerSubscribe, SimpleInnerSubscriber } from '../innerSubscribe';\nexport function audit(durationSelector) {\n return function auditOperatorFunction(source) {\n return source.lift(new AuditOperator(durationSelector));\n };\n}\n\nclass AuditOperator {\n constructor(durationSelector) {\n this.durationSelector = durationSelector;\n }\n\n call(subscriber, source) {\n return source.subscribe(new AuditSubscriber(subscriber, this.durationSelector));\n }\n\n}\n\nclass AuditSubscriber extends SimpleOuterSubscriber {\n constructor(destination, durationSelector) {\n super(destination);\n this.durationSelector = durationSelector;\n this.hasValue = false;\n }\n\n _next(value) {\n this.value = value;\n this.hasValue = true;\n\n if (!this.throttled) {\n let duration;\n\n try {\n const {\n durationSelector\n } = this;\n duration = durationSelector(value);\n } catch (err) {\n return this.destination.error(err);\n }\n\n const innerSubscription = innerSubscribe(duration, new SimpleInnerSubscriber(this));\n\n if (!innerSubscription || innerSubscription.closed) {\n this.clearThrottle();\n } else {\n this.add(this.throttled = innerSubscription);\n }\n }\n }\n\n clearThrottle() {\n const {\n value,\n hasValue,\n throttled\n } = this;\n\n if (throttled) {\n this.remove(throttled);\n this.throttled = undefined;\n throttled.unsubscribe();\n }\n\n if (hasValue) {\n this.value = undefined;\n this.hasValue = false;\n this.destination.next(value);\n }\n }\n\n notifyNext() {\n this.clearThrottle();\n }\n\n notifyComplete() {\n this.clearThrottle();\n }\n\n} //# sourceMappingURL=audit.js.map","map":null,"metadata":{},"sourceType":"module"}