1 line
16 KiB
JSON
1 line
16 KiB
JSON
{"ast":null,"code":"import { Subject } from '../Subject';\nimport { async } from '../scheduler/async';\nimport { Subscriber } from '../Subscriber';\nimport { isNumeric } from '../util/isNumeric';\nimport { isScheduler } from '../util/isScheduler';\nexport function windowTime(windowTimeSpan) {\n let scheduler = async;\n let windowCreationInterval = null;\n let maxWindowSize = Number.POSITIVE_INFINITY;\n\n if (isScheduler(arguments[3])) {\n scheduler = arguments[3];\n }\n\n if (isScheduler(arguments[2])) {\n scheduler = arguments[2];\n } else if (isNumeric(arguments[2])) {\n maxWindowSize = Number(arguments[2]);\n }\n\n if (isScheduler(arguments[1])) {\n scheduler = arguments[1];\n } else if (isNumeric(arguments[1])) {\n windowCreationInterval = Number(arguments[1]);\n }\n\n return function windowTimeOperatorFunction(source) {\n return source.lift(new WindowTimeOperator(windowTimeSpan, windowCreationInterval, maxWindowSize, scheduler));\n };\n}\n\nclass WindowTimeOperator {\n constructor(windowTimeSpan, windowCreationInterval, maxWindowSize, scheduler) {\n this.windowTimeSpan = windowTimeSpan;\n this.windowCreationInterval = windowCreationInterval;\n this.maxWindowSize = maxWindowSize;\n this.scheduler = scheduler;\n }\n\n call(subscriber, source) {\n return source.subscribe(new WindowTimeSubscriber(subscriber, this.windowTimeSpan, this.windowCreationInterval, this.maxWindowSize, this.scheduler));\n }\n\n}\n\nclass CountedSubject extends Subject {\n constructor() {\n super(...arguments);\n this._numberOfNextedValues = 0;\n }\n\n next(value) {\n this._numberOfNextedValues++;\n super.next(value);\n }\n\n get numberOfNextedValues() {\n return this._numberOfNextedValues;\n }\n\n}\n\nclass WindowTimeSubscriber extends Subscriber {\n constructor(destination, windowTimeSpan, windowCreationInterval, maxWindowSize, scheduler) {\n super(destination);\n this.destination = destination;\n this.windowTimeSpan = windowTimeSpan;\n this.windowCreationInterval = windowCreationInterval;\n this.maxWindowSize = maxWindowSize;\n this.scheduler = scheduler;\n this.windows = [];\n const window = this.openWindow();\n\n if (windowCreationInterval !== null && windowCreationInterval >= 0) {\n const closeState = {\n subscriber: this,\n window,\n context: null\n };\n const creationState = {\n windowTimeSpan,\n windowCreationInterval,\n subscriber: this,\n scheduler\n };\n this.add(scheduler.schedule(dispatchWindowClose, windowTimeSpan, closeState));\n this.add(scheduler.schedule(dispatchWindowCreation, windowCreationInterval, creationState));\n } else {\n const timeSpanOnlyState = {\n subscriber: this,\n window,\n windowTimeSpan\n };\n this.add(scheduler.schedule(dispatchWindowTimeSpanOnly, windowTimeSpan, timeSpanOnlyState));\n }\n }\n\n _next(value) {\n const windows = this.windows;\n const len = windows.length;\n\n for (let i = 0; i < len; i++) {\n const window = windows[i];\n\n if (!window.closed) {\n window.next(value);\n\n if (window.numberOfNextedValues >= this.maxWindowSize) {\n this.closeWindow(window);\n }\n }\n }\n }\n\n _error(err) {\n const windows = this.windows;\n\n while (windows.length > 0) {\n windows.shift().error(err);\n }\n\n this.destination.error(err);\n }\n\n _complete() {\n const windows = this.windows;\n\n while (windows.length > 0) {\n const window = windows.shift();\n\n if (!window.closed) {\n window.complete();\n }\n }\n\n this.destination.complete();\n }\n\n openWindow() {\n const window = new CountedSubject();\n this.windows.push(window);\n const destination = this.destination;\n destination.next(window);\n return window;\n }\n\n closeWindow(window) {\n window.complete();\n const windows = this.windows;\n windows.splice(windows.indexOf(window), 1);\n }\n\n}\n\nfunction dispatchWindowTimeSpanOnly(state) {\n const {\n subscriber,\n windowTimeSpan,\n window\n } = state;\n\n if (window) {\n subscriber.closeWindow(window);\n }\n\n state.window = subscriber.openWindow();\n this.schedule(state, windowTimeSpan);\n}\n\nfunction dispatchWindowCreation(state) {\n const {\n windowTimeSpan,\n subscriber,\n scheduler,\n windowCreationInterval\n } = state;\n const window = subscriber.openWindow();\n const action = this;\n let context = {\n action,\n subscription: null\n };\n const timeSpanState = {\n subscriber,\n window,\n context\n };\n context.subscription = scheduler.schedule(dispatchWindowClose, windowTimeSpan, timeSpanState);\n action.add(context.subscription);\n action.schedule(state, windowCreationInterval);\n}\n\nfunction dispatchWindowClose(state) {\n const {\n subscriber,\n window,\n context\n } = state;\n\n if (context && context.action && context.subscription) {\n context.action.remove(context.subscription);\n }\n\n subscriber.closeWindow(window);\n}","map":{"version":3,"names":["Subject","async","Subscriber","isNumeric","isScheduler","windowTime","windowTimeSpan","scheduler","windowCreationInterval","maxWindowSize","Number","POSITIVE_INFINITY","arguments","windowTimeOperatorFunction","source","lift","WindowTimeOperator","constructor","call","subscriber","subscribe","WindowTimeSubscriber","CountedSubject","_numberOfNextedValues","next","value","numberOfNextedValues","destination","windows","window","openWindow","closeState","context","creationState","add","schedule","dispatchWindowClose","dispatchWindowCreation","timeSpanOnlyState","dispatchWindowTimeSpanOnly","_next","len","length","i","closed","closeWindow","_error","err","shift","error","_complete","complete","push","splice","indexOf","state","action","subscription","timeSpanState","remove"],"sources":["D:/MobileDev/WRB/WrenchBoard2023a/node_modules/rxjs/_esm2015/internal/operators/windowTime.js"],"sourcesContent":["import { Subject } from '../Subject';\nimport { async } from '../scheduler/async';\nimport { Subscriber } from '../Subscriber';\nimport { isNumeric } from '../util/isNumeric';\nimport { isScheduler } from '../util/isScheduler';\nexport function windowTime(windowTimeSpan) {\n let scheduler = async;\n let windowCreationInterval = null;\n let maxWindowSize = Number.POSITIVE_INFINITY;\n if (isScheduler(arguments[3])) {\n scheduler = arguments[3];\n }\n if (isScheduler(arguments[2])) {\n scheduler = arguments[2];\n }\n else if (isNumeric(arguments[2])) {\n maxWindowSize = Number(arguments[2]);\n }\n if (isScheduler(arguments[1])) {\n scheduler = arguments[1];\n }\n else if (isNumeric(arguments[1])) {\n windowCreationInterval = Number(arguments[1]);\n }\n return function windowTimeOperatorFunction(source) {\n return source.lift(new WindowTimeOperator(windowTimeSpan, windowCreationInterval, maxWindowSize, scheduler));\n };\n}\nclass WindowTimeOperator {\n constructor(windowTimeSpan, windowCreationInterval, maxWindowSize, scheduler) {\n this.windowTimeSpan = windowTimeSpan;\n this.windowCreationInterval = windowCreationInterval;\n this.maxWindowSize = maxWindowSize;\n this.scheduler = scheduler;\n }\n call(subscriber, source) {\n return source.subscribe(new WindowTimeSubscriber(subscriber, this.windowTimeSpan, this.windowCreationInterval, this.maxWindowSize, this.scheduler));\n }\n}\nclass CountedSubject extends Subject {\n constructor() {\n super(...arguments);\n this._numberOfNextedValues = 0;\n }\n next(value) {\n this._numberOfNextedValues++;\n super.next(value);\n }\n get numberOfNextedValues() {\n return this._numberOfNextedValues;\n }\n}\nclass WindowTimeSubscriber extends Subscriber {\n constructor(destination, windowTimeSpan, windowCreationInterval, maxWindowSize, scheduler) {\n super(destination);\n this.destination = destination;\n this.windowTimeSpan = windowTimeSpan;\n this.windowCreationInterval = windowCreationInterval;\n this.maxWindowSize = maxWindowSize;\n this.scheduler = scheduler;\n this.windows = [];\n const window = this.openWindow();\n if (windowCreationInterval !== null && windowCreationInterval >= 0) {\n const closeState = { subscriber: this, window, context: null };\n const creationState = { windowTimeSpan, windowCreationInterval, subscriber: this, scheduler };\n this.add(scheduler.schedule(dispatchWindowClose, windowTimeSpan, closeState));\n this.add(scheduler.schedule(dispatchWindowCreation, windowCreationInterval, creationState));\n }\n else {\n const timeSpanOnlyState = { subscriber: this, window, windowTimeSpan };\n this.add(scheduler.schedule(dispatchWindowTimeSpanOnly, windowTimeSpan, timeSpanOnlyState));\n }\n }\n _next(value) {\n const windows = this.windows;\n const len = windows.length;\n for (let i = 0; i < len; i++) {\n const window = windows[i];\n if (!window.closed) {\n window.next(value);\n if (window.numberOfNextedValues >= this.maxWindowSize) {\n this.closeWindow(window);\n }\n }\n }\n }\n _error(err) {\n const windows = this.windows;\n while (windows.length > 0) {\n windows.shift().error(err);\n }\n this.destination.error(err);\n }\n _complete() {\n const windows = this.windows;\n while (windows.length > 0) {\n const window = windows.shift();\n if (!window.closed) {\n window.complete();\n }\n }\n this.destination.complete();\n }\n openWindow() {\n const window = new CountedSubject();\n this.windows.push(window);\n const destination = this.destination;\n destination.next(window);\n return window;\n }\n closeWindow(window) {\n window.complete();\n const windows = this.windows;\n windows.splice(windows.indexOf(window), 1);\n }\n}\nfunction dispatchWindowTimeSpanOnly(state) {\n const { subscriber, windowTimeSpan, window } = state;\n if (window) {\n subscriber.closeWindow(window);\n }\n state.window = subscriber.openWindow();\n this.schedule(state, windowTimeSpan);\n}\nfunction dispatchWindowCreation(state) {\n const { windowTimeSpan, subscriber, scheduler, windowCreationInterval } = state;\n const window = subscriber.openWindow();\n const action = this;\n let context = { action, subscription: null };\n const timeSpanState = { subscriber, window, context };\n context.subscription = scheduler.schedule(dispatchWindowClose, windowTimeSpan, timeSpanState);\n action.add(context.subscription);\n action.schedule(state, windowCreationInterval);\n}\nfunction dispatchWindowClose(state) {\n const { subscriber, window, context } = state;\n if (context && context.action && context.subscription) {\n context.action.remove(context.subscription);\n }\n subscriber.closeWindow(window);\n}\n"],"mappings":"AAAA,SAASA,OAAT,QAAwB,YAAxB;AACA,SAASC,KAAT,QAAsB,oBAAtB;AACA,SAASC,UAAT,QAA2B,eAA3B;AACA,SAASC,SAAT,QAA0B,mBAA1B;AACA,SAASC,WAAT,QAA4B,qBAA5B;AACA,OAAO,SAASC,UAAT,CAAoBC,cAApB,EAAoC;EACvC,IAAIC,SAAS,GAAGN,KAAhB;EACA,IAAIO,sBAAsB,GAAG,IAA7B;EACA,IAAIC,aAAa,GAAGC,MAAM,CAACC,iBAA3B;;EACA,IAAIP,WAAW,CAACQ,SAAS,CAAC,CAAD,CAAV,CAAf,EAA+B;IAC3BL,SAAS,GAAGK,SAAS,CAAC,CAAD,CAArB;EACH;;EACD,IAAIR,WAAW,CAACQ,SAAS,CAAC,CAAD,CAAV,CAAf,EAA+B;IAC3BL,SAAS,GAAGK,SAAS,CAAC,CAAD,CAArB;EACH,CAFD,MAGK,IAAIT,SAAS,CAACS,SAAS,CAAC,CAAD,CAAV,CAAb,EAA6B;IAC9BH,aAAa,GAAGC,MAAM,CAACE,SAAS,CAAC,CAAD,CAAV,CAAtB;EACH;;EACD,IAAIR,WAAW,CAACQ,SA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