UNPKG

@reactivex/rxjs

Version:

Reactive Extensions for modern JavaScript

1,347 lines (1,346 loc) 324 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": "Subject", "range": [ 53, 60 ], "loc": { "start": { "line": 2, "column": 9 }, "end": { "line": 2, "column": 16 } } }, "imported": { "type": "Identifier", "name": "Subject", "range": [ 53, 60 ], "loc": { "start": { "line": 2, "column": 9 }, "end": { "line": 2, "column": 16 } } }, "range": [ 53, 60 ], "loc": { "start": { "line": 2, "column": 9 }, "end": { "line": 2, "column": 16 } } } ], "source": { "type": "Literal", "value": "../Subject", "raw": "'../Subject'", "range": [ 68, 80 ], "loc": { "start": { "line": 2, "column": 24 }, "end": { "line": 2, "column": 36 } } }, "range": [ 44, 81 ], "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 2, "column": 37 } }, "trailingComments": [ { "type": "Block", "value": "*\n * Branch out the source Observable values as a nested Observable with each\n * nested Observable emitting at most `windowSize` values.\n *\n * <span class=\"informal\">It's like {@link bufferCount}, but emits a nested\n * Observable instead of an array.</span>\n *\n * <img src=\"./img/windowCount.png\" width=\"100%\">\n *\n * Returns an Observable that emits windows of items it collects from the source\n * Observable. The output Observable emits windows every `startWindowEvery`\n * items, each containing no more than `windowSize` items. When the source\n * Observable completes or encounters an error, the output Observable emits\n * the current window and propagates the notification from the source\n * Observable. If `startWindowEvery` is not provided, then new windows are\n * started immediately at the start of the source and when each window completes\n * with size `windowSize`.\n *\n * @example <caption>Ignore every 3rd click event, starting from the first one</caption>\n * var clicks = Rx.Observable.fromEvent(document, 'click');\n * var result = clicks.windowCount(3)\n * .map(win => win.skip(1)) // skip first of every 3 clicks\n * .mergeAll(); // flatten the Observable-of-Observables\n * result.subscribe(x => console.log(x));\n *\n * @example <caption>Ignore every 3rd click event, starting from the third one</caption>\n * var clicks = Rx.Observable.fromEvent(document, 'click');\n * var result = clicks.windowCount(2, 3)\n * .mergeAll(); // flatten the Observable-of-Observables\n * result.subscribe(x => console.log(x));\n *\n * @see {@link window}\n * @see {@link windowTime}\n * @see {@link windowToggle}\n * @see {@link windowWhen}\n * @see {@link bufferCount}\n *\n * @param {number} windowSize The maximum number of values emitted by each\n * window.\n * @param {number} [startWindowEvery] Interval at which to start a new window.\n * For example if `startWindowEvery` is `2`, then a new window will be started\n * on every other value from the source. A new window is started at the\n * beginning of the source by default.\n * @return {Observable<Observable<T>>} An Observable of windows, which in turn\n * are Observable of values.\n * @method windowCount\n * @owner Observable\n ", "range": [ 82, 2256 ], "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 50, "column": 3 } } } ] }, { "type": "ExportNamedDeclaration", "declaration": { "type": "FunctionDeclaration", "id": { "type": "Identifier", "name": "windowCount", "range": [ 2273, 2284 ], "loc": { "start": { "line": 51, "column": 16 }, "end": { "line": 51, "column": 27 } } }, "params": [ { "type": "Identifier", "name": "windowSize", "range": [ 2285, 2295 ], "loc": { "start": { "line": 51, "column": 28 }, "end": { "line": 51, "column": 38 } } }, { "type": "Identifier", "name": "startWindowEvery", "range": [ 2297, 2313 ], "loc": { "start": { "line": 51, "column": 40 }, "end": { "line": 51, "column": 56 } } } ], "body": { "type": "BlockStatement", "body": [ { "type": "IfStatement", "test": { "type": "BinaryExpression", "operator": "===", "left": { "type": "Identifier", "name": "startWindowEvery", "range": [ 2325, 2341 ], "loc": { "start": { "line": 52, "column": 8 }, "end": { "line": 52, "column": 24 } } }, "right": { "type": "UnaryExpression", "operator": "void", "argument": { "type": "Literal", "value": 0, "raw": "0", "range": [ 2351, 2352 ], "loc": { "start": { "line": 52, "column": 34 }, "end": { "line": 52, "column": 35 } } }, "prefix": true, "range": [ 2346, 2352 ], "loc": { "start": { "line": 52, "column": 29 }, "end": { "line": 52, "column": 35 } } }, "range": [ 2325, 2352 ], "loc": { "start": { "line": 52, "column": 8 }, "end": { "line": 52, "column": 35 } } }, "consequent": { "type": "BlockStatement", "body": [ { "type": "ExpressionStatement", "expression": { "type": "AssignmentExpression", "operator": "=", "left": { "type": "Identifier", "name": "startWindowEvery", "range": [ 2356, 2372 ], "loc": { "start": { "line": 52, "column": 39 }, "end": { "line": 52, "column": 55 } } }, "right": { "type": "Literal", "value": 0, "raw": "0", "range": [ 2375, 2376 ], "loc": { "start": { "line": 52, "column": 58 }, "end": { "line": 52, "column": 59 } } }, "range": [ 2356, 2376 ], "loc": { "start": { "line": 52, "column": 39 }, "end": { "line": 52, "column": 59 } } }, "range": [ 2356, 2377 ], "loc": { "start": { "line": 52, "column": 39 }, "end": { "line": 52, "column": 60 } } } ], "range": [ 2354, 2379 ], "loc": { "start": { "line": 52, "column": 37 }, "end": { "line": 52, "column": 62 } } }, "alternate": null, "range": [ 2321, 2379 ], "loc": { "start": { "line": 52, "column": 4 }, "end": { "line": 52, "column": 62 } } }, { "type": "ReturnStatement", "argument": { "type": "CallExpression", "callee": { "type": "MemberExpression", "computed": false, "object": { "type": "ThisExpression", "range": [ 2391, 2395 ], "loc": { "start": { "line": 53, "column": 11 }, "end": { "line": 53, "column": 15 } } }, "property": { "type": "Identifier", "name": "lift", "range": [ 2396, 2400 ], "loc": { "start": { "line": 53, "column": 16 }, "end": { "line": 53, "column": 20 } } }, "range": [ 2391, 2400 ], "loc": { "start": { "line": 53, "column": 11 }, "end": { "line": 53, "column": 20 } } }, "arguments": [ { "type": "NewExpression", "callee": { "type": "Identifier", "name": "WindowCountOperator", "range": [ 2405, 2424 ], "loc": { "start": { "line": 53, "column": 25 }, "end": { "line": 53, "column": 44 } } }, "arguments": [ { "type": "Identifier", "name": "windowSize", "range": [ 2425, 2435 ], "loc": { "start": { "line": 53, "column": 45 }, "end": { "line": 53, "column": 55 } } }, { "type": "Identifier", "name": "startWindowEvery", "range": [ 2437, 2453 ], "loc": { "start": { "line": 53, "column": 57 }, "end": { "line": 53, "column": 73 } } } ], "range": [ 2401, 2454 ], "loc": { "start": { "line": 53, "column": 21 }, "end": { "line": 53, "column": 74 } } } ], "range": [ 2391, 2455 ], "loc": { "start": { "line": 53, "column": 11 }, "end": { "line": 53, "column": 75 } } }, "range": [ 2384, 2456 ], "loc": { "start": { "line": 53, "column": 4 }, "end": { "line": 53, "column": 76 } } } ], "range": [ 2315, 2458 ], "loc": { "start": { "line": 51, "column": 58 }, "end": { "line": 54, "column": 1 } } }, "generator": false, "expression": false, "range": [ 2264, 2458 ], "loc": { "start": { "line": 51, "column": 7 }, "end": { "line": 54, "column": 1 } }, "leadingComments": [ { "type": "Block", "value": "*\n * Branch out the source Observable values as a nested Observable with each\n * nested Observable emitting at most `windowSize` values.\n *\n * <span class=\"informal\">It's like {@link bufferCount}, but emits a nested\n * Observable instead of an array.</span>\n *\n * <img src=\"./img/windowCount.png\" width=\"100%\">\n *\n * Returns an Observable that emits windows of items it collects from the source\n * Observable. The output Observable emits windows every `startWindowEvery`\n * items, each containing no more than `windowSize` items. When the source\n * Observable completes or encounters an error, the output Observable emits\n * the current window and propagates the notification from the source\n * Observable. If `startWindowEvery` is not provided, then new windows are\n * started immediately at the start of the source and when each window completes\n * with size `windowSize`.\n *\n * @example <caption>Ignore every 3rd click event, starting from the first one</caption>\n * var clicks = Rx.Observable.fromEvent(document, 'click');\n * var result = clicks.windowCount(3)\n * .map(win => win.skip(1)) // skip first of every 3 clicks\n * .mergeAll(); // flatten the Observable-of-Observables\n * result.subscribe(x => console.log(x));\n *\n * @example <caption>Ignore every 3rd click event, starting from the third one</caption>\n * var clicks = Rx.Observable.fromEvent(document, 'click');\n * var result = clicks.windowCount(2, 3)\n * .mergeAll(); // flatten the Observable-of-Observables\n * result.subscribe(x => console.log(x));\n *\n * @see {@link window}\n * @see {@link windowTime}\n * @see {@link windowToggle}\n * @see {@link windowWhen}\n * @see {@link bufferCount}\n *\n * @param {number} windowSize The maximum number of values emitted by each\n * window.\n * @param {number} [startWindowEvery] Interval at which to start a new window.\n * For example if `startWindowEvery` is `2`, then a new window will be started\n * on every other value from the source. A new window is started at the\n * beginning of the source by default.\n * @return {Observable<Observable<T>>} An Observable of windows, which in turn\n * are Observable of values.\n * @method windowCount\n * @owner Observable\n ", "range": [ 82, 2256 ], "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 50, "column": 3 } } } ], "trailingComments": [] }, "specifiers": [], "source": null, "range": [ 2257, 2458 ], "loc": { "start": { "line": 51, "column": 0 }, "end": { "line": 54, "column": 1 } }, "leadingComments": [ { "type": "Block", "value": "*\n * Branch out the source Observable values as a nested Observable with each\n * nested Observable emitting at most `windowSize` values.\n *\n * <span class=\"informal\">It's like {@link bufferCount}, but emits a nested\n * Observable instead of an array.</span>\n *\n * <img src=\"./img/windowCount.png\" width=\"100%\">\n *\n * Returns an Observable that emits windows of items it collects from the source\n * Observable. The output Observable emits windows every `startWindowEvery`\n * items, each containing no more than `windowSize` items. When the source\n * Observable completes or encounters an error, the output Observable emits\n * the current window and propagates the notification from the source\n * Observable. If `startWindowEvery` is not provided, then new windows are\n * started immediately at the start of the source and when each window completes\n * with size `windowSize`.\n *\n * @example <caption>Ignore every 3rd click event, starting from the first one</caption>\n * var clicks = Rx.Observable.fromEvent(document, 'click');\n * var result = clicks.windowCount(3)\n * .map(win => win.skip(1)) // skip first of every 3 clicks\n * .mergeAll(); // flatten the Observable-of-Observables\n * result.subscribe(x => console.log(x));\n *\n * @example <caption>Ignore every 3rd click event, starting from the third one</caption>\n * var clicks = Rx.Observable.fromEvent(document, 'click');\n * var result = clicks.windowCount(2, 3)\n * .mergeAll(); // flatten the Observable-of-Observables\n * result.subscribe(x => console.log(x));\n *\n * @see {@link window}\n * @see {@link windowTime}\n * @see {@link windowToggle}\n * @see {@link windowWhen}\n * @see {@link bufferCount}\n *\n * @param {number} windowSize The maximum number of values emitted by each\n * window.\n * @param {number} [startWindowEvery] Interval at which to start a new window.\n * For example if `startWindowEvery` is `2`, then a new window will be started\n * on every other value from the source. A new window is started at the\n * beginning of the source by default.\n * @return {Observable<Observable<T>>} An Observable of windows, which in turn\n * are Observable of values.\n * @method windowCount\n * @owner Observable\n ", "range": [ 82, 2256 ], "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 50, "column": 3 } } } ] }, { "type": "VariableDeclaration", "declarations": [ { "type": "VariableDeclarator", "id": { "type": "Identifier", "name": "WindowCountOperator", "range": [ 2463, 2482 ], "loc": { "start": { "line": 55, "column": 4 }, "end": { "line": 55, "column": 23 } } }, "init": { "type": "CallExpression", "callee": { "type": "FunctionExpression", "id": null, "params": [], "body": { "type": "BlockStatement", "body": [ { "type": "FunctionDeclaration", "id": { "type": "Identifier", "name": "WindowCountOperator", "range": [ 2513, 2532 ], "loc": { "start": { "line": 56, "column": 13 }, "end": { "line": 56, "column": 32 } } }, "params": [ { "type": "Identifier", "name": "windowSize", "range": [ 2533, 2543 ], "loc": { "start": { "line": 56, "column": 33 }, "end": { "line": 56, "column": 43 } } }, { "type": "Identifier", "name": "startWindowEvery", "range": [ 2545, 2561 ], "loc": { "start": { "line": 56, "column": 45 }, "end": { "line": 56, "column": 61 } } } ], "body": { "type": "BlockStatement", "body": [ { "type": "ExpressionStatement", "expression": { "type": "AssignmentExpression", "operator": "=", "left": { "type": "MemberExpression", "computed": false, "object": { "type": "ThisExpression", "range": [ 2573, 2577 ], "loc": { "start": { "line": 57, "column": 8 }, "end": { "line": 57, "column": 12 } } }, "property": { "type": "Identifier", "name": "windowSize", "range": [ 2578, 2588 ], "loc": { "start": { "line": 57, "column": 13 }, "end": { "line": 57, "column": 23 } } }, "range": [ 2573, 2588 ], "loc": { "start": { "line": 57, "column": 8 }, "end": { "line": 57, "column": 23 } } }, "right": { "type": "Identifier", "name": "windowSize", "range": [ 2591, 2601 ], "loc": { "start": { "line": 57, "column": 26 }, "end": { "line": 57, "column": 36 } } }, "range": [ 2573, 2601 ], "loc": { "start": { "line": 57, "column": 8 }, "end": { "line": 57, "column": 36 } } }, "range": [ 2573, 2602 ], "loc": { "start": { "line": 57, "column": 8 }, "end": { "line": 57, "column": 37 } } }, { "type": "ExpressionStatement", "expression": { "type": "AssignmentExpression", "operator": "=", "left": { "type": "MemberExpression", "computed": false, "object": { "type": "ThisExpression", "range": [ 2611, 2615 ], "loc": { "start": { "line": 58, "column": 8 }, "end": { "line": 58, "column": 12 } } }, "property": { "type": "Identifier", "name": "startWindowEvery", "range": [ 2616, 2632 ], "loc": { "start": { "line": 58, "column": 13 }, "end": { "line": 58, "column": 29 } } }, "range": [ 2611, 2632 ], "loc": { "start": { "line": 58, "column": 8 }, "end": { "line": 58, "column": 29 } } }, "right": { "type": "Identifier", "name": "startWindowEvery", "range": [ 2635, 2651 ], "loc": { "start": { "line": 58, "column": 32 }, "end": { "line": 58, "column": 48 } } }, "range": [ 2611, 2651 ], "loc": { "start": { "line": 58, "column": 8 }, "end": { "line": 58, "column": 48 } } }, "range": [ 2611, 2652 ], "loc": { "start": { "line": 58, "column": 8 }, "end": { "line": 58, "column": 49 } } } ], "range": [ 2563, 2658 ], "loc": { "start": { "line": 56, "column": 63 }, "end": { "line": 59, "column": 5 } } }, "generator": false, "expression": false, "range": [ 2504, 2658 ], "loc": { "start": { "line": 56, "column": 4 }, "end": { "line": 59, "column": 5 } } }, { "type": "ExpressionStatement", "expression": { "type": "AssignmentExpression", "operator": "=", "left": { "type": "MemberExpression", "computed": false, "object": { "type": "MemberExpression", "computed": false, "object": { "type": "Identifier", "name": "WindowCountOperator", "range": [ 2663, 2682 ], "loc": { "start": { "line": 60, "column": 4 }, "end": { "line": 60, "column": 23 } } }, "property": { "type": "Identifier", "name": "prototype", "range": [ 2683, 2692 ], "loc": { "start": { "line": 60, "column": 24 }, "end": { "line": 60, "column": 33 } } }, "range": [ 2663, 2692 ], "loc": { "start": { "line": 60, "column": 4 }, "end": { "line": 60, "column": 33 } } }, "property": { "type": "Identifier", "name": "call", "range": [ 2693, 2697 ], "loc": { "start": { "line": 60, "column": 34 }, "end": { "line": 60, "column": 38 } } }, "range": [ 2663, 2697 ], "loc": { "start": { "line": 60, "column": 4 }, "end": { "line": 60, "column": 38 } } }, "right": { "type": "FunctionExpression", "id": null, "params": [ { "type": "Identifier", "name": "subscriber", "range": [ 2710, 2720 ], "loc": { "start": { "line": 60, "column": 51 }, "end": { "line": 60, "column": 61 } } }, { "type": "Identifier", "name": "source", "range": [ 2722, 2728 ], "loc": { "start": { "line": 60, "column": 63 }, "end": { "line": 60, "column": 69 } } } ], "body": { "type": "BlockStatement", "body": [ { "type": "ReturnStatement", "argument": { "type": "CallExpression", "callee": { "type": "MemberExpression", "computed": false, "object": { "type": "Identifier", "name": "source", "range": [ 2747, 2753 ], "loc": { "start": { "line": 61, "column": 15 }, "end": { "line": 61, "column": 21 } } }, "property": { "type": "Identifier", "name": "_subscribe", "range": [ 2754, 2764 ], "loc": { "start": { "line": 61, "column": 22 }, "end": { "line": 61, "column": 32 } } }, "range": [ 2747, 2764 ], "loc": { "start": { "line": 61, "column": 15 }, "end": { "line": 61, "column": 32 } } }, "arguments": [ { "type": "NewExpression", "callee": { "type": "Identifier", "name": "WindowCountSubscriber", "range": [ 2769, 2790 ], "loc": { "start": { "line": 61, "column": 37 }, "end": { "line": 61, "column": 58 } } }, "arguments": [ { "type": "Identifier", "name": "subscriber", "range": [ 2791, 2801 ], "loc": { "start": { "line": 61, "column": 59 }, "end": { "line": 61, "column": 69 } } }, { "type": "MemberExpression", "computed": false, "object": { "type": "ThisExpression", "range": [ 2803, 2807 ], "loc": { "start": { "line": 61, "column": 71 }, "end": { "line": 61, "column": 75 } } }, "property": { "type": "Identifier", "name": "windowSize", "range": [ 2808, 2818 ], "loc": { "start": { "line": 61, "column": 76 }, "end": { "line": 61, "column": 86 } } }, "range": [ 2803, 2818 ], "loc": { "start": { "line": 61, "column": 71 }, "end": { "line": 61, "column": 86 } } }, { "type": "MemberExpression", "computed": false, "object": { "type": "ThisExpression", "range": [ 2820, 2824 ], "loc": { "start": { "line": 61, "column": 88 },