UNPKG

@reactivex/rxjs

Version:

Reactive Extensions for modern JavaScript

1,665 lines (1,664 loc) 83.1 kB
{ "type": "Program", "body": [ { "type": "ImportDeclaration", "specifiers": [ { "type": "ImportSpecifier", "local": { "type": "Identifier", "name": "isScheduler", "range": [ 9, 20 ], "loc": { "start": { "line": 1, "column": 9 }, "end": { "line": 1, "column": 20 } } }, "imported": { "type": "Identifier", "name": "isScheduler", "range": [ 9, 20 ], "loc": { "start": { "line": 1, "column": 9 }, "end": { "line": 1, "column": 20 } } }, "range": [ 9, 20 ], "loc": { "start": { "line": 1, "column": 9 }, "end": { "line": 1, "column": 20 } } } ], "source": { "type": "Literal", "value": "../util/isScheduler", "raw": "'../util/isScheduler'", "range": [ 28, 49 ], "loc": { "start": { "line": 1, "column": 28 }, "end": { "line": 1, "column": 49 } } }, "range": [ 0, 50 ], "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 1, "column": 50 } } }, { "type": "ImportDeclaration", "specifiers": [ { "type": "ImportSpecifier", "local": { "type": "Identifier", "name": "isArray", "range": [ 60, 67 ], "loc": { "start": { "line": 2, "column": 9 }, "end": { "line": 2, "column": 16 } } }, "imported": { "type": "Identifier", "name": "isArray", "range": [ 60, 67 ], "loc": { "start": { "line": 2, "column": 9 }, "end": { "line": 2, "column": 16 } } }, "range": [ 60, 67 ], "loc": { "start": { "line": 2, "column": 9 }, "end": { "line": 2, "column": 16 } } } ], "source": { "type": "Literal", "value": "../util/isArray", "raw": "'../util/isArray'", "range": [ 75, 92 ], "loc": { "start": { "line": 2, "column": 24 }, "end": { "line": 2, "column": 41 } } }, "range": [ 51, 93 ], "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 2, "column": 42 } } }, { "type": "ImportDeclaration", "specifiers": [ { "type": "ImportSpecifier", "local": { "type": "Identifier", "name": "ArrayObservable", "range": [ 103, 118 ], "loc": { "start": { "line": 3, "column": 9 }, "end": { "line": 3, "column": 24 } } }, "imported": { "type": "Identifier", "name": "ArrayObservable", "range": [ 103, 118 ], "loc": { "start": { "line": 3, "column": 9 }, "end": { "line": 3, "column": 24 } } }, "range": [ 103, 118 ], "loc": { "start": { "line": 3, "column": 9 }, "end": { "line": 3, "column": 24 } } } ], "source": { "type": "Literal", "value": "./ArrayObservable", "raw": "'./ArrayObservable'", "range": [ 126, 145 ], "loc": { "start": { "line": 3, "column": 32 }, "end": { "line": 3, "column": 51 } } }, "range": [ 94, 146 ], "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 3, "column": 52 } } }, { "type": "ImportDeclaration", "specifiers": [ { "type": "ImportSpecifier", "local": { "type": "Identifier", "name": "CombineLatestOperator", "range": [ 156, 177 ], "loc": { "start": { "line": 4, "column": 9 }, "end": { "line": 4, "column": 30 } } }, "imported": { "type": "Identifier", "name": "CombineLatestOperator", "range": [ 156, 177 ], "loc": { "start": { "line": 4, "column": 9 }, "end": { "line": 4, "column": 30 } } }, "range": [ 156, 177 ], "loc": { "start": { "line": 4, "column": 9 }, "end": { "line": 4, "column": 30 } } } ], "source": { "type": "Literal", "value": "../operator/combineLatest", "raw": "'../operator/combineLatest'", "range": [ 185, 212 ], "loc": { "start": { "line": 4, "column": 38 }, "end": { "line": 4, "column": 65 } } }, "range": [ 147, 213 ], "loc": { "start": { "line": 4, "column": 0 }, "end": { "line": 4, "column": 66 } }, "trailingComments": [ { "type": "Block", "value": " tslint:enable:max-line-length ", "range": [ 214, 249 ], "loc": { "start": { "line": 5, "column": 0 }, "end": { "line": 5, "column": 35 } } }, { "type": "Block", "value": "*\n * Combines multiple Observables to create an Observable whose values are\n * calculated from the latest values of each of its input Observables.\n *\n * <span class=\"informal\">Whenever any input Observable emits a value, it\n * computes a formula using the latest values from all the inputs, then emits\n * the output of that formula.</span>\n *\n * <img src=\"./img/combineLatest.png\" width=\"100%\">\n *\n * `combineLatest` combines the values from all the Observables passed as\n * arguments. This is done by subscribing to each Observable, in order, and\n * collecting an array of each of the most recent values any time any of the\n * input Observables emits, then either taking that array and passing it as\n * arguments to an optional `project` function and emitting the return value of\n * that, or just emitting the array of recent values directly if there is no\n * `project` function.\n *\n * @example <caption>Dynamically calculate the Body-Mass Index from an Observable of weight and one for height</caption>\n * var weight = Rx.Observable.of(70, 72, 76, 79, 75);\n * var height = Rx.Observable.of(1.76, 1.77, 1.78);\n * var bmi = Rx.Observable.combineLatest(weight, height, (w, h) => w / (h * h));\n * bmi.subscribe(x => console.log('BMI is ' + x));\n *\n * @see {@link combineAll}\n * @see {@link merge}\n * @see {@link withLatestFrom}\n *\n * @param {Observable} observable1 An input Observable to combine with the\n * source Observable.\n * @param {Observable} observable2 An input Observable to combine with the\n * source Observable. More than one input Observables may be given as argument.\n * @param {function} [project] An optional function to project the values from\n * the combined latest values into a new value on the output Observable.\n * @param {Scheduler} [scheduler=null] The Scheduler to use for subscribing to\n * each input Observable.\n * @return {Observable} An Observable of projected values from the most recent\n * values from each input Observable, or an array of the most recent values from\n * each input Observable.\n * @static true\n * @name combineLatest\n * @owner Observable\n ", "range": [ 250, 2339 ], "loc": { "start": { "line": 6, "column": 0 }, "end": { "line": 48, "column": 3 } } } ] }, { "type": "ExportNamedDeclaration", "declaration": { "type": "FunctionDeclaration", "id": { "type": "Identifier", "name": "combineLatest", "range": [ 2356, 2369 ], "loc": { "start": { "line": 49, "column": 16 }, "end": { "line": 49, "column": 29 } } }, "params": [], "body": { "type": "BlockStatement", "body": [ { "type": "VariableDeclaration", "declarations": [ { "type": "VariableDeclarator", "id": { "type": "Identifier", "name": "observables", "range": [ 2382, 2393 ], "loc": { "start": { "line": 50, "column": 8 }, "end": { "line": 50, "column": 19 } } }, "init": { "type": "ArrayExpression", "elements": [], "range": [ 2396, 2398 ], "loc": { "start": { "line": 50, "column": 22 }, "end": { "line": 50, "column": 24 } } }, "range": [ 2382, 2398 ], "loc": { "start": { "line": 50, "column": 8 }, "end": { "line": 50, "column": 24 } } } ], "kind": "var", "range": [ 2378, 2399 ], "loc": { "start": { "line": 50, "column": 4 }, "end": { "line": 50, "column": 25 } } }, { "type": "ForStatement", "init": { "type": "VariableDeclaration", "declarations": [ { "type": "VariableDeclarator", "id": { "type": "Identifier", "name": "_i", "range": [ 2413, 2415 ], "loc": { "start": { "line": 51, "column": 13 }, "end": { "line": 51, "column": 15 } } }, "init": { "type": "Literal", "value": 0, "raw": "0", "range": [ 2418, 2419 ], "loc": { "start": { "line": 51, "column": 18 }, "end": { "line": 51, "column": 19 } } }, "range": [ 2413, 2419 ], "loc": { "start": { "line": 51, "column": 13 }, "end": { "line": 51, "column": 19 } } } ], "kind": "var", "range": [ 2409, 2419 ], "loc": { "start": { "line": 51, "column": 9 }, "end": { "line": 51, "column": 19 } } }, "test": { "type": "BinaryExpression", "operator": "<", "left": { "type": "Identifier", "name": "_i", "range": [ 2421, 2423 ], "loc": { "start": { "line": 51, "column": 21 }, "end": { "line": 51, "column": 23 } } }, "right": { "type": "MemberExpression", "computed": false, "object": { "type": "Identifier", "name": "arguments", "range": [ 2426, 2435 ], "loc": { "start": { "line": 51, "column": 26 }, "end": { "line": 51, "column": 35 } } }, "property": { "type": "Identifier", "name": "length", "range": [ 2436, 2442 ], "loc": { "start": { "line": 51, "column": 36 }, "end": { "line": 51, "column": 42 } } }, "range": [ 2426, 2442 ], "loc": { "start": { "line": 51, "column": 26 }, "end": { "line": 51, "column": 42 } } }, "range": [ 2421, 2442 ], "loc": { "start": { "line": 51, "column": 21 }, "end": { "line": 51, "column": 42 } } }, "update": { "type": "UpdateExpression", "operator": "++", "argument": { "type": "Identifier", "name": "_i", "range": [ 2444, 2446 ], "loc": { "start": { "line": 51, "column": 44 }, "end": { "line": 51, "column": 46 } } }, "prefix": false, "range": [ 2444, 2448 ], "loc": { "start": { "line": 51, "column": 44 }, "end": { "line": 51, "column": 48 } } }, "body": { "type": "BlockStatement", "body": [ { "type": "ExpressionStatement", "expression": { "type": "AssignmentExpression", "operator": "=", "left": { "type": "MemberExpression", "computed": true, "object": { "type": "Identifier", "name": "observables", "range": [ 2460, 2471 ], "loc": { "start": { "line": 52, "column": 8 }, "end": { "line": 52, "column": 19 } } }, "property": { "type": "BinaryExpression", "operator": "-", "left": { "type": "Identifier", "name": "_i", "range": [ 2472, 2474 ], "loc": { "start": { "line": 52, "column": 20 }, "end": { "line": 52, "column": 22 } } }, "right": { "type": "Literal", "value": 0, "raw": "0", "range": [ 2477, 2478 ], "loc": { "start": { "line": 52, "column": 25 }, "end": { "line": 52, "column": 26 } } }, "range": [ 2472, 2478 ], "loc": { "start": { "line": 52, "column": 20 }, "end": { "line": 52, "column": 26 } } }, "range": [ 2460, 2479 ], "loc": { "start": { "line": 52, "column": 8 }, "end": { "line": 52, "column": 27 } } }, "right": { "type": "MemberExpression", "computed": true, "object": { "type": "Identifier", "name": "arguments", "range": [ 2482, 2491 ], "loc": { "start": { "line": 52, "column": 30 }, "end": { "line": 52, "column": 39 } } }, "property": { "type": "Identifier", "name": "_i", "range": [ 2492, 2494 ], "loc": { "start": { "line": 52, "column": 40 }, "end": { "line": 52, "column": 42 } } }, "range": [ 2482, 2495 ], "loc": { "start": { "line": 52, "column": 30 }, "end": { "line": 52, "column": 43 } } }, "range": [ 2460, 2495 ], "loc": { "start": { "line": 52, "column": 8 }, "end": { "line": 52, "column": 43 } } }, "range": [ 2460, 2496 ], "loc": { "start": { "line": 52, "column": 8 }, "end": { "line": 52, "column": 44 } } } ], "range": [ 2450, 2502 ], "loc": { "start": { "line": 51, "column": 50 }, "end": { "line": 53, "column": 5 } } }, "range": [ 2404, 2502 ], "loc": { "start": { "line": 51, "column": 4 }, "end": { "line": 53, "column": 5 } } }, { "type": "VariableDeclaration", "declarations": [ { "type": "VariableDeclarator", "id": { "type": "Identifier", "name": "project", "range": [ 2511, 2518 ], "loc": { "start": { "line": 54, "column": 8 }, "end": { "line": 54, "column": 15 } } }, "init": { "type": "Literal", "value": null, "raw": "null", "range": [ 2521, 2525 ], "loc": { "start": { "line": 54, "column": 18 }, "end": { "line": 54, "column": 22 } } }, "range": [ 2511, 2525 ], "loc": { "start": { "line": 54, "column": 8 }, "end": { "line": 54, "column": 22 } } } ], "kind": "var", "range": [ 2507, 2526 ], "loc": { "start": { "line": 54, "column": 4 }, "end": { "line": 54, "column": 23 } } }, { "type": "VariableDeclaration", "declarations": [ { "type": "VariableDeclarator", "id": { "type": "Identifier", "name": "scheduler", "range": [ 2535, 2544 ], "loc": { "start": { "line": 55, "column": 8 }, "end": { "line": 55, "column": 17 } } }, "init": { "type": "Literal", "value": null, "raw": "null", "range": [ 2547, 2551 ], "loc": { "start": { "line": 55, "column": 20 }, "end": { "line": 55, "column": 24 } } }, "range": [ 2535, 2551 ], "loc": { "start": { "line": 55, "column": 8 }, "end": { "line": 55, "column": 24 } } } ], "kind": "var", "range": [ 2531, 2552 ], "loc": { "start": { "line": 55, "column": 4 }, "end": { "line": 55, "column": 25 } } }, { "type": "IfStatement", "test": { "type": "CallExpression", "callee": { "type": "Identifier", "name": "isScheduler", "range": [ 2561, 2572 ], "loc": { "start": { "line": 56, "column": 8 }, "end": { "line": 56, "column": 19 } } }, "arguments": [ { "type": "MemberExpression", "computed": true, "object": { "type": "Identifier", "name": "observables", "range": [ 2573, 2584 ], "loc": { "start": { "line": 56, "column": 20 }, "end": { "line": 56, "column": 31 } } }, "property": { "type": "BinaryExpression", "operator": "-", "left": { "type": "MemberExpression", "computed": false, "object": { "type": "Identifier", "name": "observables", "range": [ 2585, 2596 ], "loc": { "start": { "line": 56, "column": 32 }, "end": { "line": 56, "column": 43 } } }, "property": { "type": "Identifier", "name": "length", "range": [ 2597, 2603 ], "loc": { "start": { "line": 56, "column": 44 }, "end": { "line": 56, "column": 50 } } }, "range": [ 2585, 2603 ], "loc": { "start": { "line": 56, "column": 32 }, "end": { "line": 56, "column": 50 } } }, "right": { "type": "Literal", "value": 1, "raw": "1", "range": [ 2606, 2607 ], "loc": { "start": { "line": 56, "column": 53 }, "end": { "line": 56, "column": 54 } } }, "range": [ 2585, 2607 ], "loc": { "start": { "line": 56, "column": 32 }, "end": { "line": 56, "column": 54 } } }, "range": [ 2573, 2608 ], "loc": { "start": { "line": 56, "column": 20 }, "end": { "line": 56, "column": 55 } } } ], "range": [ 2561, 2609 ], "loc": { "start": { "line": 56, "column": 8 }, "end": { "line": 56, "column": 56 } } }, "consequent": { "type": "BlockStatement", "body": [ { "type": "ExpressionStatement", "expression": { "type": "AssignmentExpression", "operator": "=", "left": { "type": "Identifier", "name": "scheduler", "range": [ 2621, 2630 ], "loc": { "start": { "line": 57, "column": 8 }, "end": { "line": 57, "column": 17 } } }, "right": { "type": "CallExpression", "callee": { "type": "MemberExpression", "computed": false, "object": { "type": "Identifier", "name": "observables", "range": [ 2633, 2644 ], "loc": { "start": { "line": 57, "column": 20 }, "end": { "line": 57, "column": 31 } } }, "property": { "type": "Identifier", "name": "pop", "range": [ 2645, 2648 ], "loc": { "start": { "line": 57, "column": 32 }, "end": { "line": 57, "column": 35 } } }, "range": [ 2633, 2648 ], "loc": { "start": { "line": 57, "column": 20 }, "end": { "line": 57, "column": 35 } } }, "arguments": [], "range": [ 2633, 2650 ], "loc": { "start": { "line": 57, "column": 20 }, "end": { "line": 57, "column": 37 } } }, "range": [ 2621, 2650 ], "loc": { "start": { "line": 57, "column": 8 }, "end": { "line": 57, "column": 37 } } }, "range": [ 2621, 2651 ], "loc": { "start": { "line": 57, "column": 8 }, "end": { "line": 57, "column": 38 } } } ], "range": [ 2611, 2657 ], "loc": { "start": { "line": 56, "column": 58 }, "end": { "line": 58, "column": 5 } } }, "alternate": null, "range": [ 2557, 2657 ], "loc": { "start": { "line": 56, "column": 4 }, "end": { "line": 58, "column": 5 } } }, { "type": "IfStatement", "test": { "type": "BinaryExpression", "operator": "===", "left": { "type": "UnaryExpression", "operator": "typeof", "argument": { "type": "MemberExpression", "computed": true, "object": { "type": "Identifier", "name": "observables", "range": [ 2673, 2684 ], "loc": { "start": { "line": 59, "column": 15 }, "end": { "line": 59, "column": 26 } } }, "property": { "type": "BinaryExpression", "operator": "-", "left": { "type": "MemberExpression", "computed": false, "object": { "type": "Identifier", "name": "observables", "range": [ 2685, 2696 ], "loc": { "start": { "line": 59, "column": 27 }, "end": { "line": 59, "column": 38 } } }, "property": { "type": "Identifier", "name": "length", "range": [ 2697, 2703 ], "loc": { "start": { "line": 59, "column": 39 }, "end": { "line": 59, "column": 45 } } }, "range": [ 2685, 2703 ], "loc": { "start": { "line": 59, "column": 27 }, "end": { "line": 59, "column": 45 } } }, "right": { "type": "Literal", "value": 1, "raw": "1", "range": [ 2706, 2707 ], "loc": { "start": { "line": 59, "column": 48 }, "end": { "line": 59, "column": 49 } } }, "range": [ 2685, 2707 ], "loc": { "start": { "line": 59, "column": 27 }, "end": { "line": 59, "column": 49 } } }, "range": [ 2673, 2708 ], "loc": { "start": { "line": 59, "column": 15 }, "end": { "line": 59, "column": 50 } } }, "prefix": true, "range": [ 2666, 2708 ], "loc": { "start": { "line": 59, "column": 8 }, "end": { "line": 59, "column": 50 } } }, "right": { "type": "Literal", "value": "function", "raw": "'function'", "range": [ 2713, 2723 ], "loc": { "start": { "line": 59, "column": 55 }, "end": { "line": 59, "column": 65 } } }, "range": [ 2666, 2723 ], "loc": { "start": { "line": 59, "column": 8 }, "end": { "line": 59, "column": 65 } } }, "consequent": { "type": "BlockStatement", "body": [ { "type": "ExpressionStatement", "expression": { "type": "AssignmentExpression", "operator": "=", "left": { "type": "Identifier", "name": "project", "range": [ 2735, 2742 ], "loc": { "start": { "line": 60, "column": 8 }, "end": { "line": 60, "column": 15 } } }, "right": { "type": "CallExpression", "callee": { "type": "MemberExpression", "computed": false, "object": { "type": "Identifier", "name": "observables", "range": [ 2745, 2756 ], "loc": { "start": { "line": 60, "column": 18 }, "end": { "line": 60, "column": 29 } } }, "property": { "type": "Identifier", "name": "pop", "range": [ 2757, 2760 ], "loc": { "start": { "line": 60, "column": 30 }, "end": { "line": 60, "column": 33 } } }, "range": [ 2745, 2760 ], "loc": { "start": { "line": 60, "column": 18 }, "end": { "line": 60, "column": 33 } } }, "arguments": [], "range": [