UNPKG

@reactivex/rxjs

Version:

Reactive Extensions for modern JavaScript

1,389 lines (1,388 loc) 138 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 } }, "trailingComments": [ { "type": "Block", "value": "*\n * Emits values emitted by the source Observable so long as each value satisfies\n * the given `predicate`, and then completes as soon as this `predicate` is not\n * satisfied.\n *\n * <span class=\"informal\">Takes values from the source only while they pass the\n * condition given. When the first value does not satisfy, it completes.</span>\n *\n * <img src=\"./img/takeWhile.png\" width=\"100%\">\n *\n * `takeWhile` subscribes and begins mirroring the source Observable. Each value\n * emitted on the source is given to the `predicate` function which returns a\n * boolean, representing a condition to be satisfied by the source values. The\n * output Observable emits the source values until such time as the `predicate`\n * returns false, at which point `takeWhile` stops mirroring the source\n * Observable and completes the output Observable.\n *\n * @example <caption>Emit click events only while the clientX property is greater than 200</caption>\n * var clicks = Rx.Observable.fromEvent(document, 'click');\n * var result = clicks.takeWhile(ev => ev.clientX > 200);\n * result.subscribe(x => console.log(x));\n *\n * @see {@link take}\n * @see {@link takeLast}\n * @see {@link takeUntil}\n * @see {@link skip}\n *\n * @param {function(value: T, index: number): boolean} predicate A function that\n * evaluates a value emitted by the source Observable and returns a boolean.\n * Also takes the (zero-based) index as the second argument.\n * @return {Observable<T>} An Observable that emits the values from the source\n * Observable so long as each value satisfies the condition defined by the\n * `predicate`, then completes.\n * @method takeWhile\n * @owner Observable\n ", "range": [ 44, 1694 ], "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 37, "column": 3 } } } ] }, { "type": "ExportNamedDeclaration", "declaration": { "type": "FunctionDeclaration", "id": { "type": "Identifier", "name": "takeWhile", "range": [ 1711, 1720 ], "loc": { "start": { "line": 38, "column": 16 }, "end": { "line": 38, "column": 25 } } }, "params": [ { "type": "Identifier", "name": "predicate", "range": [ 1721, 1730 ], "loc": { "start": { "line": 38, "column": 26 }, "end": { "line": 38, "column": 35 } } } ], "body": { "type": "BlockStatement", "body": [ { "type": "ReturnStatement", "argument": { "type": "CallExpression", "callee": { "type": "MemberExpression", "computed": false, "object": { "type": "ThisExpression", "range": [ 1745, 1749 ], "loc": { "start": { "line": 39, "column": 11 }, "end": { "line": 39, "column": 15 } } }, "property": { "type": "Identifier", "name": "lift", "range": [ 1750, 1754 ], "loc": { "start": { "line": 39, "column": 16 }, "end": { "line": 39, "column": 20 } } }, "range": [ 1745, 1754 ], "loc": { "start": { "line": 39, "column": 11 }, "end": { "line": 39, "column": 20 } } }, "arguments": [ { "type": "NewExpression", "callee": { "type": "Identifier", "name": "TakeWhileOperator", "range": [ 1759, 1776 ], "loc": { "start": { "line": 39, "column": 25 }, "end": { "line": 39, "column": 42 } } }, "arguments": [ { "type": "Identifier", "name": "predicate", "range": [ 1777, 1786 ], "loc": { "start": { "line": 39, "column": 43 }, "end": { "line": 39, "column": 52 } } } ], "range": [ 1755, 1787 ], "loc": { "start": { "line": 39, "column": 21 }, "end": { "line": 39, "column": 53 } } } ], "range": [ 1745, 1788 ], "loc": { "start": { "line": 39, "column": 11 }, "end": { "line": 39, "column": 54 } } }, "range": [ 1738, 1789 ], "loc": { "start": { "line": 39, "column": 4 }, "end": { "line": 39, "column": 55 } } } ], "range": [ 1732, 1791 ], "loc": { "start": { "line": 38, "column": 37 }, "end": { "line": 40, "column": 1 } } }, "generator": false, "expression": false, "range": [ 1702, 1791 ], "loc": { "start": { "line": 38, "column": 7 }, "end": { "line": 40, "column": 1 } }, "leadingComments": [ { "type": "Block", "value": "*\n * Emits values emitted by the source Observable so long as each value satisfies\n * the given `predicate`, and then completes as soon as this `predicate` is not\n * satisfied.\n *\n * <span class=\"informal\">Takes values from the source only while they pass the\n * condition given. When the first value does not satisfy, it completes.</span>\n *\n * <img src=\"./img/takeWhile.png\" width=\"100%\">\n *\n * `takeWhile` subscribes and begins mirroring the source Observable. Each value\n * emitted on the source is given to the `predicate` function which returns a\n * boolean, representing a condition to be satisfied by the source values. The\n * output Observable emits the source values until such time as the `predicate`\n * returns false, at which point `takeWhile` stops mirroring the source\n * Observable and completes the output Observable.\n *\n * @example <caption>Emit click events only while the clientX property is greater than 200</caption>\n * var clicks = Rx.Observable.fromEvent(document, 'click');\n * var result = clicks.takeWhile(ev => ev.clientX > 200);\n * result.subscribe(x => console.log(x));\n *\n * @see {@link take}\n * @see {@link takeLast}\n * @see {@link takeUntil}\n * @see {@link skip}\n *\n * @param {function(value: T, index: number): boolean} predicate A function that\n * evaluates a value emitted by the source Observable and returns a boolean.\n * Also takes the (zero-based) index as the second argument.\n * @return {Observable<T>} An Observable that emits the values from the source\n * Observable so long as each value satisfies the condition defined by the\n * `predicate`, then completes.\n * @method takeWhile\n * @owner Observable\n ", "range": [ 44, 1694 ], "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 37, "column": 3 } } } ], "trailingComments": [] }, "specifiers": [], "source": null, "range": [ 1695, 1791 ], "loc": { "start": { "line": 38, "column": 0 }, "end": { "line": 40, "column": 1 } }, "leadingComments": [ { "type": "Block", "value": "*\n * Emits values emitted by the source Observable so long as each value satisfies\n * the given `predicate`, and then completes as soon as this `predicate` is not\n * satisfied.\n *\n * <span class=\"informal\">Takes values from the source only while they pass the\n * condition given. When the first value does not satisfy, it completes.</span>\n *\n * <img src=\"./img/takeWhile.png\" width=\"100%\">\n *\n * `takeWhile` subscribes and begins mirroring the source Observable. Each value\n * emitted on the source is given to the `predicate` function which returns a\n * boolean, representing a condition to be satisfied by the source values. The\n * output Observable emits the source values until such time as the `predicate`\n * returns false, at which point `takeWhile` stops mirroring the source\n * Observable and completes the output Observable.\n *\n * @example <caption>Emit click events only while the clientX property is greater than 200</caption>\n * var clicks = Rx.Observable.fromEvent(document, 'click');\n * var result = clicks.takeWhile(ev => ev.clientX > 200);\n * result.subscribe(x => console.log(x));\n *\n * @see {@link take}\n * @see {@link takeLast}\n * @see {@link takeUntil}\n * @see {@link skip}\n *\n * @param {function(value: T, index: number): boolean} predicate A function that\n * evaluates a value emitted by the source Observable and returns a boolean.\n * Also takes the (zero-based) index as the second argument.\n * @return {Observable<T>} An Observable that emits the values from the source\n * Observable so long as each value satisfies the condition defined by the\n * `predicate`, then completes.\n * @method takeWhile\n * @owner Observable\n ", "range": [ 44, 1694 ], "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 37, "column": 3 } } } ] }, { "type": "VariableDeclaration", "declarations": [ { "type": "VariableDeclarator", "id": { "type": "Identifier", "name": "TakeWhileOperator", "range": [ 1796, 1813 ], "loc": { "start": { "line": 41, "column": 4 }, "end": { "line": 41, "column": 21 } } }, "init": { "type": "CallExpression", "callee": { "type": "FunctionExpression", "id": null, "params": [], "body": { "type": "BlockStatement", "body": [ { "type": "FunctionDeclaration", "id": { "type": "Identifier", "name": "TakeWhileOperator", "range": [ 1844, 1861 ], "loc": { "start": { "line": 42, "column": 13 }, "end": { "line": 42, "column": 30 } } }, "params": [ { "type": "Identifier", "name": "predicate", "range": [ 1862, 1871 ], "loc": { "start": { "line": 42, "column": 31 }, "end": { "line": 42, "column": 40 } } } ], "body": { "type": "BlockStatement", "body": [ { "type": "ExpressionStatement", "expression": { "type": "AssignmentExpression", "operator": "=", "left": { "type": "MemberExpression", "computed": false, "object": { "type": "ThisExpression", "range": [ 1883, 1887 ], "loc": { "start": { "line": 43, "column": 8 }, "end": { "line": 43, "column": 12 } } }, "property": { "type": "Identifier", "name": "predicate", "range": [ 1888, 1897 ], "loc": { "start": { "line": 43, "column": 13 }, "end": { "line": 43, "column": 22 } } }, "range": [ 1883, 1897 ], "loc": { "start": { "line": 43, "column": 8 }, "end": { "line": 43, "column": 22 } } }, "right": { "type": "Identifier", "name": "predicate", "range": [ 1900, 1909 ], "loc": { "start": { "line": 43, "column": 25 }, "end": { "line": 43, "column": 34 } } }, "range": [ 1883, 1909 ], "loc": { "start": { "line": 43, "column": 8 }, "end": { "line": 43, "column": 34 } } }, "range": [ 1883, 1910 ], "loc": { "start": { "line": 43, "column": 8 }, "end": { "line": 43, "column": 35 } } } ], "range": [ 1873, 1916 ], "loc": { "start": { "line": 42, "column": 42 }, "end": { "line": 44, "column": 5 } } }, "generator": false, "expression": false, "range": [ 1835, 1916 ], "loc": { "start": { "line": 42, "column": 4 }, "end": { "line": 44, "column": 5 } } }, { "type": "ExpressionStatement", "expression": { "type": "AssignmentExpression", "operator": "=", "left": { "type": "MemberExpression", "computed": false, "object": { "type": "MemberExpression", "computed": false, "object": { "type": "Identifier", "name": "TakeWhileOperator", "range": [ 1921, 1938 ], "loc": { "start": { "line": 45, "column": 4 }, "end": { "line": 45, "column": 21 } } }, "property": { "type": "Identifier", "name": "prototype", "range": [ 1939, 1948 ], "loc": { "start": { "line": 45, "column": 22 }, "end": { "line": 45, "column": 31 } } }, "range": [ 1921, 1948 ], "loc": { "start": { "line": 45, "column": 4 }, "end": { "line": 45, "column": 31 } } }, "property": { "type": "Identifier", "name": "call", "range": [ 1949, 1953 ], "loc": { "start": { "line": 45, "column": 32 }, "end": { "line": 45, "column": 36 } } }, "range": [ 1921, 1953 ], "loc": { "start": { "line": 45, "column": 4 }, "end": { "line": 45, "column": 36 } } }, "right": { "type": "FunctionExpression", "id": null, "params": [ { "type": "Identifier", "name": "subscriber", "range": [ 1966, 1976 ], "loc": { "start": { "line": 45, "column": 49 }, "end": { "line": 45, "column": 59 } } }, { "type": "Identifier", "name": "source", "range": [ 1978, 1984 ], "loc": { "start": { "line": 45, "column": 61 }, "end": { "line": 45, "column": 67 } } } ], "body": { "type": "BlockStatement", "body": [ { "type": "ReturnStatement", "argument": { "type": "CallExpression", "callee": { "type": "MemberExpression", "computed": false, "object": { "type": "Identifier", "name": "source", "range": [ 2003, 2009 ], "loc": { "start": { "line": 46, "column": 15 }, "end": { "line": 46, "column": 21 } } }, "property": { "type": "Identifier", "name": "_subscribe", "range": [ 2010, 2020 ], "loc": { "start": { "line": 46, "column": 22 }, "end": { "line": 46, "column": 32 } } }, "range": [ 2003, 2020 ], "loc": { "start": { "line": 46, "column": 15 }, "end": { "line": 46, "column": 32 } } }, "arguments": [ { "type": "NewExpression", "callee": { "type": "Identifier", "name": "TakeWhileSubscriber", "range": [ 2025, 2044 ], "loc": { "start": { "line": 46, "column": 37 }, "end": { "line": 46, "column": 56 } } }, "arguments": [ { "type": "Identifier", "name": "subscriber", "range": [ 2045, 2055 ], "loc": { "start": { "line": 46, "column": 57 }, "end": { "line": 46, "column": 67 } } }, { "type": "MemberExpression", "computed": false, "object": { "type": "ThisExpression", "range": [ 2057, 2061 ], "loc": { "start": { "line": 46, "column": 69 }, "end": { "line": 46, "column": 73 } } }, "property": { "type": "Identifier", "name": "predicate", "range": [ 2062, 2071 ], "loc": { "start": { "line": 46, "column": 74 }, "end": { "line": 46, "column": 83 } } }, "range": [ 2057, 2071 ], "loc": { "start": { "line": 46, "column": 69 }, "end": { "line": 46, "column": 83 } } } ], "range": [ 2021, 2072 ], "loc": { "start": { "line": 46, "column": 33 }, "end": { "line": 46, "column": 84 } } } ], "range": [ 2003, 2073 ], "loc": { "start": { "line": 46, "column": 15 }, "end": { "line": 46, "column": 85 } } }, "range": [ 1996, 2074 ], "loc": { "start": { "line": 46, "column": 8 }, "end": { "line": 46, "column": 86 } } } ], "range": [ 1986, 2080 ], "loc": { "start": { "line": 45, "column": 69 }, "end": { "line": 47, "column": 5 } } }, "generator": false, "expression": false, "range": [ 1956, 2080 ], "loc": { "start": { "line": 45, "column": 39 }, "end": { "line": 47, "column": 5 } } }, "range": [ 1921, 2080 ], "loc": { "start": { "line": 45, "column": 4 }, "end": { "line": 47, "column": 5 } } }, "range": [ 1921, 2081 ], "loc": { "start": { "line": 45, "column": 4 }, "end": { "line": 47, "column": 6 } } }, { "type": "ReturnStatement", "argument": { "type": "Identifier", "name": "TakeWhileOperator", "range": [ 2093, 2110 ], "loc": { "start": { "line": 48, "column": 11 }, "end": { "line": 48, "column": 28 } } }, "range": [ 2086, 2111 ], "loc": { "start": { "line": 48, "column": 4 }, "end": { "line": 48, "column": 29 } } } ], "range": [ 1829, 2113 ], "loc": { "start": { "line": 41, "column": 37 }, "end": { "line": 49, "column": 1 } } }, "generator": false, "expression": false, "range": [ 1817, 2113 ], "loc": { "start": { "line": 41, "column": 25 }, "end": { "line": 49, "column": 1 } } }, "arguments": [], "range": [ 1817, 2115 ], "loc": { "start": { "line": 41, "column": 25 }, "end": { "line": 49, "column": 3 } } }, "range": [ 1796, 2116 ], "loc": { "start": { "line": 41, "column": 4 }, "end": { "line": 49, "column": 4 } } } ], "kind": "var", "range": [ 1792, 2117 ], "loc": { "start": { "line": 41, "column": 0 }, "end": { "line": 49, "column": 5 } }, "trailingComments": [ { "type": "Block", "value": "*\n * We need this JSDoc comment for affecting ESDoc.\n * @ignore\n * @extends {Ignored}\n ", "range": [ 2118, 2209 ], "loc": { "start": { "line": 50, "column": 0 }, "end": { "line": 54, "column": 3 } } } ] }, { "type": "VariableDeclaration", "declarations": [ { "type": "VariableDeclarator", "id": { "type": "Identifier", "name": "TakeWhileSubscriber", "range": [ 2214, 2233 ], "loc": { "start": { "line": 55, "column": 4 }, "end": { "line": 55, "column": 23 } } }, "init": { "type": "CallExpression", "callee": { "type": "FunctionExpression", "id": null, "params": [ { "type": "Identifier", "name": "_super", "range": [ 2247, 2253 ], "loc": { "start": { "line": 55, "column": 37 }, "end": { "line": 55, "column": 43 } } } ], "body": { "type": "BlockStatement", "body": [ { "type": "ExpressionStatement", "expression": { "type": "CallExpression", "callee": { "type": "Identifier", "name": "__extends", "range": [ 2261, 2270 ], "loc": { "start": { "line": 56, "column": 4 }, "end": { "line": 56, "column": 13 } } }, "arguments": [ { "type": "Identifier", "name": "TakeWhileSubscriber", "range": [ 2271, 2290 ], "loc": { "start": { "line": 56, "column": 14 }, "end": { "line": 56, "column": 33 } } }, { "type": "Identifier", "name": "_super", "range": [ 2292, 2298 ], "loc": { "start": { "line": 56, "column": 35 }, "end": { "line": 56, "column": 41 } } } ], "range": [ 2261, 2299 ], "loc": { "start": { "line": 56, "column": 4 }, "end": { "line": 56, "column": 42 } } }, "range": [ 2261, 2300 ], "loc": { "start": { "line": 56, "column": 4 }, "end": { "line": 56, "column": 43 } } }, { "type": "FunctionDeclaration", "id": { "type": "Identifier", "name": "TakeWhileSubscriber", "range": [ 2314, 2333 ], "loc": { "start": { "line": 57, "column": 13 }, "end": { "line": 57, "column": 32 } } }, "params": [ { "type": "Identifier", "name": "destination", "range": [ 2334, 2345 ], "loc": { "start": { "line": 57, "column": 33 }, "end": { "line": 57, "column": 44 } } }, { "type": "Identifier", "name": "predicate", "range": [ 2347, 2356 ], "loc": { "start": { "line": 57, "column": 46 }, "end": { "line": 57, "column": 55 } } } ], "body": { "type": "BlockStatement", "body": [ { "type": "ExpressionStatement", "expression": { "type": "CallExpression", "callee": { "type": "MemberExpression", "computed": false, "object": { "type": "Identifier", "name": "_super", "range": [ 2368, 2374 ], "loc": { "start": { "line": 58, "column": 8 }, "end": { "line": 58, "column": 14 } } }, "property": { "type": "Identifier", "name": "call", "range": [ 2375, 2379 ], "loc": { "start": { "line": 58, "column": 15 }, "end": { "line": 58, "column": 19 } }