UNPKG

@reactivex/rxjs

Version:

Reactive Extensions for modern JavaScript

1,426 lines (1,425 loc) 457 kB
{ "type": "Program", "body": [ { "type": "ImportDeclaration", "specifiers": [ { "type": "ImportSpecifier", "local": { "type": "Identifier", "name": "Subscriber", "range": [ 9, 19 ], "loc": { "start": { "line": 1, "column": 9 }, "end": { "line": 1, "column": 19 } } }, "imported": { "type": "Identifier", "name": "Subscriber", "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": "../Subscriber", "raw": "'../Subscriber'", "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": "Observable", "range": [ 53, 63 ], "loc": { "start": { "line": 2, "column": 9 }, "end": { "line": 2, "column": 19 } } }, "imported": { "type": "Identifier", "name": "Observable", "range": [ 53, 63 ], "loc": { "start": { "line": 2, "column": 9 }, "end": { "line": 2, "column": 19 } } }, "range": [ 53, 63 ], "loc": { "start": { "line": 2, "column": 9 }, "end": { "line": 2, "column": 19 } } } ], "source": { "type": "Literal", "value": "../Observable", "raw": "'../Observable'", "range": [ 71, 86 ], "loc": { "start": { "line": 2, "column": 27 }, "end": { "line": 2, "column": 42 } } }, "range": [ 44, 87 ], "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 2, "column": 43 } } }, { "type": "ImportDeclaration", "specifiers": [ { "type": "ImportSpecifier", "local": { "type": "Identifier", "name": "OuterSubscriber", "range": [ 97, 112 ], "loc": { "start": { "line": 3, "column": 9 }, "end": { "line": 3, "column": 24 } } }, "imported": { "type": "Identifier", "name": "OuterSubscriber", "range": [ 97, 112 ], "loc": { "start": { "line": 3, "column": 9 }, "end": { "line": 3, "column": 24 } } }, "range": [ 97, 112 ], "loc": { "start": { "line": 3, "column": 9 }, "end": { "line": 3, "column": 24 } } } ], "source": { "type": "Literal", "value": "../OuterSubscriber", "raw": "'../OuterSubscriber'", "range": [ 120, 140 ], "loc": { "start": { "line": 3, "column": 32 }, "end": { "line": 3, "column": 52 } } }, "range": [ 88, 141 ], "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 3, "column": 53 } } }, { "type": "ImportDeclaration", "specifiers": [ { "type": "ImportSpecifier", "local": { "type": "Identifier", "name": "subscribeToResult", "range": [ 151, 168 ], "loc": { "start": { "line": 4, "column": 9 }, "end": { "line": 4, "column": 26 } } }, "imported": { "type": "Identifier", "name": "subscribeToResult", "range": [ 151, 168 ], "loc": { "start": { "line": 4, "column": 9 }, "end": { "line": 4, "column": 26 } } }, "range": [ 151, 168 ], "loc": { "start": { "line": 4, "column": 9 }, "end": { "line": 4, "column": 26 } } } ], "source": { "type": "Literal", "value": "../util/subscribeToResult", "raw": "'../util/subscribeToResult'", "range": [ 176, 203 ], "loc": { "start": { "line": 4, "column": 34 }, "end": { "line": 4, "column": 61 } } }, "range": [ 142, 204 ], "loc": { "start": { "line": 4, "column": 0 }, "end": { "line": 4, "column": 62 } }, "trailingComments": [ { "type": "Block", "value": "*\n * Delays the emission of items from the source Observable by a given time span\n * determined by the emissions of another Observable.\n *\n * <span class=\"informal\">It's like {@link delay}, but the time span of the\n * delay duration is determined by a second Observable.</span>\n *\n * <img src=\"./img/delayWhen.png\" width=\"100%\">\n *\n * `delayWhen` time shifts each emitted value from the source Observable by a\n * time span determined by another Observable. When the source emits a value,\n * the `delayDurationSelector` function is called with the source value as\n * argument, and should return an Observable, called the \"duration\" Observable.\n * The source value is emitted on the output Observable only when the duration\n * Observable emits a value or completes.\n *\n * Optionally, `delayWhen` takes a second argument, `subscriptionDelay`, which\n * is an Observable. When `subscriptionDelay` emits its first value or\n * completes, the source Observable is subscribed to and starts behaving like\n * described in the previous paragraph. If `subscriptionDelay` is not provided,\n * `delayWhen` will subscribe to the source Observable as soon as the output\n * Observable is subscribed.\n *\n * @example <caption>Delay each click by a random amount of time, between 0 and 5 seconds</caption>\n * var clicks = Rx.Observable.fromEvent(document, 'click');\n * var delayedClicks = clicks.delayWhen(event =>\n * Rx.Observable.interval(Math.random() * 5000)\n * );\n * delayedClicks.subscribe(x => console.log(x));\n *\n * @see {@link debounce}\n * @see {@link delay}\n *\n * @param {function(value: T): Observable} delayDurationSelector A function that\n * returns an Observable for each value emitted by the source Observable, which\n * is then used to delay the emission of that item on the output Observable\n * until the Observable returned from this function emits a value.\n * @param {Observable} subscriptionDelay An Observable that triggers the\n * subscription to the source Observable once it emits any value.\n * @return {Observable} An Observable that delays the emissions of the source\n * Observable by an amount of time specified by the Observable returned by\n * `delayDurationSelector`.\n * @method delayWhen\n * @owner Observable\n ", "range": [ 205, 2427 ], "loc": { "start": { "line": 5, "column": 0 }, "end": { "line": 49, "column": 3 } } } ] }, { "type": "ExportNamedDeclaration", "declaration": { "type": "FunctionDeclaration", "id": { "type": "Identifier", "name": "delayWhen", "range": [ 2444, 2453 ], "loc": { "start": { "line": 50, "column": 16 }, "end": { "line": 50, "column": 25 } } }, "params": [ { "type": "Identifier", "name": "delayDurationSelector", "range": [ 2454, 2475 ], "loc": { "start": { "line": 50, "column": 26 }, "end": { "line": 50, "column": 47 } } }, { "type": "Identifier", "name": "subscriptionDelay", "range": [ 2477, 2494 ], "loc": { "start": { "line": 50, "column": 49 }, "end": { "line": 50, "column": 66 } } } ], "body": { "type": "BlockStatement", "body": [ { "type": "IfStatement", "test": { "type": "Identifier", "name": "subscriptionDelay", "range": [ 2506, 2523 ], "loc": { "start": { "line": 51, "column": 8 }, "end": { "line": 51, "column": 25 } } }, "consequent": { "type": "BlockStatement", "body": [ { "type": "ReturnStatement", "argument": { "type": "CallExpression", "callee": { "type": "MemberExpression", "computed": false, "object": { "type": "NewExpression", "callee": { "type": "Identifier", "name": "SubscriptionDelayObservable", "range": [ 2546, 2573 ], "loc": { "start": { "line": 52, "column": 19 }, "end": { "line": 52, "column": 46 } } }, "arguments": [ { "type": "ThisExpression", "range": [ 2574, 2578 ], "loc": { "start": { "line": 52, "column": 47 }, "end": { "line": 52, "column": 51 } } }, { "type": "Identifier", "name": "subscriptionDelay", "range": [ 2580, 2597 ], "loc": { "start": { "line": 52, "column": 53 }, "end": { "line": 52, "column": 70 } } } ], "range": [ 2542, 2598 ], "loc": { "start": { "line": 52, "column": 15 }, "end": { "line": 52, "column": 71 } } }, "property": { "type": "Identifier", "name": "lift", "range": [ 2612, 2616 ], "loc": { "start": { "line": 53, "column": 13 }, "end": { "line": 53, "column": 17 } } }, "range": [ 2542, 2616 ], "loc": { "start": { "line": 52, "column": 15 }, "end": { "line": 53, "column": 17 } } }, "arguments": [ { "type": "NewExpression", "callee": { "type": "Identifier", "name": "DelayWhenOperator", "range": [ 2621, 2638 ], "loc": { "start": { "line": 53, "column": 22 }, "end": { "line": 53, "column": 39 } } }, "arguments": [ { "type": "Identifier", "name": "delayDurationSelector", "range": [ 2639, 2660 ], "loc": { "start": { "line": 53, "column": 40 }, "end": { "line": 53, "column": 61 } } } ], "range": [ 2617, 2661 ], "loc": { "start": { "line": 53, "column": 18 }, "end": { "line": 53, "column": 62 } } } ], "range": [ 2542, 2662 ], "loc": { "start": { "line": 52, "column": 15 }, "end": { "line": 53, "column": 63 } } }, "range": [ 2535, 2663 ], "loc": { "start": { "line": 52, "column": 8 }, "end": { "line": 53, "column": 64 } } } ], "range": [ 2525, 2669 ], "loc": { "start": { "line": 51, "column": 27 }, "end": { "line": 54, "column": 5 } } }, "alternate": null, "range": [ 2502, 2669 ], "loc": { "start": { "line": 51, "column": 4 }, "end": { "line": 54, "column": 5 } } }, { "type": "ReturnStatement", "argument": { "type": "CallExpression", "callee": { "type": "MemberExpression", "computed": false, "object": { "type": "ThisExpression", "range": [ 2681, 2685 ], "loc": { "start": { "line": 55, "column": 11 }, "end": { "line": 55, "column": 15 } } }, "property": { "type": "Identifier", "name": "lift", "range": [ 2686, 2690 ], "loc": { "start": { "line": 55, "column": 16 }, "end": { "line": 55, "column": 20 } } }, "range": [ 2681, 2690 ], "loc": { "start": { "line": 55, "column": 11 }, "end": { "line": 55, "column": 20 } } }, "arguments": [ { "type": "NewExpression", "callee": { "type": "Identifier", "name": "DelayWhenOperator", "range": [ 2695, 2712 ], "loc": { "start": { "line": 55, "column": 25 }, "end": { "line": 55, "column": 42 } } }, "arguments": [ { "type": "Identifier", "name": "delayDurationSelector", "range": [ 2713, 2734 ], "loc": { "start": { "line": 55, "column": 43 }, "end": { "line": 55, "column": 64 } } } ], "range": [ 2691, 2735 ], "loc": { "start": { "line": 55, "column": 21 }, "end": { "line": 55, "column": 65 } } } ], "range": [ 2681, 2736 ], "loc": { "start": { "line": 55, "column": 11 }, "end": { "line": 55, "column": 66 } } }, "range": [ 2674, 2737 ], "loc": { "start": { "line": 55, "column": 4 }, "end": { "line": 55, "column": 67 } } } ], "range": [ 2496, 2739 ], "loc": { "start": { "line": 50, "column": 68 }, "end": { "line": 56, "column": 1 } } }, "generator": false, "expression": false, "range": [ 2435, 2739 ], "loc": { "start": { "line": 50, "column": 7 }, "end": { "line": 56, "column": 1 } }, "leadingComments": [ { "type": "Block", "value": "*\n * Delays the emission of items from the source Observable by a given time span\n * determined by the emissions of another Observable.\n *\n * <span class=\"informal\">It's like {@link delay}, but the time span of the\n * delay duration is determined by a second Observable.</span>\n *\n * <img src=\"./img/delayWhen.png\" width=\"100%\">\n *\n * `delayWhen` time shifts each emitted value from the source Observable by a\n * time span determined by another Observable. When the source emits a value,\n * the `delayDurationSelector` function is called with the source value as\n * argument, and should return an Observable, called the \"duration\" Observable.\n * The source value is emitted on the output Observable only when the duration\n * Observable emits a value or completes.\n *\n * Optionally, `delayWhen` takes a second argument, `subscriptionDelay`, which\n * is an Observable. When `subscriptionDelay` emits its first value or\n * completes, the source Observable is subscribed to and starts behaving like\n * described in the previous paragraph. If `subscriptionDelay` is not provided,\n * `delayWhen` will subscribe to the source Observable as soon as the output\n * Observable is subscribed.\n *\n * @example <caption>Delay each click by a random amount of time, between 0 and 5 seconds</caption>\n * var clicks = Rx.Observable.fromEvent(document, 'click');\n * var delayedClicks = clicks.delayWhen(event =>\n * Rx.Observable.interval(Math.random() * 5000)\n * );\n * delayedClicks.subscribe(x => console.log(x));\n *\n * @see {@link debounce}\n * @see {@link delay}\n *\n * @param {function(value: T): Observable} delayDurationSelector A function that\n * returns an Observable for each value emitted by the source Observable, which\n * is then used to delay the emission of that item on the output Observable\n * until the Observable returned from this function emits a value.\n * @param {Observable} subscriptionDelay An Observable that triggers the\n * subscription to the source Observable once it emits any value.\n * @return {Observable} An Observable that delays the emissions of the source\n * Observable by an amount of time specified by the Observable returned by\n * `delayDurationSelector`.\n * @method delayWhen\n * @owner Observable\n ", "range": [ 205, 2427 ], "loc": { "start": { "line": 5, "column": 0 }, "end": { "line": 49, "column": 3 } } } ], "trailingComments": [] }, "specifiers": [], "source": null, "range": [ 2428, 2739 ], "loc": { "start": { "line": 50, "column": 0 }, "end": { "line": 56, "column": 1 } }, "leadingComments": [ { "type": "Block", "value": "*\n * Delays the emission of items from the source Observable by a given time span\n * determined by the emissions of another Observable.\n *\n * <span class=\"informal\">It's like {@link delay}, but the time span of the\n * delay duration is determined by a second Observable.</span>\n *\n * <img src=\"./img/delayWhen.png\" width=\"100%\">\n *\n * `delayWhen` time shifts each emitted value from the source Observable by a\n * time span determined by another Observable. When the source emits a value,\n * the `delayDurationSelector` function is called with the source value as\n * argument, and should return an Observable, called the \"duration\" Observable.\n * The source value is emitted on the output Observable only when the duration\n * Observable emits a value or completes.\n *\n * Optionally, `delayWhen` takes a second argument, `subscriptionDelay`, which\n * is an Observable. When `subscriptionDelay` emits its first value or\n * completes, the source Observable is subscribed to and starts behaving like\n * described in the previous paragraph. If `subscriptionDelay` is not provided,\n * `delayWhen` will subscribe to the source Observable as soon as the output\n * Observable is subscribed.\n *\n * @example <caption>Delay each click by a random amount of time, between 0 and 5 seconds</caption>\n * var clicks = Rx.Observable.fromEvent(document, 'click');\n * var delayedClicks = clicks.delayWhen(event =>\n * Rx.Observable.interval(Math.random() * 5000)\n * );\n * delayedClicks.subscribe(x => console.log(x));\n *\n * @see {@link debounce}\n * @see {@link delay}\n *\n * @param {function(value: T): Observable} delayDurationSelector A function that\n * returns an Observable for each value emitted by the source Observable, which\n * is then used to delay the emission of that item on the output Observable\n * until the Observable returned from this function emits a value.\n * @param {Observable} subscriptionDelay An Observable that triggers the\n * subscription to the source Observable once it emits any value.\n * @return {Observable} An Observable that delays the emissions of the source\n * Observable by an amount of time specified by the Observable returned by\n * `delayDurationSelector`.\n * @method delayWhen\n * @owner Observable\n ", "range": [ 205, 2427 ], "loc": { "start": { "line": 5, "column": 0 }, "end": { "line": 49, "column": 3 } } } ] }, { "type": "VariableDeclaration", "declarations": [ { "type": "VariableDeclarator", "id": { "type": "Identifier", "name": "DelayWhenOperator", "range": [ 2744, 2761 ], "loc": { "start": { "line": 57, "column": 4 }, "end": { "line": 57, "column": 21 } } }, "init": { "type": "CallExpression", "callee": { "type": "FunctionExpression", "id": null, "params": [], "body": { "type": "BlockStatement", "body": [ { "type": "FunctionDeclaration", "id": { "type": "Identifier", "name": "DelayWhenOperator", "range": [ 2792, 2809 ], "loc": { "start": { "line": 58, "column": 13 }, "end": { "line": 58, "column": 30 } } }, "params": [ { "type": "Identifier", "name": "delayDurationSelector", "range": [ 2810, 2831 ], "loc": { "start": { "line": 58, "column": 31 }, "end": { "line": 58, "column": 52 } } } ], "body": { "type": "BlockStatement", "body": [ { "type": "ExpressionStatement", "expression": { "type": "AssignmentExpression", "operator": "=", "left": { "type": "MemberExpression", "computed": false, "object": { "type": "ThisExpression", "range": [ 2843, 2847 ], "loc": { "start": { "line": 59, "column": 8 }, "end": { "line": 59, "column": 12 } } }, "property": { "type": "Identifier", "name": "delayDurationSelector", "range": [ 2848, 2869 ], "loc": { "start": { "line": 59, "column": 13 }, "end": { "line": 59, "column": 34 } } }, "range": [ 2843, 2869 ], "loc": { "start": { "line": 59, "column": 8 }, "end": { "line": 59, "column": 34 } } }, "right": { "type": "Identifier", "name": "delayDurationSelector", "range": [ 2872, 2893 ], "loc": { "start": { "line": 59, "column": 37 }, "end": { "line": 59, "column": 58 } } }, "range": [ 2843, 2893 ], "loc": { "start": { "line": 59, "column": 8 }, "end": { "line": 59, "column": 58 } } }, "range": [ 2843, 2894 ], "loc": { "start": { "line": 59, "column": 8 }, "end": { "line": 59, "column": 59 } } } ], "range": [ 2833, 2900 ], "loc": { "start": { "line": 58, "column": 54 }, "end": { "line": 60, "column": 5 } } }, "generator": false, "expression": false, "range": [ 2783, 2900 ], "loc": { "start": { "line": 58, "column": 4 }, "end": { "line": 60, "column": 5 } } }, { "type": "ExpressionStatement", "expression": { "type": "AssignmentExpression", "operator": "=", "left": { "type": "MemberExpression", "computed": false, "object": { "type": "MemberExpression", "computed": false, "object": { "type": "Identifier", "name": "DelayWhenOperator", "range": [ 2905, 2922 ], "loc": { "start": { "line": 61, "column": 4 }, "end": { "line": 61, "column": 21 } } }, "property": { "type": "Identifier", "name": "prototype", "range": [ 2923, 2932 ], "loc": { "start": { "line": 61, "column": 22 }, "end": { "line": 61, "column": 31 } } }, "range": [ 2905, 2932 ], "loc": { "start": { "line": 61, "column": 4 }, "end": { "line": 61, "column": 31 } } }, "property": { "type": "Identifier", "name": "call", "range": [ 2933, 2937 ], "loc": { "start": { "line": 61, "column": 32 }, "end": { "line": 61, "column": 36 } } }, "range": [ 2905, 2937 ], "loc": { "start": { "line": 61, "column": 4 }, "end": { "line": 61, "column": 36 } } }, "right": { "type": "FunctionExpression", "id": null, "params": [ { "type": "Identifier", "name": "subscriber", "range": [ 2950, 2960 ], "loc": { "start": { "line": 61, "column": 49 }, "end": { "line": 61, "column": 59 } } }, { "type": "Identifier", "name": "source", "range": [ 2962, 2968 ], "loc": { "start": { "line": 61, "column": 61 }, "end": { "line": 61, "column": 67 } } } ], "body": { "type": "BlockStatement", "body": [ { "type": "ReturnStatement", "argument": { "type": "CallExpression", "callee": { "type": "MemberExpression", "computed": false, "object": { "type": "Identifier", "name": "source", "range": [ 2987, 2993 ], "loc": { "start": { "line": 62, "column": 15 }, "end": { "line": 62, "column": 21 } } }, "property": { "type": "Identifier", "name": "_subscribe", "range": [ 2994, 3004 ], "loc": { "start": { "line": 62, "column": 22 }, "end": { "line": 62, "column": 32 } } }, "range": [ 2987, 3004 ], "loc": { "start": { "line": 62, "column": 15 }, "end": { "line": 62, "column": 32 } } }, "arguments": [ { "type": "NewExpression", "callee": { "type": "Identifier", "name": "DelayWhenSubscriber", "range": [ 3009, 3028 ], "loc": { "start": { "line": 62, "column": 37 }, "end": { "line": 62, "column": 56 } } }, "arguments": [ { "type": "Identifier", "name": "subscriber", "range": [ 3029, 3039 ], "loc": { "start": { "line": 62, "column": 57 }, "end": { "line": 62, "column": 67 } } }, { "type": "MemberExpression", "computed": false, "object": { "type": "ThisExpression", "range": [ 3041, 3045 ], "loc": { "start": { "line": 62, "column": 69 }, "end": { "line": 62, "column": 73 } } }, "property": { "type": "Identifier", "name": "delayDurationSelector", "range": [ 3046, 3067 ], "loc": { "start": { "line": 62, "column": 74 }, "end": { "line": 62, "column": 95