UNPKG

@reactivex/rxjs

Version:

Reactive Extensions for modern JavaScript

1,328 lines (1,327 loc) 123 kB
{ "type": "Program", "body": [ { "type": "ImportDeclaration", "specifiers": [ { "type": "ImportSpecifier", "local": { "type": "Identifier", "name": "Observable", "range": [ 9, 19 ], "loc": { "start": { "line": 1, "column": 9 }, "end": { "line": 1, "column": 19 } } }, "imported": { "type": "Identifier", "name": "Observable", "range": [ 9, 19 ], "loc": { "start": { "line": 1, "column": 9 }, "end": { "line": 1, "column": 19 } } }, "range": [ 9, 19 ], "loc": { "start": { "line": 1, "column": 9 }, "end": { "line": 1, "column": 19 } } } ], "source": { "type": "Literal", "value": "../Observable", "raw": "'../Observable'", "range": [ 27, 42 ], "loc": { "start": { "line": 1, "column": 27 }, "end": { "line": 1, "column": 42 } } }, "range": [ 0, 43 ], "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 1, "column": 43 } } }, { "type": "ImportDeclaration", "specifiers": [ { "type": "ImportSpecifier", "local": { "type": "Identifier", "name": "subscribeToResult", "range": [ 53, 70 ], "loc": { "start": { "line": 2, "column": 9 }, "end": { "line": 2, "column": 26 } } }, "imported": { "type": "Identifier", "name": "subscribeToResult", "range": [ 53, 70 ], "loc": { "start": { "line": 2, "column": 9 }, "end": { "line": 2, "column": 26 } } }, "range": [ 53, 70 ], "loc": { "start": { "line": 2, "column": 9 }, "end": { "line": 2, "column": 26 } } } ], "source": { "type": "Literal", "value": "../util/subscribeToResult", "raw": "'../util/subscribeToResult'", "range": [ 78, 105 ], "loc": { "start": { "line": 2, "column": 34 }, "end": { "line": 2, "column": 61 } } }, "range": [ 44, 106 ], "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 2, "column": 62 } } }, { "type": "ImportDeclaration", "specifiers": [ { "type": "ImportSpecifier", "local": { "type": "Identifier", "name": "OuterSubscriber", "range": [ 116, 131 ], "loc": { "start": { "line": 3, "column": 9 }, "end": { "line": 3, "column": 24 } } }, "imported": { "type": "Identifier", "name": "OuterSubscriber", "range": [ 116, 131 ], "loc": { "start": { "line": 3, "column": 9 }, "end": { "line": 3, "column": 24 } } }, "range": [ 116, 131 ], "loc": { "start": { "line": 3, "column": 9 }, "end": { "line": 3, "column": 24 } } } ], "source": { "type": "Literal", "value": "../OuterSubscriber", "raw": "'../OuterSubscriber'", "range": [ 139, 159 ], "loc": { "start": { "line": 3, "column": 32 }, "end": { "line": 3, "column": 52 } } }, "range": [ 107, 160 ], "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 3, "column": 53 } }, "trailingComments": [ { "type": "Block", "value": "*\n * We need this JSDoc comment for affecting ESDoc.\n * @extends {Ignored}\n * @hide true\n ", "range": [ 161, 255 ], "loc": { "start": { "line": 4, "column": 0 }, "end": { "line": 8, "column": 3 } } } ] }, { "type": "ExportNamedDeclaration", "declaration": { "type": "VariableDeclaration", "declarations": [ { "type": "VariableDeclarator", "id": { "type": "Identifier", "name": "DeferObservable", "range": [ 267, 282 ], "loc": { "start": { "line": 9, "column": 11 }, "end": { "line": 9, "column": 26 } } }, "init": { "type": "CallExpression", "callee": { "type": "FunctionExpression", "id": null, "params": [ { "type": "Identifier", "name": "_super", "range": [ 296, 302 ], "loc": { "start": { "line": 9, "column": 40 }, "end": { "line": 9, "column": 46 } } } ], "body": { "type": "BlockStatement", "body": [ { "type": "ExpressionStatement", "expression": { "type": "CallExpression", "callee": { "type": "Identifier", "name": "__extends", "range": [ 310, 319 ], "loc": { "start": { "line": 10, "column": 4 }, "end": { "line": 10, "column": 13 } } }, "arguments": [ { "type": "Identifier", "name": "DeferObservable", "range": [ 320, 335 ], "loc": { "start": { "line": 10, "column": 14 }, "end": { "line": 10, "column": 29 } } }, { "type": "Identifier", "name": "_super", "range": [ 337, 343 ], "loc": { "start": { "line": 10, "column": 31 }, "end": { "line": 10, "column": 37 } } } ], "range": [ 310, 344 ], "loc": { "start": { "line": 10, "column": 4 }, "end": { "line": 10, "column": 38 } } }, "range": [ 310, 345 ], "loc": { "start": { "line": 10, "column": 4 }, "end": { "line": 10, "column": 39 } } }, { "type": "FunctionDeclaration", "id": { "type": "Identifier", "name": "DeferObservable", "range": [ 359, 374 ], "loc": { "start": { "line": 11, "column": 13 }, "end": { "line": 11, "column": 28 } } }, "params": [ { "type": "Identifier", "name": "observableFactory", "range": [ 375, 392 ], "loc": { "start": { "line": 11, "column": 29 }, "end": { "line": 11, "column": 46 } } } ], "body": { "type": "BlockStatement", "body": [ { "type": "ExpressionStatement", "expression": { "type": "CallExpression", "callee": { "type": "MemberExpression", "computed": false, "object": { "type": "Identifier", "name": "_super", "range": [ 404, 410 ], "loc": { "start": { "line": 12, "column": 8 }, "end": { "line": 12, "column": 14 } } }, "property": { "type": "Identifier", "name": "call", "range": [ 411, 415 ], "loc": { "start": { "line": 12, "column": 15 }, "end": { "line": 12, "column": 19 } } }, "range": [ 404, 415 ], "loc": { "start": { "line": 12, "column": 8 }, "end": { "line": 12, "column": 19 } } }, "arguments": [ { "type": "ThisExpression", "range": [ 416, 420 ], "loc": { "start": { "line": 12, "column": 20 }, "end": { "line": 12, "column": 24 } } } ], "range": [ 404, 421 ], "loc": { "start": { "line": 12, "column": 8 }, "end": { "line": 12, "column": 25 } } }, "range": [ 404, 422 ], "loc": { "start": { "line": 12, "column": 8 }, "end": { "line": 12, "column": 26 } } }, { "type": "ExpressionStatement", "expression": { "type": "AssignmentExpression", "operator": "=", "left": { "type": "MemberExpression", "computed": false, "object": { "type": "ThisExpression", "range": [ 431, 435 ], "loc": { "start": { "line": 13, "column": 8 }, "end": { "line": 13, "column": 12 } } }, "property": { "type": "Identifier", "name": "observableFactory", "range": [ 436, 453 ], "loc": { "start": { "line": 13, "column": 13 }, "end": { "line": 13, "column": 30 } } }, "range": [ 431, 453 ], "loc": { "start": { "line": 13, "column": 8 }, "end": { "line": 13, "column": 30 } } }, "right": { "type": "Identifier", "name": "observableFactory", "range": [ 456, 473 ], "loc": { "start": { "line": 13, "column": 33 }, "end": { "line": 13, "column": 50 } } }, "range": [ 431, 473 ], "loc": { "start": { "line": 13, "column": 8 }, "end": { "line": 13, "column": 50 } } }, "range": [ 431, 474 ], "loc": { "start": { "line": 13, "column": 8 }, "end": { "line": 13, "column": 51 } } } ], "range": [ 394, 480 ], "loc": { "start": { "line": 11, "column": 48 }, "end": { "line": 14, "column": 5 } } }, "generator": false, "expression": false, "range": [ 350, 480 ], "loc": { "start": { "line": 11, "column": 4 }, "end": { "line": 14, "column": 5 } }, "trailingComments": [ { "type": "Block", "value": "*\n * Creates an Observable that, on subscribe, calls an Observable factory to\n * make an Observable for each new Observer.\n *\n * <span class=\"informal\">Creates the Observable lazily, that is, only when it\n * is subscribed.\n * </span>\n *\n * <img src=\"./img/defer.png\" width=\"100%\">\n *\n * `defer` allows you to create the Observable only when the Observer\n * subscribes, and create a fresh Observable for each Observer. It waits until\n * an Observer subscribes to it, and then it generates an Observable,\n * typically with an Observable factory function. It does this afresh for each\n * subscriber, so although each subscriber may think it is subscribing to the\n * same Observable, in fact each subscriber gets its own individual\n * Observable.\n *\n * @example <caption>Subscribe to either an Observable of clicks or an Observable of interval, at random</caption>\n * var clicksOrInterval = Rx.Observable.defer(function () {\n * if (Math.random() > 0.5) {\n * return Rx.Observable.fromEvent(document, 'click');\n * } else {\n * return Rx.Observable.interval(1000);\n * }\n * });\n * clicksOrInterval.subscribe(x => console.log(x));\n *\n * @see {@link create}\n *\n * @param {function(): Observable|Promise} observableFactory The Observable\n * factory function to invoke for each Observer that subscribes to the output\n * Observable. May also return a Promise, which will be converted on the fly\n * to an Observable.\n * @return {Observable} An Observable whose Observers' subscriptions trigger\n * an invocation of the given Observable factory function.\n * @static true\n * @name defer\n * @owner Observable\n ", "range": [ 485, 2250 ], "loc": { "start": { "line": 15, "column": 4 }, "end": { "line": 54, "column": 7 } } } ] }, { "type": "ExpressionStatement", "expression": { "type": "AssignmentExpression", "operator": "=", "left": { "type": "MemberExpression", "computed": false, "object": { "type": "Identifier", "name": "DeferObservable", "range": [ 2255, 2270 ], "loc": { "start": { "line": 55, "column": 4 }, "end": { "line": 55, "column": 19 } } }, "property": { "type": "Identifier", "name": "create", "range": [ 2271, 2277 ], "loc": { "start": { "line": 55, "column": 20 }, "end": { "line": 55, "column": 26 } } }, "range": [ 2255, 2277 ], "loc": { "start": { "line": 55, "column": 4 }, "end": { "line": 55, "column": 26 } } }, "right": { "type": "FunctionExpression", "id": null, "params": [ { "type": "Identifier", "name": "observableFactory", "range": [ 2290, 2307 ], "loc": { "start": { "line": 55, "column": 39 }, "end": { "line": 55, "column": 56 } } } ], "body": { "type": "BlockStatement", "body": [ { "type": "ReturnStatement", "argument": { "type": "NewExpression", "callee": { "type": "Identifier", "name": "DeferObservable", "range": [ 2330, 2345 ], "loc": { "start": { "line": 56, "column": 19 }, "end": { "line": 56, "column": 34 } } }, "arguments": [ { "type": "Identifier", "name": "observableFactory", "range": [ 2346, 2363 ], "loc": { "start": { "line": 56, "column": 35 }, "end": { "line": 56, "column": 52 } } } ], "range": [ 2326, 2364 ], "loc": { "start": { "line": 56, "column": 15 }, "end": { "line": 56, "column": 53 } } }, "range": [ 2319, 2365 ], "loc": { "start": { "line": 56, "column": 8 }, "end": { "line": 56, "column": 54 } } } ], "range": [ 2309, 2371 ], "loc": { "start": { "line": 55, "column": 58 }, "end": { "line": 57, "column": 5 } } }, "generator": false, "expression": false, "range": [ 2280, 2371 ], "loc": { "start": { "line": 55, "column": 29 }, "end": { "line": 57, "column": 5 } } }, "range": [ 2255, 2371 ], "loc": { "start": { "line": 55, "column": 4 }, "end": { "line": 57, "column": 5 } } }, "range": [ 2255, 2372 ], "loc": { "start": { "line": 55, "column": 4 }, "end": { "line": 57, "column": 6 } }, "leadingComments": [ { "type": "Block", "value": "*\n * Creates an Observable that, on subscribe, calls an Observable factory to\n * make an Observable for each new Observer.\n *\n * <span class=\"informal\">Creates the Observable lazily, that is, only when it\n * is subscribed.\n * </span>\n *\n * <img src=\"./img/defer.png\" width=\"100%\">\n *\n * `defer` allows you to create the Observable only when the Observer\n * subscribes, and create a fresh Observable for each Observer. It waits until\n * an Observer subscribes to it, and then it generates an Observable,\n * typically with an Observable factory function. It does this afresh for each\n * subscriber, so although each subscriber may think it is subscribing to the\n * same Observable, in fact each subscriber gets its own individual\n * Observable.\n *\n * @example <caption>Subscribe to either an Observable of clicks or an Observable of interval, at random</caption>\n * var clicksOrInterval = Rx.Observable.defer(function () {\n * if (Math.random() > 0.5) {\n * return Rx.Observable.fromEvent(document, 'click');\n * } else {\n * return Rx.Observable.interval(1000);\n * }\n * });\n * clicksOrInterval.subscribe(x => console.log(x));\n *\n * @see {@link create}\n *\n * @param {function(): Observable|Promise} observableFactory The Observable\n * factory function to invoke for each Observer that subscribes to the output\n * Observable. May also return a Promise, which will be converted on the fly\n * to an Observable.\n * @return {Observable} An Observable whose Observers' subscriptions trigger\n * an invocation of the given Observable factory function.\n * @static true\n * @name defer\n * @owner Observable\n ", "range": [ 485, 2250 ], "loc": { "start": { "line": 15, "column": 4 }, "end": { "line": 54, "column": 7 } } } ] }, { "type": "ExpressionStatement", "expression": { "type": "AssignmentExpression", "operator": "=", "left": { "type": "MemberExpression", "computed": false, "object": { "type": "MemberExpression", "computed": false, "object": { "type": "Identifier", "name": "DeferObservable", "range": [ 2377, 2392 ], "loc": { "start": { "line": 58, "column": 4 }, "end": { "line": 58, "column": 19 } } }, "property": { "type": "Identifier", "name": "prototype", "range": [ 2393, 2402 ], "loc": { "start": { "line": 58, "column": 20 }, "end": { "line": 58, "column": 29 } } }, "range": [ 2377, 2402 ], "loc": { "start": { "line": 58, "column": 4 }, "end": { "line": 58, "column": 29 } } }, "property": { "type": "Identifier", "name": "_subscribe", "range": [ 2403, 2413 ], "loc": { "start": { "line": 58, "column": 30 }, "end": { "line": 58, "column": 40 } } }, "range": [ 2377, 2413 ], "loc": { "start": { "line": 58, "column": 4 }, "end": { "line": 58, "column": 40 } } }, "right": { "type": "FunctionExpression", "id": null, "params": [ { "type": "Identifier", "name": "subscriber", "range": [ 2426, 2436 ], "loc": { "start": { "line": 58, "column": 53 }, "end": { "line": 58, "column": 63 } } } ], "body": { "type": "BlockStatement", "body": [ { "type": "ReturnStatement", "argument": { "type": "NewExpression", "callee": { "type": "Identifier", "name": "DeferSubscriber", "range": [ 2459, 2474 ], "loc": { "start": { "line": 59, "column": 19 }, "end": { "line": 59, "column": 34 } } }, "arguments": [ { "type": "Identifier", "name": "subscriber", "range": [ 2475, 2485 ], "loc": { "start": { "line": 59, "column": 35 }, "end": { "line": 59, "column": 45 } } }, { "type": "MemberExpression", "computed": false, "object": { "type": "ThisExpression", "range": [ 2487, 2491 ], "loc": { "start": { "line": 59, "column": 47 }, "end": { "line": 59, "column": 51 } } }, "property": { "type": "Identifier", "name": "observableFactory", "range": [ 2492, 2509 ], "loc": { "start": { "line": 59, "column": 52 }, "end": { "line": 59, "column": 69 } } }, "range": [ 2487, 2509 ], "loc": { "start": { "line": 59, "column": 47 }, "end": { "line": 59, "column": 69 } } } ], "range": [ 2455, 2510 ], "loc": { "start": { "line": 59, "column": 15 }, "end": { "line": 59, "column": 70 } } }, "range": [ 2448, 2511 ], "loc": { "start": { "line": 59, "column": 8 }, "end": { "line": 59, "column": 71 } } } ], "range": [ 2438, 2517 ], "loc": { "start": { "line": 58, "column": 65 }, "end": { "line": 60, "column": 5 } } }, "generator": false, "expression": false, "range": [ 2416, 2517 ], "loc": { "start": { "line": 58, "column": 43 }, "end": { "line": 60, "column": 5 } } }, "range": [ 2377, 2517 ], "loc": { "start": { "line": 58, "column": 4 }, "end": { "line": 60, "column": 5 } } }, "range": [ 2377, 2518 ], "loc": { "start": { "line": 58, "column": 4 }, "end": { "line": 60, "column": 6 } } }, { "type": "ReturnStatement", "argument": { "type": "Identifier", "name": "DeferObservable", "range": [ 2530, 2545 ], "loc": { "start": { "line": 61, "column": 11 }, "end": { "line": 61, "column": 26 } } }, "range": [ 2523, 2546 ], "loc": { "start": { "line": 61, "column": 4 }, "end": {