feat: initial commit

This commit is contained in:
Carlos
2024-08-12 22:57:35 -04:00
commit 6f68ae8259
13140 changed files with 1104801 additions and 0 deletions

20
node_modules/rxjs/internal/testing/ColdObservable.d.ts generated vendored Normal file
View File

@ -0,0 +1,20 @@
import { Observable } from '../Observable';
import { Scheduler } from '../Scheduler';
import { TestMessage } from './TestMessage';
import { SubscriptionLog } from './SubscriptionLog';
import { SubscriptionLoggable } from './SubscriptionLoggable';
import { Subscriber } from '../Subscriber';
/**
* We need this JSDoc comment for affecting ESDoc.
* @ignore
* @extends {Ignored}
*/
export declare class ColdObservable<T> extends Observable<T> implements SubscriptionLoggable {
messages: TestMessage[];
subscriptions: SubscriptionLog[];
scheduler: Scheduler;
logSubscribedFrame: () => number;
logUnsubscribedFrame: (index: number) => void;
constructor(messages: TestMessage[], scheduler: Scheduler);
scheduleMessages(subscriber: Subscriber<any>): void;
}

52
node_modules/rxjs/internal/testing/ColdObservable.js generated vendored Normal file
View File

@ -0,0 +1,52 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
}
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var Observable_1 = require("../Observable");
var Subscription_1 = require("../Subscription");
var SubscriptionLoggable_1 = require("./SubscriptionLoggable");
var applyMixins_1 = require("../util/applyMixins");
var ColdObservable = (function (_super) {
__extends(ColdObservable, _super);
function ColdObservable(messages, scheduler) {
var _this = _super.call(this, function (subscriber) {
var observable = this;
var index = observable.logSubscribedFrame();
var subscription = new Subscription_1.Subscription();
subscription.add(new Subscription_1.Subscription(function () {
observable.logUnsubscribedFrame(index);
}));
observable.scheduleMessages(subscriber);
return subscription;
}) || this;
_this.messages = messages;
_this.subscriptions = [];
_this.scheduler = scheduler;
return _this;
}
ColdObservable.prototype.scheduleMessages = function (subscriber) {
var messagesLength = this.messages.length;
for (var i = 0; i < messagesLength; i++) {
var message = this.messages[i];
subscriber.add(this.scheduler.schedule(function (_a) {
var message = _a.message, subscriber = _a.subscriber;
message.notification.observe(subscriber);
}, message.frame, { message: message, subscriber: subscriber }));
}
};
return ColdObservable;
}(Observable_1.Observable));
exports.ColdObservable = ColdObservable;
applyMixins_1.applyMixins(ColdObservable, [SubscriptionLoggable_1.SubscriptionLoggable]);
//# sourceMappingURL=ColdObservable.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"ColdObservable.js","sources":["../../src/internal/testing/ColdObservable.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,4CAA2C;AAC3C,gDAA+C;AAI/C,+DAA8D;AAC9D,mDAAkD;AAQlD;IAAuC,kCAAa;IAMlD,wBAAmB,QAAuB,EAC9B,SAAoB;QADhC,YAEE,kBAAM,UAA+B,UAA2B;YAC9D,IAAM,UAAU,GAAsB,IAAW,CAAC;YAClD,IAAM,KAAK,GAAG,UAAU,CAAC,kBAAkB,EAAE,CAAC;YAC9C,IAAM,YAAY,GAAG,IAAI,2BAAY,EAAE,CAAC;YACxC,YAAY,CAAC,GAAG,CAAC,IAAI,2BAAY,CAAC;gBAChC,UAAU,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC;YACzC,CAAC,CAAC,CAAC,CAAC;YACJ,UAAU,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;YACxC,OAAO,YAAY,CAAC;QACtB,CAAC,CAAC,SAEH;QAbkB,cAAQ,GAAR,QAAQ,CAAe;QALnC,mBAAa,GAAsB,EAAE,CAAC;QAiB3C,KAAI,CAAC,SAAS,GAAG,SAAS,CAAC;;IAC7B,CAAC;IAED,yCAAgB,GAAhB,UAAiB,UAA2B;QAC1C,IAAM,cAAc,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;QAC5C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,cAAc,EAAE,CAAC,EAAE,EAAE;YACvC,IAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;YACjC,UAAU,CAAC,GAAG,CACZ,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,UAAC,EAAuB;oBAArB,oBAAO,EAAE,0BAAU;gBAAS,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;YAAC,CAAC,EAChG,OAAO,CAAC,KAAK,EACb,EAAE,OAAO,SAAA,EAAE,UAAU,YAAA,EAAE,CAAC,CAC3B,CAAC;SACH;IACH,CAAC;IACH,qBAAC;AAAD,CAAC,AAhCD,CAAuC,uBAAU,GAgChD;AAhCY,wCAAc;AAiC3B,yBAAW,CAAC,cAAc,EAAE,CAAC,2CAAoB,CAAC,CAAC,CAAC"}

23
node_modules/rxjs/internal/testing/HotObservable.d.ts generated vendored Normal file
View File

@ -0,0 +1,23 @@
import { Subject } from '../Subject';
import { Subscriber } from '../Subscriber';
import { Subscription } from '../Subscription';
import { Scheduler } from '../Scheduler';
import { TestMessage } from './TestMessage';
import { SubscriptionLog } from './SubscriptionLog';
import { SubscriptionLoggable } from './SubscriptionLoggable';
/**
* We need this JSDoc comment for affecting ESDoc.
* @ignore
* @extends {Ignored}
*/
export declare class HotObservable<T> extends Subject<T> implements SubscriptionLoggable {
messages: TestMessage[];
subscriptions: SubscriptionLog[];
scheduler: Scheduler;
logSubscribedFrame: () => number;
logUnsubscribedFrame: (index: number) => void;
constructor(messages: TestMessage[], scheduler: Scheduler);
/** @deprecated This is an internal implementation detail, do not use. */
_subscribe(subscriber: Subscriber<any>): Subscription;
setup(): void;
}

53
node_modules/rxjs/internal/testing/HotObservable.js generated vendored Normal file
View File

@ -0,0 +1,53 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
}
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var Subject_1 = require("../Subject");
var Subscription_1 = require("../Subscription");
var SubscriptionLoggable_1 = require("./SubscriptionLoggable");
var applyMixins_1 = require("../util/applyMixins");
var HotObservable = (function (_super) {
__extends(HotObservable, _super);
function HotObservable(messages, scheduler) {
var _this = _super.call(this) || this;
_this.messages = messages;
_this.subscriptions = [];
_this.scheduler = scheduler;
return _this;
}
HotObservable.prototype._subscribe = function (subscriber) {
var subject = this;
var index = subject.logSubscribedFrame();
var subscription = new Subscription_1.Subscription();
subscription.add(new Subscription_1.Subscription(function () {
subject.logUnsubscribedFrame(index);
}));
subscription.add(_super.prototype._subscribe.call(this, subscriber));
return subscription;
};
HotObservable.prototype.setup = function () {
var subject = this;
var messagesLength = subject.messages.length;
for (var i = 0; i < messagesLength; i++) {
(function () {
var message = subject.messages[i];
subject.scheduler.schedule(function () { message.notification.observe(subject); }, message.frame);
})();
}
};
return HotObservable;
}(Subject_1.Subject));
exports.HotObservable = HotObservable;
applyMixins_1.applyMixins(HotObservable, [SubscriptionLoggable_1.SubscriptionLoggable]);
//# sourceMappingURL=HotObservable.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"HotObservable.js","sources":["../../src/internal/testing/HotObservable.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,sCAAqC;AAErC,gDAA+C;AAI/C,+DAA8D;AAC9D,mDAAkD;AAOlD;IAAsC,iCAAU;IAM9C,uBAAmB,QAAuB,EAC9B,SAAoB;QADhC,YAEE,iBAAO,SAER;QAJkB,cAAQ,GAAR,QAAQ,CAAe;QALnC,mBAAa,GAAsB,EAAE,CAAC;QAQ3C,KAAI,CAAC,SAAS,GAAG,SAAS,CAAC;;IAC7B,CAAC;IAGD,kCAAU,GAAV,UAAW,UAA2B;QACpC,IAAM,OAAO,GAAqB,IAAI,CAAC;QACvC,IAAM,KAAK,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC;QAC3C,IAAM,YAAY,GAAG,IAAI,2BAAY,EAAE,CAAC;QACxC,YAAY,CAAC,GAAG,CAAC,IAAI,2BAAY,CAAC;YAChC,OAAO,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC;QACtC,CAAC,CAAC,CAAC,CAAC;QACJ,YAAY,CAAC,GAAG,CAAC,iBAAM,UAAU,YAAC,UAAU,CAAC,CAAC,CAAC;QAC/C,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,6BAAK,GAAL;QACE,IAAM,OAAO,GAAG,IAAI,CAAC;QACrB,IAAM,cAAc,GAAG,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC;QAE/C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,cAAc,EAAE,CAAC,EAAE,EAAE;YACvC,CAAC;gBACC,IAAI,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;gBAElC,OAAO,CAAC,SAAS,CAAC,QAAQ,CACxB,cAAQ,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAChD,OAAO,CAAC,KAAK,CACd,CAAC;YACJ,CAAC,CAAC,EAAE,CAAC;SACN;IACH,CAAC;IACH,oBAAC;AAAD,CAAC,AAvCD,CAAsC,iBAAO,GAuC5C;AAvCY,sCAAa;AAwC1B,yBAAW,CAAC,aAAa,EAAE,CAAC,2CAAoB,CAAC,CAAC,CAAC"}

View File

@ -0,0 +1,5 @@
export declare class SubscriptionLog {
subscribedFrame: number;
unsubscribedFrame: number;
constructor(subscribedFrame: number, unsubscribedFrame?: number);
}

12
node_modules/rxjs/internal/testing/SubscriptionLog.js generated vendored Normal file
View File

@ -0,0 +1,12 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var SubscriptionLog = (function () {
function SubscriptionLog(subscribedFrame, unsubscribedFrame) {
if (unsubscribedFrame === void 0) { unsubscribedFrame = Number.POSITIVE_INFINITY; }
this.subscribedFrame = subscribedFrame;
this.unsubscribedFrame = unsubscribedFrame;
}
return SubscriptionLog;
}());
exports.SubscriptionLog = SubscriptionLog;
//# sourceMappingURL=SubscriptionLog.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"SubscriptionLog.js","sources":["../../src/internal/testing/SubscriptionLog.ts"],"names":[],"mappings":";;AAAA;IACE,yBAAmB,eAAuB,EACvB,iBAAoD;QAApD,kCAAA,EAAA,oBAA4B,MAAM,CAAC,iBAAiB;QADpD,oBAAe,GAAf,eAAe,CAAQ;QACvB,sBAAiB,GAAjB,iBAAiB,CAAmC;IACvE,CAAC;IACH,sBAAC;AAAD,CAAC,AAJD,IAIC;AAJY,0CAAe"}

View File

@ -0,0 +1,8 @@
import { Scheduler } from '../Scheduler';
import { SubscriptionLog } from './SubscriptionLog';
export declare class SubscriptionLoggable {
subscriptions: SubscriptionLog[];
scheduler: Scheduler;
logSubscribedFrame(): number;
logUnsubscribedFrame(index: number): void;
}

View File

@ -0,0 +1,20 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var SubscriptionLog_1 = require("./SubscriptionLog");
var SubscriptionLoggable = (function () {
function SubscriptionLoggable() {
this.subscriptions = [];
}
SubscriptionLoggable.prototype.logSubscribedFrame = function () {
this.subscriptions.push(new SubscriptionLog_1.SubscriptionLog(this.scheduler.now()));
return this.subscriptions.length - 1;
};
SubscriptionLoggable.prototype.logUnsubscribedFrame = function (index) {
var subscriptionLogs = this.subscriptions;
var oldSubscriptionLog = subscriptionLogs[index];
subscriptionLogs[index] = new SubscriptionLog_1.SubscriptionLog(oldSubscriptionLog.subscribedFrame, this.scheduler.now());
};
return SubscriptionLoggable;
}());
exports.SubscriptionLoggable = SubscriptionLoggable;
//# sourceMappingURL=SubscriptionLoggable.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"SubscriptionLoggable.js","sources":["../../src/internal/testing/SubscriptionLoggable.ts"],"names":[],"mappings":";;AACA,qDAAoD;AAEpD;IAAA;QACS,kBAAa,GAAsB,EAAE,CAAC;IAgB/C,CAAC;IAbC,iDAAkB,GAAlB;QACE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,iCAAe,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;QACnE,OAAO,IAAI,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC;IACvC,CAAC;IAED,mDAAoB,GAApB,UAAqB,KAAa;QAChC,IAAM,gBAAgB,GAAG,IAAI,CAAC,aAAa,CAAC;QAC5C,IAAM,kBAAkB,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAC;QACnD,gBAAgB,CAAC,KAAK,CAAC,GAAG,IAAI,iCAAe,CAC3C,kBAAkB,CAAC,eAAe,EAClC,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,CACrB,CAAC;IACJ,CAAC;IACH,2BAAC;AAAD,CAAC,AAjBD,IAiBC;AAjBY,oDAAoB"}

6
node_modules/rxjs/internal/testing/TestMessage.d.ts generated vendored Normal file
View File

@ -0,0 +1,6 @@
import { Notification } from '../Notification';
export interface TestMessage {
frame: number;
notification: Notification<any>;
isGhost?: boolean;
}

3
node_modules/rxjs/internal/testing/TestMessage.js generated vendored Normal file
View File

@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=TestMessage.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"TestMessage.js","sources":["../../src/internal/testing/TestMessage.ts"],"names":[],"mappings":""}

53
node_modules/rxjs/internal/testing/TestScheduler.d.ts generated vendored Normal file
View File

@ -0,0 +1,53 @@
import { Observable } from '../Observable';
import { ColdObservable } from './ColdObservable';
import { HotObservable } from './HotObservable';
import { TestMessage } from './TestMessage';
import { SubscriptionLog } from './SubscriptionLog';
import { VirtualTimeScheduler } from '../scheduler/VirtualTimeScheduler';
export interface RunHelpers {
cold: typeof TestScheduler.prototype.createColdObservable;
hot: typeof TestScheduler.prototype.createHotObservable;
flush: typeof TestScheduler.prototype.flush;
expectObservable: typeof TestScheduler.prototype.expectObservable;
expectSubscriptions: typeof TestScheduler.prototype.expectSubscriptions;
}
export declare type observableToBeFn = (marbles: string, values?: any, errorValue?: any) => void;
export declare type subscriptionLogsToBeFn = (marbles: string | string[]) => void;
export declare class TestScheduler extends VirtualTimeScheduler {
assertDeepEqual: (actual: any, expected: any) => boolean | void;
readonly hotObservables: HotObservable<any>[];
readonly coldObservables: ColdObservable<any>[];
private flushTests;
private runMode;
constructor(assertDeepEqual: (actual: any, expected: any) => boolean | void);
createTime(marbles: string): number;
/**
* @param marbles A diagram in the marble DSL. Letters map to keys in `values` if provided.
* @param values Values to use for the letters in `marbles`. If ommitted, the letters themselves are used.
* @param error The error to use for the `#` marble (if present).
*/
createColdObservable<T = string>(marbles: string, values?: {
[marble: string]: T;
}, error?: any): ColdObservable<T>;
/**
* @param marbles A diagram in the marble DSL. Letters map to keys in `values` if provided.
* @param values Values to use for the letters in `marbles`. If ommitted, the letters themselves are used.
* @param error The error to use for the `#` marble (if present).
*/
createHotObservable<T = string>(marbles: string, values?: {
[marble: string]: T;
}, error?: any): HotObservable<T>;
private materializeInnerObservable;
expectObservable(observable: Observable<any>, subscriptionMarbles?: string): ({
toBe: observableToBeFn;
});
expectSubscriptions(actualSubscriptionLogs: SubscriptionLog[]): ({
toBe: subscriptionLogsToBeFn;
});
flush(): void;
/** @nocollapse */
static parseMarblesAsSubscriptions(marbles: string, runMode?: boolean): SubscriptionLog;
/** @nocollapse */
static parseMarbles(marbles: string, values?: any, errorValue?: any, materializeInnerObservables?: boolean, runMode?: boolean): TestMessage[];
run<T>(callback: (helpers: RunHelpers) => T): T;
}

364
node_modules/rxjs/internal/testing/TestScheduler.js generated vendored Normal file
View File

@ -0,0 +1,364 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
}
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var Observable_1 = require("../Observable");
var Notification_1 = require("../Notification");
var ColdObservable_1 = require("./ColdObservable");
var HotObservable_1 = require("./HotObservable");
var SubscriptionLog_1 = require("./SubscriptionLog");
var VirtualTimeScheduler_1 = require("../scheduler/VirtualTimeScheduler");
var AsyncScheduler_1 = require("../scheduler/AsyncScheduler");
var defaultMaxFrame = 750;
var TestScheduler = (function (_super) {
__extends(TestScheduler, _super);
function TestScheduler(assertDeepEqual) {
var _this = _super.call(this, VirtualTimeScheduler_1.VirtualAction, defaultMaxFrame) || this;
_this.assertDeepEqual = assertDeepEqual;
_this.hotObservables = [];
_this.coldObservables = [];
_this.flushTests = [];
_this.runMode = false;
return _this;
}
TestScheduler.prototype.createTime = function (marbles) {
var indexOf = marbles.indexOf('|');
if (indexOf === -1) {
throw new Error('marble diagram for time should have a completion marker "|"');
}
return indexOf * TestScheduler.frameTimeFactor;
};
TestScheduler.prototype.createColdObservable = function (marbles, values, error) {
if (marbles.indexOf('^') !== -1) {
throw new Error('cold observable cannot have subscription offset "^"');
}
if (marbles.indexOf('!') !== -1) {
throw new Error('cold observable cannot have unsubscription marker "!"');
}
var messages = TestScheduler.parseMarbles(marbles, values, error, undefined, this.runMode);
var cold = new ColdObservable_1.ColdObservable(messages, this);
this.coldObservables.push(cold);
return cold;
};
TestScheduler.prototype.createHotObservable = function (marbles, values, error) {
if (marbles.indexOf('!') !== -1) {
throw new Error('hot observable cannot have unsubscription marker "!"');
}
var messages = TestScheduler.parseMarbles(marbles, values, error, undefined, this.runMode);
var subject = new HotObservable_1.HotObservable(messages, this);
this.hotObservables.push(subject);
return subject;
};
TestScheduler.prototype.materializeInnerObservable = function (observable, outerFrame) {
var _this = this;
var messages = [];
observable.subscribe(function (value) {
messages.push({ frame: _this.frame - outerFrame, notification: Notification_1.Notification.createNext(value) });
}, function (err) {
messages.push({ frame: _this.frame - outerFrame, notification: Notification_1.Notification.createError(err) });
}, function () {
messages.push({ frame: _this.frame - outerFrame, notification: Notification_1.Notification.createComplete() });
});
return messages;
};
TestScheduler.prototype.expectObservable = function (observable, subscriptionMarbles) {
var _this = this;
if (subscriptionMarbles === void 0) { subscriptionMarbles = null; }
var actual = [];
var flushTest = { actual: actual, ready: false };
var subscriptionParsed = TestScheduler.parseMarblesAsSubscriptions(subscriptionMarbles, this.runMode);
var subscriptionFrame = subscriptionParsed.subscribedFrame === Number.POSITIVE_INFINITY ?
0 : subscriptionParsed.subscribedFrame;
var unsubscriptionFrame = subscriptionParsed.unsubscribedFrame;
var subscription;
this.schedule(function () {
subscription = observable.subscribe(function (x) {
var value = x;
if (x instanceof Observable_1.Observable) {
value = _this.materializeInnerObservable(value, _this.frame);
}
actual.push({ frame: _this.frame, notification: Notification_1.Notification.createNext(value) });
}, function (err) {
actual.push({ frame: _this.frame, notification: Notification_1.Notification.createError(err) });
}, function () {
actual.push({ frame: _this.frame, notification: Notification_1.Notification.createComplete() });
});
}, subscriptionFrame);
if (unsubscriptionFrame !== Number.POSITIVE_INFINITY) {
this.schedule(function () { return subscription.unsubscribe(); }, unsubscriptionFrame);
}
this.flushTests.push(flushTest);
var runMode = this.runMode;
return {
toBe: function (marbles, values, errorValue) {
flushTest.ready = true;
flushTest.expected = TestScheduler.parseMarbles(marbles, values, errorValue, true, runMode);
}
};
};
TestScheduler.prototype.expectSubscriptions = function (actualSubscriptionLogs) {
var flushTest = { actual: actualSubscriptionLogs, ready: false };
this.flushTests.push(flushTest);
var runMode = this.runMode;
return {
toBe: function (marbles) {
var marblesArray = (typeof marbles === 'string') ? [marbles] : marbles;
flushTest.ready = true;
flushTest.expected = marblesArray.map(function (marbles) {
return TestScheduler.parseMarblesAsSubscriptions(marbles, runMode);
});
}
};
};
TestScheduler.prototype.flush = function () {
var _this = this;
var hotObservables = this.hotObservables;
while (hotObservables.length > 0) {
hotObservables.shift().setup();
}
_super.prototype.flush.call(this);
this.flushTests = this.flushTests.filter(function (test) {
if (test.ready) {
_this.assertDeepEqual(test.actual, test.expected);
return false;
}
return true;
});
};
TestScheduler.parseMarblesAsSubscriptions = function (marbles, runMode) {
var _this = this;
if (runMode === void 0) { runMode = false; }
if (typeof marbles !== 'string') {
return new SubscriptionLog_1.SubscriptionLog(Number.POSITIVE_INFINITY);
}
var len = marbles.length;
var groupStart = -1;
var subscriptionFrame = Number.POSITIVE_INFINITY;
var unsubscriptionFrame = Number.POSITIVE_INFINITY;
var frame = 0;
var _loop_1 = function (i) {
var nextFrame = frame;
var advanceFrameBy = function (count) {
nextFrame += count * _this.frameTimeFactor;
};
var c = marbles[i];
switch (c) {
case ' ':
if (!runMode) {
advanceFrameBy(1);
}
break;
case '-':
advanceFrameBy(1);
break;
case '(':
groupStart = frame;
advanceFrameBy(1);
break;
case ')':
groupStart = -1;
advanceFrameBy(1);
break;
case '^':
if (subscriptionFrame !== Number.POSITIVE_INFINITY) {
throw new Error('found a second subscription point \'^\' in a ' +
'subscription marble diagram. There can only be one.');
}
subscriptionFrame = groupStart > -1 ? groupStart : frame;
advanceFrameBy(1);
break;
case '!':
if (unsubscriptionFrame !== Number.POSITIVE_INFINITY) {
throw new Error('found a second subscription point \'^\' in a ' +
'subscription marble diagram. There can only be one.');
}
unsubscriptionFrame = groupStart > -1 ? groupStart : frame;
break;
default:
if (runMode && c.match(/^[0-9]$/)) {
if (i === 0 || marbles[i - 1] === ' ') {
var buffer = marbles.slice(i);
var match = buffer.match(/^([0-9]+(?:\.[0-9]+)?)(ms|s|m) /);
if (match) {
i += match[0].length - 1;
var duration = parseFloat(match[1]);
var unit = match[2];
var durationInMs = void 0;
switch (unit) {
case 'ms':
durationInMs = duration;
break;
case 's':
durationInMs = duration * 1000;
break;
case 'm':
durationInMs = duration * 1000 * 60;
break;
default:
break;
}
advanceFrameBy(durationInMs / this_1.frameTimeFactor);
break;
}
}
}
throw new Error('there can only be \'^\' and \'!\' markers in a ' +
'subscription marble diagram. Found instead \'' + c + '\'.');
}
frame = nextFrame;
out_i_1 = i;
};
var this_1 = this, out_i_1;
for (var i = 0; i < len; i++) {
_loop_1(i);
i = out_i_1;
}
if (unsubscriptionFrame < 0) {
return new SubscriptionLog_1.SubscriptionLog(subscriptionFrame);
}
else {
return new SubscriptionLog_1.SubscriptionLog(subscriptionFrame, unsubscriptionFrame);
}
};
TestScheduler.parseMarbles = function (marbles, values, errorValue, materializeInnerObservables, runMode) {
var _this = this;
if (materializeInnerObservables === void 0) { materializeInnerObservables = false; }
if (runMode === void 0) { runMode = false; }
if (marbles.indexOf('!') !== -1) {
throw new Error('conventional marble diagrams cannot have the ' +
'unsubscription marker "!"');
}
var len = marbles.length;
var testMessages = [];
var subIndex = runMode ? marbles.replace(/^[ ]+/, '').indexOf('^') : marbles.indexOf('^');
var frame = subIndex === -1 ? 0 : (subIndex * -this.frameTimeFactor);
var getValue = typeof values !== 'object' ?
function (x) { return x; } :
function (x) {
if (materializeInnerObservables && values[x] instanceof ColdObservable_1.ColdObservable) {
return values[x].messages;
}
return values[x];
};
var groupStart = -1;
var _loop_2 = function (i) {
var nextFrame = frame;
var advanceFrameBy = function (count) {
nextFrame += count * _this.frameTimeFactor;
};
var notification = void 0;
var c = marbles[i];
switch (c) {
case ' ':
if (!runMode) {
advanceFrameBy(1);
}
break;
case '-':
advanceFrameBy(1);
break;
case '(':
groupStart = frame;
advanceFrameBy(1);
break;
case ')':
groupStart = -1;
advanceFrameBy(1);
break;
case '|':
notification = Notification_1.Notification.createComplete();
advanceFrameBy(1);
break;
case '^':
advanceFrameBy(1);
break;
case '#':
notification = Notification_1.Notification.createError(errorValue || 'error');
advanceFrameBy(1);
break;
default:
if (runMode && c.match(/^[0-9]$/)) {
if (i === 0 || marbles[i - 1] === ' ') {
var buffer = marbles.slice(i);
var match = buffer.match(/^([0-9]+(?:\.[0-9]+)?)(ms|s|m) /);
if (match) {
i += match[0].length - 1;
var duration = parseFloat(match[1]);
var unit = match[2];
var durationInMs = void 0;
switch (unit) {
case 'ms':
durationInMs = duration;
break;
case 's':
durationInMs = duration * 1000;
break;
case 'm':
durationInMs = duration * 1000 * 60;
break;
default:
break;
}
advanceFrameBy(durationInMs / this_2.frameTimeFactor);
break;
}
}
}
notification = Notification_1.Notification.createNext(getValue(c));
advanceFrameBy(1);
break;
}
if (notification) {
testMessages.push({ frame: groupStart > -1 ? groupStart : frame, notification: notification });
}
frame = nextFrame;
out_i_2 = i;
};
var this_2 = this, out_i_2;
for (var i = 0; i < len; i++) {
_loop_2(i);
i = out_i_2;
}
return testMessages;
};
TestScheduler.prototype.run = function (callback) {
var prevFrameTimeFactor = TestScheduler.frameTimeFactor;
var prevMaxFrames = this.maxFrames;
TestScheduler.frameTimeFactor = 1;
this.maxFrames = Number.POSITIVE_INFINITY;
this.runMode = true;
AsyncScheduler_1.AsyncScheduler.delegate = this;
var helpers = {
cold: this.createColdObservable.bind(this),
hot: this.createHotObservable.bind(this),
flush: this.flush.bind(this),
expectObservable: this.expectObservable.bind(this),
expectSubscriptions: this.expectSubscriptions.bind(this),
};
try {
var ret = callback(helpers);
this.flush();
return ret;
}
finally {
TestScheduler.frameTimeFactor = prevFrameTimeFactor;
this.maxFrames = prevMaxFrames;
this.runMode = false;
AsyncScheduler_1.AsyncScheduler.delegate = undefined;
}
};
return TestScheduler;
}(VirtualTimeScheduler_1.VirtualTimeScheduler));
exports.TestScheduler = TestScheduler;
//# sourceMappingURL=TestScheduler.js.map

File diff suppressed because one or more lines are too long