UNPKG

@reactivex/rxjs

Version:

Reactive Extensions for modern JavaScript

1,413 lines (1,412 loc) 203 kB
{ "type": "Program", "body": [ { "type": "ImportDeclaration", "specifiers": [ { "type": "ImportSpecifier", "local": { "type": "Identifier", "name": "OuterSubscriber", "range": [ 9, 24 ], "loc": { "start": { "line": 1, "column": 9 }, "end": { "line": 1, "column": 24 } } }, "imported": { "type": "Identifier", "name": "OuterSubscriber", "range": [ 9, 24 ], "loc": { "start": { "line": 1, "column": 9 }, "end": { "line": 1, "column": 24 } } }, "range": [ 9, 24 ], "loc": { "start": { "line": 1, "column": 9 }, "end": { "line": 1, "column": 24 } } } ], "source": { "type": "Literal", "value": "../OuterSubscriber", "raw": "'../OuterSubscriber'", "range": [ 32, 52 ], "loc": { "start": { "line": 1, "column": 32 }, "end": { "line": 1, "column": 52 } } }, "range": [ 0, 53 ], "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 1, "column": 53 } } }, { "type": "ImportDeclaration", "specifiers": [ { "type": "ImportSpecifier", "local": { "type": "Identifier", "name": "subscribeToResult", "range": [ 63, 80 ], "loc": { "start": { "line": 2, "column": 9 }, "end": { "line": 2, "column": 26 } } }, "imported": { "type": "Identifier", "name": "subscribeToResult", "range": [ 63, 80 ], "loc": { "start": { "line": 2, "column": 9 }, "end": { "line": 2, "column": 26 } } }, "range": [ 63, 80 ], "loc": { "start": { "line": 2, "column": 9 }, "end": { "line": 2, "column": 26 } } } ], "source": { "type": "Literal", "value": "../util/subscribeToResult", "raw": "'../util/subscribeToResult'", "range": [ 88, 115 ], "loc": { "start": { "line": 2, "column": 34 }, "end": { "line": 2, "column": 61 } } }, "range": [ 54, 116 ], "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 2, "column": 62 } }, "trailingComments": [ { "type": "Block", "value": "*\n * Converts a higher-order Observable into a first-order Observable by\n * subscribing to only the most recently emitted of those inner Observables.\n *\n * <span class=\"informal\">Flattens an Observable-of-Observables by dropping the\n * previous inner Observable once a new one appears.</span>\n *\n * <img src=\"./img/switch.png\" width=\"100%\">\n *\n * `switch` subscribes to an Observable that emits Observables, also known as a\n * higher-order Observable. Each time it observes one of these emitted inner\n * Observables, the output Observable subscribes to the inner Observable and\n * begins emitting the items emitted by that. So far, it behaves\n * like {@link mergeAll}. However, when a new inner Observable is emitted,\n * `switch` unsubscribes from the earlier-emitted inner Observable and\n * subscribes to the new inner Observable and begins emitting items from it. It\n * continues to behave like this for subsequent inner Observables.\n *\n * @example <caption>Rerun an interval Observable on every click event</caption>\n * var clicks = Rx.Observable.fromEvent(document, 'click');\n * // Each click event is mapped to an Observable that ticks every second\n * var higherOrder = clicks.map((ev) => Rx.Observable.interval(1000));\n * var switched = higherOrder.switch();\n * // The outcome is that `switched` is essentially a timer that restarts\n * // on every click. The interval Observables from older clicks do not merge\n * // with the current interval Observable.\n * switched.subscribe(x => console.log(x));\n *\n * @see {@link combineAll}\n * @see {@link concatAll}\n * @see {@link exhaust}\n * @see {@link mergeAll}\n * @see {@link switchMap}\n * @see {@link switchMapTo}\n * @see {@link zipAll}\n *\n * @return {Observable<T>} An Observable that emits the items emitted by the\n * Observable most recently emitted by the source Observable.\n * @method switch\n * @name switch\n * @owner Observable\n ", "range": [ 117, 2006 ], "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 44, "column": 3 } } } ] }, { "type": "ExportNamedDeclaration", "declaration": { "type": "FunctionDeclaration", "id": { "type": "Identifier", "name": "_switch", "range": [ 2023, 2030 ], "loc": { "start": { "line": 45, "column": 16 }, "end": { "line": 45, "column": 23 } } }, "params": [], "body": { "type": "BlockStatement", "body": [ { "type": "ReturnStatement", "argument": { "type": "CallExpression", "callee": { "type": "MemberExpression", "computed": false, "object": { "type": "ThisExpression", "range": [ 2046, 2050 ], "loc": { "start": { "line": 46, "column": 11 }, "end": { "line": 46, "column": 15 } } }, "property": { "type": "Identifier", "name": "lift", "range": [ 2051, 2055 ], "loc": { "start": { "line": 46, "column": 16 }, "end": { "line": 46, "column": 20 } } }, "range": [ 2046, 2055 ], "loc": { "start": { "line": 46, "column": 11 }, "end": { "line": 46, "column": 20 } } }, "arguments": [ { "type": "NewExpression", "callee": { "type": "Identifier", "name": "SwitchOperator", "range": [ 2060, 2074 ], "loc": { "start": { "line": 46, "column": 25 }, "end": { "line": 46, "column": 39 } } }, "arguments": [], "range": [ 2056, 2076 ], "loc": { "start": { "line": 46, "column": 21 }, "end": { "line": 46, "column": 41 } } } ], "range": [ 2046, 2077 ], "loc": { "start": { "line": 46, "column": 11 }, "end": { "line": 46, "column": 42 } } }, "range": [ 2039, 2078 ], "loc": { "start": { "line": 46, "column": 4 }, "end": { "line": 46, "column": 43 } } } ], "range": [ 2033, 2080 ], "loc": { "start": { "line": 45, "column": 26 }, "end": { "line": 47, "column": 1 } } }, "generator": false, "expression": false, "range": [ 2014, 2080 ], "loc": { "start": { "line": 45, "column": 7 }, "end": { "line": 47, "column": 1 } }, "leadingComments": [ { "type": "Block", "value": "*\n * Converts a higher-order Observable into a first-order Observable by\n * subscribing to only the most recently emitted of those inner Observables.\n *\n * <span class=\"informal\">Flattens an Observable-of-Observables by dropping the\n * previous inner Observable once a new one appears.</span>\n *\n * <img src=\"./img/switch.png\" width=\"100%\">\n *\n * `switch` subscribes to an Observable that emits Observables, also known as a\n * higher-order Observable. Each time it observes one of these emitted inner\n * Observables, the output Observable subscribes to the inner Observable and\n * begins emitting the items emitted by that. So far, it behaves\n * like {@link mergeAll}. However, when a new inner Observable is emitted,\n * `switch` unsubscribes from the earlier-emitted inner Observable and\n * subscribes to the new inner Observable and begins emitting items from it. It\n * continues to behave like this for subsequent inner Observables.\n *\n * @example <caption>Rerun an interval Observable on every click event</caption>\n * var clicks = Rx.Observable.fromEvent(document, 'click');\n * // Each click event is mapped to an Observable that ticks every second\n * var higherOrder = clicks.map((ev) => Rx.Observable.interval(1000));\n * var switched = higherOrder.switch();\n * // The outcome is that `switched` is essentially a timer that restarts\n * // on every click. The interval Observables from older clicks do not merge\n * // with the current interval Observable.\n * switched.subscribe(x => console.log(x));\n *\n * @see {@link combineAll}\n * @see {@link concatAll}\n * @see {@link exhaust}\n * @see {@link mergeAll}\n * @see {@link switchMap}\n * @see {@link switchMapTo}\n * @see {@link zipAll}\n *\n * @return {Observable<T>} An Observable that emits the items emitted by the\n * Observable most recently emitted by the source Observable.\n * @method switch\n * @name switch\n * @owner Observable\n ", "range": [ 117, 2006 ], "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 44, "column": 3 } } } ], "trailingComments": [] }, "specifiers": [], "source": null, "range": [ 2007, 2080 ], "loc": { "start": { "line": 45, "column": 0 }, "end": { "line": 47, "column": 1 } }, "leadingComments": [ { "type": "Block", "value": "*\n * Converts a higher-order Observable into a first-order Observable by\n * subscribing to only the most recently emitted of those inner Observables.\n *\n * <span class=\"informal\">Flattens an Observable-of-Observables by dropping the\n * previous inner Observable once a new one appears.</span>\n *\n * <img src=\"./img/switch.png\" width=\"100%\">\n *\n * `switch` subscribes to an Observable that emits Observables, also known as a\n * higher-order Observable. Each time it observes one of these emitted inner\n * Observables, the output Observable subscribes to the inner Observable and\n * begins emitting the items emitted by that. So far, it behaves\n * like {@link mergeAll}. However, when a new inner Observable is emitted,\n * `switch` unsubscribes from the earlier-emitted inner Observable and\n * subscribes to the new inner Observable and begins emitting items from it. It\n * continues to behave like this for subsequent inner Observables.\n *\n * @example <caption>Rerun an interval Observable on every click event</caption>\n * var clicks = Rx.Observable.fromEvent(document, 'click');\n * // Each click event is mapped to an Observable that ticks every second\n * var higherOrder = clicks.map((ev) => Rx.Observable.interval(1000));\n * var switched = higherOrder.switch();\n * // The outcome is that `switched` is essentially a timer that restarts\n * // on every click. The interval Observables from older clicks do not merge\n * // with the current interval Observable.\n * switched.subscribe(x => console.log(x));\n *\n * @see {@link combineAll}\n * @see {@link concatAll}\n * @see {@link exhaust}\n * @see {@link mergeAll}\n * @see {@link switchMap}\n * @see {@link switchMapTo}\n * @see {@link zipAll}\n *\n * @return {Observable<T>} An Observable that emits the items emitted by the\n * Observable most recently emitted by the source Observable.\n * @method switch\n * @name switch\n * @owner Observable\n ", "range": [ 117, 2006 ], "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 44, "column": 3 } } } ] }, { "type": "VariableDeclaration", "declarations": [ { "type": "VariableDeclarator", "id": { "type": "Identifier", "name": "SwitchOperator", "range": [ 2085, 2099 ], "loc": { "start": { "line": 48, "column": 4 }, "end": { "line": 48, "column": 18 } } }, "init": { "type": "CallExpression", "callee": { "type": "FunctionExpression", "id": null, "params": [], "body": { "type": "BlockStatement", "body": [ { "type": "FunctionDeclaration", "id": { "type": "Identifier", "name": "SwitchOperator", "range": [ 2130, 2144 ], "loc": { "start": { "line": 49, "column": 13 }, "end": { "line": 49, "column": 27 } } }, "params": [], "body": { "type": "BlockStatement", "body": [], "range": [ 2147, 2154 ], "loc": { "start": { "line": 49, "column": 30 }, "end": { "line": 50, "column": 5 } } }, "generator": false, "expression": false, "range": [ 2121, 2154 ], "loc": { "start": { "line": 49, "column": 4 }, "end": { "line": 50, "column": 5 } } }, { "type": "ExpressionStatement", "expression": { "type": "AssignmentExpression", "operator": "=", "left": { "type": "MemberExpression", "computed": false, "object": { "type": "MemberExpression", "computed": false, "object": { "type": "Identifier", "name": "SwitchOperator", "range": [ 2159, 2173 ], "loc": { "start": { "line": 51, "column": 4 }, "end": { "line": 51, "column": 18 } } }, "property": { "type": "Identifier", "name": "prototype", "range": [ 2174, 2183 ], "loc": { "start": { "line": 51, "column": 19 }, "end": { "line": 51, "column": 28 } } }, "range": [ 2159, 2183 ], "loc": { "start": { "line": 51, "column": 4 }, "end": { "line": 51, "column": 28 } } }, "property": { "type": "Identifier", "name": "call", "range": [ 2184, 2188 ], "loc": { "start": { "line": 51, "column": 29 }, "end": { "line": 51, "column": 33 } } }, "range": [ 2159, 2188 ], "loc": { "start": { "line": 51, "column": 4 }, "end": { "line": 51, "column": 33 } } }, "right": { "type": "FunctionExpression", "id": null, "params": [ { "type": "Identifier", "name": "subscriber", "range": [ 2201, 2211 ], "loc": { "start": { "line": 51, "column": 46 }, "end": { "line": 51, "column": 56 } } }, { "type": "Identifier", "name": "source", "range": [ 2213, 2219 ], "loc": { "start": { "line": 51, "column": 58 }, "end": { "line": 51, "column": 64 } } } ], "body": { "type": "BlockStatement", "body": [ { "type": "ReturnStatement", "argument": { "type": "CallExpression", "callee": { "type": "MemberExpression", "computed": false, "object": { "type": "Identifier", "name": "source", "range": [ 2238, 2244 ], "loc": { "start": { "line": 52, "column": 15 }, "end": { "line": 52, "column": 21 } } }, "property": { "type": "Identifier", "name": "_subscribe", "range": [ 2245, 2255 ], "loc": { "start": { "line": 52, "column": 22 }, "end": { "line": 52, "column": 32 } } }, "range": [ 2238, 2255 ], "loc": { "start": { "line": 52, "column": 15 }, "end": { "line": 52, "column": 32 } } }, "arguments": [ { "type": "NewExpression", "callee": { "type": "Identifier", "name": "SwitchSubscriber", "range": [ 2260, 2276 ], "loc": { "start": { "line": 52, "column": 37 }, "end": { "line": 52, "column": 53 } } }, "arguments": [ { "type": "Identifier", "name": "subscriber", "range": [ 2277, 2287 ], "loc": { "start": { "line": 52, "column": 54 }, "end": { "line": 52, "column": 64 } } } ], "range": [ 2256, 2288 ], "loc": { "start": { "line": 52, "column": 33 }, "end": { "line": 52, "column": 65 } } } ], "range": [ 2238, 2289 ], "loc": { "start": { "line": 52, "column": 15 }, "end": { "line": 52, "column": 66 } } }, "range": [ 2231, 2290 ], "loc": { "start": { "line": 52, "column": 8 }, "end": { "line": 52, "column": 67 } } } ], "range": [ 2221, 2296 ], "loc": { "start": { "line": 51, "column": 66 }, "end": { "line": 53, "column": 5 } } }, "generator": false, "expression": false, "range": [ 2191, 2296 ], "loc": { "start": { "line": 51, "column": 36 }, "end": { "line": 53, "column": 5 } } }, "range": [ 2159, 2296 ], "loc": { "start": { "line": 51, "column": 4 }, "end": { "line": 53, "column": 5 } } }, "range": [ 2159, 2297 ], "loc": { "start": { "line": 51, "column": 4 }, "end": { "line": 53, "column": 6 } } }, { "type": "ReturnStatement", "argument": { "type": "Identifier", "name": "SwitchOperator", "range": [ 2309, 2323 ], "loc": { "start": { "line": 54, "column": 11 }, "end": { "line": 54, "column": 25 } } }, "range": [ 2302, 2324 ], "loc": { "start": { "line": 54, "column": 4 }, "end": { "line": 54, "column": 26 } } } ], "range": [ 2115, 2326 ], "loc": { "start": { "line": 48, "column": 34 }, "end": { "line": 55, "column": 1 } } }, "generator": false, "expression": false, "range": [ 2103, 2326 ], "loc": { "start": { "line": 48, "column": 22 }, "end": { "line": 55, "column": 1 } } }, "arguments": [], "range": [ 2103, 2328 ], "loc": { "start": { "line": 48, "column": 22 }, "end": { "line": 55, "column": 3 } } }, "range": [ 2085, 2329 ], "loc": { "start": { "line": 48, "column": 4 }, "end": { "line": 55, "column": 4 } } } ], "kind": "var", "range": [ 2081, 2330 ], "loc": { "start": { "line": 48, "column": 0 }, "end": { "line": 55, "column": 5 } }, "trailingComments": [ { "type": "Block", "value": "*\n * We need this JSDoc comment for affecting ESDoc.\n * @ignore\n * @extends {Ignored}\n ", "range": [ 2331, 2422 ], "loc": { "start": { "line": 56, "column": 0 }, "end": { "line": 60, "column": 3 } } } ] }, { "type": "VariableDeclaration", "declarations": [ { "type": "VariableDeclarator", "id": { "type": "Identifier", "name": "SwitchSubscriber", "range": [ 2427, 2443 ], "loc": { "start": { "line": 61, "column": 4 }, "end": { "line": 61, "column": 20 } } }, "init": { "type": "CallExpression", "callee": { "type": "FunctionExpression", "id": null, "params": [ { "type": "Identifier", "name": "_super", "range": [ 2457, 2463 ], "loc": { "start": { "line": 61, "column": 34 }, "end": { "line": 61, "column": 40 } } } ], "body": { "type": "BlockStatement", "body": [ { "type": "ExpressionStatement", "expression": { "type": "CallExpression", "callee": { "type": "Identifier", "name": "__extends", "range": [ 2471, 2480 ], "loc": { "start": { "line": 62, "column": 4 }, "end": { "line": 62, "column": 13 } } }, "arguments": [ { "type": "Identifier", "name": "SwitchSubscriber", "range": [ 2481, 2497 ], "loc": { "start": { "line": 62, "column": 14 }, "end": { "line": 62, "column": 30 } } }, { "type": "Identifier", "name": "_super", "range": [ 2499, 2505 ], "loc": { "start": { "line": 62, "column": 32 }, "end": { "line": 62, "column": 38 } } } ], "range": [ 2471, 2506 ], "loc": { "start": { "line": 62, "column": 4 }, "end": { "line": 62, "column": 39 } } }, "range": [ 2471, 2507 ], "loc": { "start": { "line": 62, "column": 4 }, "end": { "line": 62, "column": 40 } } }, { "type": "FunctionDeclaration", "id": { "type": "Identifier", "name": "SwitchSubscriber", "range": [ 2521, 2537 ], "loc": { "start": { "line": 63, "column": 13 }, "end": { "line": 63, "column": 29 } } }, "params": [ { "type": "Identifier", "name": "destination", "range": [ 2538, 2549 ], "loc": { "start": { "line": 63, "column": 30 }, "end": { "line": 63, "column": 41 } } } ], "body": { "type": "BlockStatement", "body": [ { "type": "ExpressionStatement", "expression": { "type": "CallExpression", "callee": { "type": "MemberExpression", "computed": false, "object": { "type": "Identifier", "name": "_super", "range": [ 2561, 2567 ], "loc": { "start": { "line": 64, "column": 8 }, "end": { "line": 64, "column": 14 } } }, "property": { "type": "Identifier", "name": "call", "range": [ 2568, 2572 ], "loc": { "start": { "line": 64, "column": 15 }, "end": { "line": 64, "column": 19 } } }, "range": [ 2561, 2572 ], "loc": { "start": { "line": 64, "column": 8 }, "end": { "line": 64, "column": 19 } } }, "arguments": [ { "type": "ThisExpression", "range": [ 2573, 2577 ], "loc": { "start": { "line": 64, "column": 20 }, "end": { "line": 64, "column": 24 } } }, { "type": "Identifier", "name": "destination", "range": [ 2579, 2590 ], "loc": { "start": { "line": 64, "column": 26 }, "end": { "line": 64, "column": 37 } } } ], "range": [ 2561, 2591 ], "loc": { "start": { "line": 64, "column": 8 }, "end": { "line": 64, "column": 38 } } }, "range": [ 2561, 2592 ], "loc": { "start": { "line": 64, "column": 8 }, "end": { "line": 64, "column": 39 } } }, { "type": "ExpressionStatement", "expression": { "type": "AssignmentExpression", "operator": "=", "left": { "type": "MemberExpression", "computed": false, "object": { "type": "ThisExpression", "range": [ 2601, 2605 ], "loc": { "start": { "line": 65, "column": 8 }, "end": { "line": 65, "column": 12 } } }, "property": { "type": "Identifier", "name": "active", "range": [ 2606, 2612 ], "loc": { "start": { "line": 65, "column": 13 }, "end": { "line": 65, "column": 19 } } }, "range": [ 2601, 2612 ], "loc": { "start": { "line": 65, "column": 8 }, "end": { "line": 65, "column": 19 } } }, "right": { "type": "Literal", "value": 0, "raw": "0", "range": [ 2615, 2616 ], "loc": { "start": { "line": 65, "column": 22 }, "end": { "line": 65, "column": 23 } } }, "range": [ 2601, 2616 ], "loc": { "start": { "line": 65, "column": 8