UNPKG

@reactivex/rxjs

Version:

Reactive Extensions for modern JavaScript

1,545 lines (1,544 loc) 291 kB
{ "type": "Program", "body": [ { "type": "ImportDeclaration", "specifiers": [ { "type": "ImportSpecifier", "local": { "type": "Identifier", "name": "Subject", "range": [ 9, 16 ], "loc": { "start": { "line": 1, "column": 9 }, "end": { "line": 1, "column": 16 } } }, "imported": { "type": "Identifier", "name": "Subject", "range": [ 9, 16 ], "loc": { "start": { "line": 1, "column": 9 }, "end": { "line": 1, "column": 16 } } }, "range": [ 9, 16 ], "loc": { "start": { "line": 1, "column": 9 }, "end": { "line": 1, "column": 16 } } } ], "source": { "type": "Literal", "value": "../Subject", "raw": "'../Subject'", "range": [ 24, 36 ], "loc": { "start": { "line": 1, "column": 24 }, "end": { "line": 1, "column": 36 } } }, "range": [ 0, 37 ], "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 1, "column": 37 } } }, { "type": "ImportDeclaration", "specifiers": [ { "type": "ImportSpecifier", "local": { "type": "Identifier", "name": "tryCatch", "range": [ 47, 55 ], "loc": { "start": { "line": 2, "column": 9 }, "end": { "line": 2, "column": 17 } } }, "imported": { "type": "Identifier", "name": "tryCatch", "range": [ 47, 55 ], "loc": { "start": { "line": 2, "column": 9 }, "end": { "line": 2, "column": 17 } } }, "range": [ 47, 55 ], "loc": { "start": { "line": 2, "column": 9 }, "end": { "line": 2, "column": 17 } } } ], "source": { "type": "Literal", "value": "../util/tryCatch", "raw": "'../util/tryCatch'", "range": [ 63, 81 ], "loc": { "start": { "line": 2, "column": 25 }, "end": { "line": 2, "column": 43 } } }, "range": [ 38, 82 ], "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 2, "column": 44 } } }, { "type": "ImportDeclaration", "specifiers": [ { "type": "ImportSpecifier", "local": { "type": "Identifier", "name": "errorObject", "range": [ 92, 103 ], "loc": { "start": { "line": 3, "column": 9 }, "end": { "line": 3, "column": 20 } } }, "imported": { "type": "Identifier", "name": "errorObject", "range": [ 92, 103 ], "loc": { "start": { "line": 3, "column": 9 }, "end": { "line": 3, "column": 20 } } }, "range": [ 92, 103 ], "loc": { "start": { "line": 3, "column": 9 }, "end": { "line": 3, "column": 20 } } } ], "source": { "type": "Literal", "value": "../util/errorObject", "raw": "'../util/errorObject'", "range": [ 111, 132 ], "loc": { "start": { "line": 3, "column": 28 }, "end": { "line": 3, "column": 49 } } }, "range": [ 83, 133 ], "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 3, "column": 50 } } }, { "type": "ImportDeclaration", "specifiers": [ { "type": "ImportSpecifier", "local": { "type": "Identifier", "name": "OuterSubscriber", "range": [ 143, 158 ], "loc": { "start": { "line": 4, "column": 9 }, "end": { "line": 4, "column": 24 } } }, "imported": { "type": "Identifier", "name": "OuterSubscriber", "range": [ 143, 158 ], "loc": { "start": { "line": 4, "column": 9 }, "end": { "line": 4, "column": 24 } } }, "range": [ 143, 158 ], "loc": { "start": { "line": 4, "column": 9 }, "end": { "line": 4, "column": 24 } } } ], "source": { "type": "Literal", "value": "../OuterSubscriber", "raw": "'../OuterSubscriber'", "range": [ 166, 186 ], "loc": { "start": { "line": 4, "column": 32 }, "end": { "line": 4, "column": 52 } } }, "range": [ 134, 187 ], "loc": { "start": { "line": 4, "column": 0 }, "end": { "line": 4, "column": 53 } } }, { "type": "ImportDeclaration", "specifiers": [ { "type": "ImportSpecifier", "local": { "type": "Identifier", "name": "subscribeToResult", "range": [ 197, 214 ], "loc": { "start": { "line": 5, "column": 9 }, "end": { "line": 5, "column": 26 } } }, "imported": { "type": "Identifier", "name": "subscribeToResult", "range": [ 197, 214 ], "loc": { "start": { "line": 5, "column": 9 }, "end": { "line": 5, "column": 26 } } }, "range": [ 197, 214 ], "loc": { "start": { "line": 5, "column": 9 }, "end": { "line": 5, "column": 26 } } } ], "source": { "type": "Literal", "value": "../util/subscribeToResult", "raw": "'../util/subscribeToResult'", "range": [ 222, 249 ], "loc": { "start": { "line": 5, "column": 34 }, "end": { "line": 5, "column": 61 } } }, "range": [ 188, 250 ], "loc": { "start": { "line": 5, "column": 0 }, "end": { "line": 5, "column": 62 } }, "trailingComments": [ { "type": "Block", "value": "*\n * Branch out the source Observable values as a nested Observable using a\n * factory function of closing Observables to determine when to start a new\n * window.\n *\n * <span class=\"informal\">It's like {@link bufferWhen}, but emits a nested\n * Observable instead of an array.</span>\n *\n * <img src=\"./img/windowWhen.png\" width=\"100%\">\n *\n * Returns an Observable that emits windows of items it collects from the source\n * Observable. The output Observable emits connected, non-overlapping windows.\n * It emits the current window and opens a new one whenever the Observable\n * produced by the specified `closingSelector` function emits an item. The first\n * window is opened immediately when subscribing to the output Observable.\n *\n * @example <caption>Emit only the first two clicks events in every window of [1-5] random seconds</caption>\n * var clicks = Rx.Observable.fromEvent(document, 'click');\n * var result = clicks\n * .windowWhen(() => Rx.Observable.interval(1000 + Math.random() * 4000))\n * .map(win => win.take(2)) // each window has at most 2 emissions\n * .mergeAll(); // flatten the Observable-of-Observables\n * result.subscribe(x => console.log(x));\n *\n * @see {@link window}\n * @see {@link windowCount}\n * @see {@link windowTime}\n * @see {@link windowToggle}\n * @see {@link bufferWhen}\n *\n * @param {function(): Observable} closingSelector A function that takes no\n * arguments and returns an Observable that signals (on either `next` or\n * `complete`) when to close the previous window and start a new one.\n * @return {Observable<Observable<T>>} An observable of windows, which in turn\n * are Observables.\n * @method windowWhen\n * @owner Observable\n ", "range": [ 251, 1927 ], "loc": { "start": { "line": 6, "column": 0 }, "end": { "line": 43, "column": 3 } } } ] }, { "type": "ExportNamedDeclaration", "declaration": { "type": "FunctionDeclaration", "id": { "type": "Identifier", "name": "windowWhen", "range": [ 1944, 1954 ], "loc": { "start": { "line": 44, "column": 16 }, "end": { "line": 44, "column": 26 } } }, "params": [ { "type": "Identifier", "name": "closingSelector", "range": [ 1955, 1970 ], "loc": { "start": { "line": 44, "column": 27 }, "end": { "line": 44, "column": 42 } } } ], "body": { "type": "BlockStatement", "body": [ { "type": "ReturnStatement", "argument": { "type": "CallExpression", "callee": { "type": "MemberExpression", "computed": false, "object": { "type": "ThisExpression", "range": [ 1985, 1989 ], "loc": { "start": { "line": 45, "column": 11 }, "end": { "line": 45, "column": 15 } } }, "property": { "type": "Identifier", "name": "lift", "range": [ 1990, 1994 ], "loc": { "start": { "line": 45, "column": 16 }, "end": { "line": 45, "column": 20 } } }, "range": [ 1985, 1994 ], "loc": { "start": { "line": 45, "column": 11 }, "end": { "line": 45, "column": 20 } } }, "arguments": [ { "type": "NewExpression", "callee": { "type": "Identifier", "name": "WindowOperator", "range": [ 1999, 2013 ], "loc": { "start": { "line": 45, "column": 25 }, "end": { "line": 45, "column": 39 } } }, "arguments": [ { "type": "Identifier", "name": "closingSelector", "range": [ 2014, 2029 ], "loc": { "start": { "line": 45, "column": 40 }, "end": { "line": 45, "column": 55 } } } ], "range": [ 1995, 2030 ], "loc": { "start": { "line": 45, "column": 21 }, "end": { "line": 45, "column": 56 } } } ], "range": [ 1985, 2031 ], "loc": { "start": { "line": 45, "column": 11 }, "end": { "line": 45, "column": 57 } } }, "range": [ 1978, 2032 ], "loc": { "start": { "line": 45, "column": 4 }, "end": { "line": 45, "column": 58 } } } ], "range": [ 1972, 2034 ], "loc": { "start": { "line": 44, "column": 44 }, "end": { "line": 46, "column": 1 } } }, "generator": false, "expression": false, "range": [ 1935, 2034 ], "loc": { "start": { "line": 44, "column": 7 }, "end": { "line": 46, "column": 1 } }, "leadingComments": [ { "type": "Block", "value": "*\n * Branch out the source Observable values as a nested Observable using a\n * factory function of closing Observables to determine when to start a new\n * window.\n *\n * <span class=\"informal\">It's like {@link bufferWhen}, but emits a nested\n * Observable instead of an array.</span>\n *\n * <img src=\"./img/windowWhen.png\" width=\"100%\">\n *\n * Returns an Observable that emits windows of items it collects from the source\n * Observable. The output Observable emits connected, non-overlapping windows.\n * It emits the current window and opens a new one whenever the Observable\n * produced by the specified `closingSelector` function emits an item. The first\n * window is opened immediately when subscribing to the output Observable.\n *\n * @example <caption>Emit only the first two clicks events in every window of [1-5] random seconds</caption>\n * var clicks = Rx.Observable.fromEvent(document, 'click');\n * var result = clicks\n * .windowWhen(() => Rx.Observable.interval(1000 + Math.random() * 4000))\n * .map(win => win.take(2)) // each window has at most 2 emissions\n * .mergeAll(); // flatten the Observable-of-Observables\n * result.subscribe(x => console.log(x));\n *\n * @see {@link window}\n * @see {@link windowCount}\n * @see {@link windowTime}\n * @see {@link windowToggle}\n * @see {@link bufferWhen}\n *\n * @param {function(): Observable} closingSelector A function that takes no\n * arguments and returns an Observable that signals (on either `next` or\n * `complete`) when to close the previous window and start a new one.\n * @return {Observable<Observable<T>>} An observable of windows, which in turn\n * are Observables.\n * @method windowWhen\n * @owner Observable\n ", "range": [ 251, 1927 ], "loc": { "start": { "line": 6, "column": 0 }, "end": { "line": 43, "column": 3 } } } ], "trailingComments": [] }, "specifiers": [], "source": null, "range": [ 1928, 2034 ], "loc": { "start": { "line": 44, "column": 0 }, "end": { "line": 46, "column": 1 } }, "leadingComments": [ { "type": "Block", "value": "*\n * Branch out the source Observable values as a nested Observable using a\n * factory function of closing Observables to determine when to start a new\n * window.\n *\n * <span class=\"informal\">It's like {@link bufferWhen}, but emits a nested\n * Observable instead of an array.</span>\n *\n * <img src=\"./img/windowWhen.png\" width=\"100%\">\n *\n * Returns an Observable that emits windows of items it collects from the source\n * Observable. The output Observable emits connected, non-overlapping windows.\n * It emits the current window and opens a new one whenever the Observable\n * produced by the specified `closingSelector` function emits an item. The first\n * window is opened immediately when subscribing to the output Observable.\n *\n * @example <caption>Emit only the first two clicks events in every window of [1-5] random seconds</caption>\n * var clicks = Rx.Observable.fromEvent(document, 'click');\n * var result = clicks\n * .windowWhen(() => Rx.Observable.interval(1000 + Math.random() * 4000))\n * .map(win => win.take(2)) // each window has at most 2 emissions\n * .mergeAll(); // flatten the Observable-of-Observables\n * result.subscribe(x => console.log(x));\n *\n * @see {@link window}\n * @see {@link windowCount}\n * @see {@link windowTime}\n * @see {@link windowToggle}\n * @see {@link bufferWhen}\n *\n * @param {function(): Observable} closingSelector A function that takes no\n * arguments and returns an Observable that signals (on either `next` or\n * `complete`) when to close the previous window and start a new one.\n * @return {Observable<Observable<T>>} An observable of windows, which in turn\n * are Observables.\n * @method windowWhen\n * @owner Observable\n ", "range": [ 251, 1927 ], "loc": { "start": { "line": 6, "column": 0 }, "end": { "line": 43, "column": 3 } } } ] }, { "type": "VariableDeclaration", "declarations": [ { "type": "VariableDeclarator", "id": { "type": "Identifier", "name": "WindowOperator", "range": [ 2039, 2053 ], "loc": { "start": { "line": 47, "column": 4 }, "end": { "line": 47, "column": 18 } } }, "init": { "type": "CallExpression", "callee": { "type": "FunctionExpression", "id": null, "params": [], "body": { "type": "BlockStatement", "body": [ { "type": "FunctionDeclaration", "id": { "type": "Identifier", "name": "WindowOperator", "range": [ 2084, 2098 ], "loc": { "start": { "line": 48, "column": 13 }, "end": { "line": 48, "column": 27 } } }, "params": [ { "type": "Identifier", "name": "closingSelector", "range": [ 2099, 2114 ], "loc": { "start": { "line": 48, "column": 28 }, "end": { "line": 48, "column": 43 } } } ], "body": { "type": "BlockStatement", "body": [ { "type": "ExpressionStatement", "expression": { "type": "AssignmentExpression", "operator": "=", "left": { "type": "MemberExpression", "computed": false, "object": { "type": "ThisExpression", "range": [ 2126, 2130 ], "loc": { "start": { "line": 49, "column": 8 }, "end": { "line": 49, "column": 12 } } }, "property": { "type": "Identifier", "name": "closingSelector", "range": [ 2131, 2146 ], "loc": { "start": { "line": 49, "column": 13 }, "end": { "line": 49, "column": 28 } } }, "range": [ 2126, 2146 ], "loc": { "start": { "line": 49, "column": 8 }, "end": { "line": 49, "column": 28 } } }, "right": { "type": "Identifier", "name": "closingSelector", "range": [ 2149, 2164 ], "loc": { "start": { "line": 49, "column": 31 }, "end": { "line": 49, "column": 46 } } }, "range": [ 2126, 2164 ], "loc": { "start": { "line": 49, "column": 8 }, "end": { "line": 49, "column": 46 } } }, "range": [ 2126, 2165 ], "loc": { "start": { "line": 49, "column": 8 }, "end": { "line": 49, "column": 47 } } } ], "range": [ 2116, 2171 ], "loc": { "start": { "line": 48, "column": 45 }, "end": { "line": 50, "column": 5 } } }, "generator": false, "expression": false, "range": [ 2075, 2171 ], "loc": { "start": { "line": 48, "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": "WindowOperator", "range": [ 2176, 2190 ], "loc": { "start": { "line": 51, "column": 4 }, "end": { "line": 51, "column": 18 } } }, "property": { "type": "Identifier", "name": "prototype", "range": [ 2191, 2200 ], "loc": { "start": { "line": 51, "column": 19 }, "end": { "line": 51, "column": 28 } } }, "range": [ 2176, 2200 ], "loc": { "start": { "line": 51, "column": 4 }, "end": { "line": 51, "column": 28 } } }, "property": { "type": "Identifier", "name": "call", "range": [ 2201, 2205 ], "loc": { "start": { "line": 51, "column": 29 }, "end": { "line": 51, "column": 33 } } }, "range": [ 2176, 2205 ], "loc": { "start": { "line": 51, "column": 4 }, "end": { "line": 51, "column": 33 } } }, "right": { "type": "FunctionExpression", "id": null, "params": [ { "type": "Identifier", "name": "subscriber", "range": [ 2218, 2228 ], "loc": { "start": { "line": 51, "column": 46 }, "end": { "line": 51, "column": 56 } } }, { "type": "Identifier", "name": "source", "range": [ 2230, 2236 ], "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": [ 2255, 2261 ], "loc": { "start": { "line": 52, "column": 15 }, "end": { "line": 52, "column": 21 } } }, "property": { "type": "Identifier", "name": "_subscribe", "range": [ 2262, 2272 ], "loc": { "start": { "line": 52, "column": 22 }, "end": { "line": 52, "column": 32 } } }, "range": [ 2255, 2272 ], "loc": { "start": { "line": 52, "column": 15 }, "end": { "line": 52, "column": 32 } } }, "arguments": [ { "type": "NewExpression", "callee": { "type": "Identifier", "name": "WindowSubscriber", "range": [ 2277, 2293 ], "loc": { "start": { "line": 52, "column": 37 }, "end": { "line": 52, "column": 53 } } }, "arguments": [ { "type": "Identifier", "name": "subscriber", "range": [ 2294, 2304 ], "loc": { "start": { "line": 52, "column": 54 }, "end": { "line": 52, "column": 64 } } }, { "type": "MemberExpression", "computed": false, "object": { "type": "ThisExpression", "range": [ 2306, 2310 ], "loc": { "start": { "line": 52, "column": 66 }, "end": { "line": 52, "column": 70 } } }, "property": { "type": "Identifier", "name": "closingSelector", "range": [ 2311, 2326 ], "loc": { "start": { "line": 52, "column": 71 }, "end": { "line": 52, "column": 86 } } }, "range": [ 2306, 2326 ], "loc": { "start": { "line": 52, "column": 66 }, "end": { "line": 52, "column": 86 } } } ], "range": [ 2273, 2327 ], "loc": { "start": { "line": 52, "column": 33 }, "end": { "line": 52, "column": 87 } } } ], "range": [ 2255, 2328 ], "loc": { "start": { "line": 52, "column": 15 }, "end": { "line": 52, "column": 88 } } }, "range": [ 2248, 2329 ], "loc": { "start": { "line": 52, "column": 8 }, "end": { "line": 52, "column": 89 } } } ], "range": [ 2238, 2335 ], "loc": { "start": { "line": 51, "column": 66 }, "end": { "line": 53, "column": 5 } } }, "generator": false, "expression": false, "range": [ 2208, 2335 ], "loc": { "start": { "line": 51, "column": 36 }, "end": { "line": 53, "column": 5 } } }, "range": [ 2176, 2335 ], "loc": { "start": { "line": 51, "column": 4 }, "end": { "line": 53, "column": 5 } } }, "range": [ 2176, 2336 ], "loc": { "start": { "line": 51, "column": 4 }, "end": { "line": 53, "column": 6 } } }, { "type": "ReturnStatement", "argument": { "type": "Identifier", "name": "WindowOperator", "range": [ 2348, 2362 ], "loc": { "start": { "line": 54, "column": 11 }, "end": { "line": 54, "column": 25 } } }, "range": [ 2341, 2363 ], "loc": { "start": { "line": 54, "column": 4 }, "end": { "line": 54, "column": 26 } } } ], "range": [ 2069, 2365 ], "loc": { "start": { "line": 47, "column": 34 }, "end": { "line": 55, "column": 1 } } }, "generator": false, "expression": false, "range": [ 2057, 2365 ], "loc": { "start": { "line": 47, "column": 22 }, "end": { "line": 55, "column": 1 } } }, "arguments": [], "range": [ 2057, 2367 ], "loc": { "start": { "line": 47, "column": 22 }, "end": { "line": 55, "column": 3 } } }, "range": [ 2039, 2368 ], "loc": { "start": { "line": 47, "column": 4 }, "end": { "line": 55, "column": 4 } } } ], "kind": "var", "range": [ 2035, 2369 ], "loc": { "start": { "line": 47, "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": [ 2370, 2461 ], "loc": { "start": { "line": 56, "column": 0 }, "end": { "line": 60, "column": 3 } } } ] }, { "type": "VariableDeclaration", "declarations": [ { "type": "VariableDeclarator", "id": { "type": "Identifier", "name": "WindowSubscriber", "range": [ 2466, 2482 ], "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": [ 2496, 2502 ],