UNPKG

@reactivex/rxjs

Version:

Reactive Extensions for modern JavaScript

1,321 lines 233 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 * Buffers the source Observable values until the size hits the maximum\n * `bufferSize` given.\n *\n * <span class=\"informal\">Collects values from the past as an array, and emits\n * that array only when its size reaches `bufferSize`.</span>\n *\n * <img src=\"./img/bufferCount.png\" width=\"100%\">\n *\n * Buffers a number of values from the source Observable by `bufferSize` then\n * emits the buffer and clears it, and starts a new buffer each\n * `startBufferEvery` values. If `startBufferEvery` is not provided or is\n * `null`, then new buffers are started immediately at the start of the source\n * and when each buffer closes and is emitted.\n *\n * @example <caption>Emit the last two click events as an array</caption>\n * var clicks = Rx.Observable.fromEvent(document, 'click');\n * var buffered = clicks.bufferCount(2);\n * buffered.subscribe(x => console.log(x));\n *\n * @example <caption>On every click, emit the last two click events as an array</caption>\n * var clicks = Rx.Observable.fromEvent(document, 'click');\n * var buffered = clicks.bufferCount(2, 1);\n * buffered.subscribe(x => console.log(x));\n *\n * @see {@link buffer}\n * @see {@link bufferTime}\n * @see {@link bufferToggle}\n * @see {@link bufferWhen}\n * @see {@link pairwise}\n * @see {@link windowCount}\n *\n * @param {number} bufferSize The maximum size of the buffer emitted.\n * @param {number} [startBufferEvery] Interval at which to start a new buffer.\n * For example if `startBufferEvery` is `2`, then a new buffer will be started\n * on every other value from the source. A new buffer is started at the\n * beginning of the source by default.\n * @return {Observable<T[]>} An Observable of arrays of buffered values.\n * @method bufferCount\n * @owner Observable\n ", "range": [ 44, 1772 ], "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 42, "column": 3 } } } ] }, { "type": "ExportNamedDeclaration", "declaration": { "type": "FunctionDeclaration", "id": { "type": "Identifier", "name": "bufferCount", "range": [ 1789, 1800 ], "loc": { "start": { "line": 43, "column": 16 }, "end": { "line": 43, "column": 27 } } }, "params": [ { "type": "Identifier", "name": "bufferSize", "range": [ 1801, 1811 ], "loc": { "start": { "line": 43, "column": 28 }, "end": { "line": 43, "column": 38 } } }, { "type": "Identifier", "name": "startBufferEvery", "range": [ 1813, 1829 ], "loc": { "start": { "line": 43, "column": 40 }, "end": { "line": 43, "column": 56 } } } ], "body": { "type": "BlockStatement", "body": [ { "type": "IfStatement", "test": { "type": "BinaryExpression", "operator": "===", "left": { "type": "Identifier", "name": "startBufferEvery", "range": [ 1841, 1857 ], "loc": { "start": { "line": 44, "column": 8 }, "end": { "line": 44, "column": 24 } } }, "right": { "type": "UnaryExpression", "operator": "void", "argument": { "type": "Literal", "value": 0, "raw": "0", "range": [ 1867, 1868 ], "loc": { "start": { "line": 44, "column": 34 }, "end": { "line": 44, "column": 35 } } }, "prefix": true, "range": [ 1862, 1868 ], "loc": { "start": { "line": 44, "column": 29 }, "end": { "line": 44, "column": 35 } } }, "range": [ 1841, 1868 ], "loc": { "start": { "line": 44, "column": 8 }, "end": { "line": 44, "column": 35 } } }, "consequent": { "type": "BlockStatement", "body": [ { "type": "ExpressionStatement", "expression": { "type": "AssignmentExpression", "operator": "=", "left": { "type": "Identifier", "name": "startBufferEvery", "range": [ 1872, 1888 ], "loc": { "start": { "line": 44, "column": 39 }, "end": { "line": 44, "column": 55 } } }, "right": { "type": "Literal", "value": null, "raw": "null", "range": [ 1891, 1895 ], "loc": { "start": { "line": 44, "column": 58 }, "end": { "line": 44, "column": 62 } } }, "range": [ 1872, 1895 ], "loc": { "start": { "line": 44, "column": 39 }, "end": { "line": 44, "column": 62 } } }, "range": [ 1872, 1896 ], "loc": { "start": { "line": 44, "column": 39 }, "end": { "line": 44, "column": 63 } } } ], "range": [ 1870, 1898 ], "loc": { "start": { "line": 44, "column": 37 }, "end": { "line": 44, "column": 65 } } }, "alternate": null, "range": [ 1837, 1898 ], "loc": { "start": { "line": 44, "column": 4 }, "end": { "line": 44, "column": 65 } } }, { "type": "ReturnStatement", "argument": { "type": "CallExpression", "callee": { "type": "MemberExpression", "computed": false, "object": { "type": "ThisExpression", "range": [ 1910, 1914 ], "loc": { "start": { "line": 45, "column": 11 }, "end": { "line": 45, "column": 15 } } }, "property": { "type": "Identifier", "name": "lift", "range": [ 1915, 1919 ], "loc": { "start": { "line": 45, "column": 16 }, "end": { "line": 45, "column": 20 } } }, "range": [ 1910, 1919 ], "loc": { "start": { "line": 45, "column": 11 }, "end": { "line": 45, "column": 20 } } }, "arguments": [ { "type": "NewExpression", "callee": { "type": "Identifier", "name": "BufferCountOperator", "range": [ 1924, 1943 ], "loc": { "start": { "line": 45, "column": 25 }, "end": { "line": 45, "column": 44 } } }, "arguments": [ { "type": "Identifier", "name": "bufferSize", "range": [ 1944, 1954 ], "loc": { "start": { "line": 45, "column": 45 }, "end": { "line": 45, "column": 55 } } }, { "type": "Identifier", "name": "startBufferEvery", "range": [ 1956, 1972 ], "loc": { "start": { "line": 45, "column": 57 }, "end": { "line": 45, "column": 73 } } } ], "range": [ 1920, 1973 ], "loc": { "start": { "line": 45, "column": 21 }, "end": { "line": 45, "column": 74 } } } ], "range": [ 1910, 1974 ], "loc": { "start": { "line": 45, "column": 11 }, "end": { "line": 45, "column": 75 } } }, "range": [ 1903, 1975 ], "loc": { "start": { "line": 45, "column": 4 }, "end": { "line": 45, "column": 76 } } } ], "range": [ 1831, 1977 ], "loc": { "start": { "line": 43, "column": 58 }, "end": { "line": 46, "column": 1 } } }, "generator": false, "expression": false, "range": [ 1780, 1977 ], "loc": { "start": { "line": 43, "column": 7 }, "end": { "line": 46, "column": 1 } }, "leadingComments": [ { "type": "Block", "value": "*\n * Buffers the source Observable values until the size hits the maximum\n * `bufferSize` given.\n *\n * <span class=\"informal\">Collects values from the past as an array, and emits\n * that array only when its size reaches `bufferSize`.</span>\n *\n * <img src=\"./img/bufferCount.png\" width=\"100%\">\n *\n * Buffers a number of values from the source Observable by `bufferSize` then\n * emits the buffer and clears it, and starts a new buffer each\n * `startBufferEvery` values. If `startBufferEvery` is not provided or is\n * `null`, then new buffers are started immediately at the start of the source\n * and when each buffer closes and is emitted.\n *\n * @example <caption>Emit the last two click events as an array</caption>\n * var clicks = Rx.Observable.fromEvent(document, 'click');\n * var buffered = clicks.bufferCount(2);\n * buffered.subscribe(x => console.log(x));\n *\n * @example <caption>On every click, emit the last two click events as an array</caption>\n * var clicks = Rx.Observable.fromEvent(document, 'click');\n * var buffered = clicks.bufferCount(2, 1);\n * buffered.subscribe(x => console.log(x));\n *\n * @see {@link buffer}\n * @see {@link bufferTime}\n * @see {@link bufferToggle}\n * @see {@link bufferWhen}\n * @see {@link pairwise}\n * @see {@link windowCount}\n *\n * @param {number} bufferSize The maximum size of the buffer emitted.\n * @param {number} [startBufferEvery] Interval at which to start a new buffer.\n * For example if `startBufferEvery` is `2`, then a new buffer will be started\n * on every other value from the source. A new buffer is started at the\n * beginning of the source by default.\n * @return {Observable<T[]>} An Observable of arrays of buffered values.\n * @method bufferCount\n * @owner Observable\n ", "range": [ 44, 1772 ], "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 42, "column": 3 } } } ], "trailingComments": [] }, "specifiers": [], "source": null, "range": [ 1773, 1977 ], "loc": { "start": { "line": 43, "column": 0 }, "end": { "line": 46, "column": 1 } }, "leadingComments": [ { "type": "Block", "value": "*\n * Buffers the source Observable values until the size hits the maximum\n * `bufferSize` given.\n *\n * <span class=\"informal\">Collects values from the past as an array, and emits\n * that array only when its size reaches `bufferSize`.</span>\n *\n * <img src=\"./img/bufferCount.png\" width=\"100%\">\n *\n * Buffers a number of values from the source Observable by `bufferSize` then\n * emits the buffer and clears it, and starts a new buffer each\n * `startBufferEvery` values. If `startBufferEvery` is not provided or is\n * `null`, then new buffers are started immediately at the start of the source\n * and when each buffer closes and is emitted.\n *\n * @example <caption>Emit the last two click events as an array</caption>\n * var clicks = Rx.Observable.fromEvent(document, 'click');\n * var buffered = clicks.bufferCount(2);\n * buffered.subscribe(x => console.log(x));\n *\n * @example <caption>On every click, emit the last two click events as an array</caption>\n * var clicks = Rx.Observable.fromEvent(document, 'click');\n * var buffered = clicks.bufferCount(2, 1);\n * buffered.subscribe(x => console.log(x));\n *\n * @see {@link buffer}\n * @see {@link bufferTime}\n * @see {@link bufferToggle}\n * @see {@link bufferWhen}\n * @see {@link pairwise}\n * @see {@link windowCount}\n *\n * @param {number} bufferSize The maximum size of the buffer emitted.\n * @param {number} [startBufferEvery] Interval at which to start a new buffer.\n * For example if `startBufferEvery` is `2`, then a new buffer will be started\n * on every other value from the source. A new buffer is started at the\n * beginning of the source by default.\n * @return {Observable<T[]>} An Observable of arrays of buffered values.\n * @method bufferCount\n * @owner Observable\n ", "range": [ 44, 1772 ], "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 42, "column": 3 } } } ] }, { "type": "VariableDeclaration", "declarations": [ { "type": "VariableDeclarator", "id": { "type": "Identifier", "name": "BufferCountOperator", "range": [ 1982, 2001 ], "loc": { "start": { "line": 47, "column": 4 }, "end": { "line": 47, "column": 23 } } }, "init": { "type": "CallExpression", "callee": { "type": "FunctionExpression", "id": null, "params": [], "body": { "type": "BlockStatement", "body": [ { "type": "FunctionDeclaration", "id": { "type": "Identifier", "name": "BufferCountOperator", "range": [ 2032, 2051 ], "loc": { "start": { "line": 48, "column": 13 }, "end": { "line": 48, "column": 32 } } }, "params": [ { "type": "Identifier", "name": "bufferSize", "range": [ 2052, 2062 ], "loc": { "start": { "line": 48, "column": 33 }, "end": { "line": 48, "column": 43 } } }, { "type": "Identifier", "name": "startBufferEvery", "range": [ 2064, 2080 ], "loc": { "start": { "line": 48, "column": 45 }, "end": { "line": 48, "column": 61 } } } ], "body": { "type": "BlockStatement", "body": [ { "type": "ExpressionStatement", "expression": { "type": "AssignmentExpression", "operator": "=", "left": { "type": "MemberExpression", "computed": false, "object": { "type": "ThisExpression", "range": [ 2092, 2096 ], "loc": { "start": { "line": 49, "column": 8 }, "end": { "line": 49, "column": 12 } } }, "property": { "type": "Identifier", "name": "bufferSize", "range": [ 2097, 2107 ], "loc": { "start": { "line": 49, "column": 13 }, "end": { "line": 49, "column": 23 } } }, "range": [ 2092, 2107 ], "loc": { "start": { "line": 49, "column": 8 }, "end": { "line": 49, "column": 23 } } }, "right": { "type": "Identifier", "name": "bufferSize", "range": [ 2110, 2120 ], "loc": { "start": { "line": 49, "column": 26 }, "end": { "line": 49, "column": 36 } } }, "range": [ 2092, 2120 ], "loc": { "start": { "line": 49, "column": 8 }, "end": { "line": 49, "column": 36 } } }, "range": [ 2092, 2121 ], "loc": { "start": { "line": 49, "column": 8 }, "end": { "line": 49, "column": 37 } } }, { "type": "ExpressionStatement", "expression": { "type": "AssignmentExpression", "operator": "=", "left": { "type": "MemberExpression", "computed": false, "object": { "type": "ThisExpression", "range": [ 2130, 2134 ], "loc": { "start": { "line": 50, "column": 8 }, "end": { "line": 50, "column": 12 } } }, "property": { "type": "Identifier", "name": "startBufferEvery", "range": [ 2135, 2151 ], "loc": { "start": { "line": 50, "column": 13 }, "end": { "line": 50, "column": 29 } } }, "range": [ 2130, 2151 ], "loc": { "start": { "line": 50, "column": 8 }, "end": { "line": 50, "column": 29 } } }, "right": { "type": "Identifier", "name": "startBufferEvery", "range": [ 2154, 2170 ], "loc": { "start": { "line": 50, "column": 32 }, "end": { "line": 50, "column": 48 } } }, "range": [ 2130, 2170 ], "loc": { "start": { "line": 50, "column": 8 }, "end": { "line": 50, "column": 48 } } }, "range": [ 2130, 2171 ], "loc": { "start": { "line": 50, "column": 8 }, "end": { "line": 50, "column": 49 } } } ], "range": [ 2082, 2177 ], "loc": { "start": { "line": 48, "column": 63 }, "end": { "line": 51, "column": 5 } } }, "generator": false, "expression": false, "range": [ 2023, 2177 ], "loc": { "start": { "line": 48, "column": 4 }, "end": { "line": 51, "column": 5 } } }, { "type": "ExpressionStatement", "expression": { "type": "AssignmentExpression", "operator": "=", "left": { "type": "MemberExpression", "computed": false, "object": { "type": "MemberExpression", "computed": false, "object": { "type": "Identifier", "name": "BufferCountOperator", "range": [ 2182, 2201 ], "loc": { "start": { "line": 52, "column": 4 }, "end": { "line": 52, "column": 23 } } }, "property": { "type": "Identifier", "name": "prototype", "range": [ 2202, 2211 ], "loc": { "start": { "line": 52, "column": 24 }, "end": { "line": 52, "column": 33 } } }, "range": [ 2182, 2211 ], "loc": { "start": { "line": 52, "column": 4 }, "end": { "line": 52, "column": 33 } } }, "property": { "type": "Identifier", "name": "call", "range": [ 2212, 2216 ], "loc": { "start": { "line": 52, "column": 34 }, "end": { "line": 52, "column": 38 } } }, "range": [ 2182, 2216 ], "loc": { "start": { "line": 52, "column": 4 }, "end": { "line": 52, "column": 38 } } }, "right": { "type": "FunctionExpression", "id": null, "params": [ { "type": "Identifier", "name": "subscriber", "range": [ 2229, 2239 ], "loc": { "start": { "line": 52, "column": 51 }, "end": { "line": 52, "column": 61 } } }, { "type": "Identifier", "name": "source", "range": [ 2241, 2247 ], "loc": { "start": { "line": 52, "column": 63 }, "end": { "line": 52, "column": 69 } } } ], "body": { "type": "BlockStatement", "body": [ { "type": "ReturnStatement", "argument": { "type": "CallExpression", "callee": { "type": "MemberExpression", "computed": false, "object": { "type": "Identifier", "name": "source", "range": [ 2266, 2272 ], "loc": { "start": { "line": 53, "column": 15 }, "end": { "line": 53, "column": 21 } } }, "property": { "type": "Identifier", "name": "_subscribe", "range": [ 2273, 2283 ], "loc": { "start": { "line": 53, "column": 22 }, "end": { "line": 53, "column": 32 } } }, "range": [ 2266, 2283 ], "loc": { "start": { "line": 53, "column": 15 }, "end": { "line": 53, "column": 32 } } }, "arguments": [ { "type": "NewExpression", "callee": { "type": "Identifier", "name": "BufferCountSubscriber", "range": [ 2288, 2309 ], "loc": { "start": { "line": 53, "column": 37 }, "end": { "line": 53, "column": 58 } } }, "arguments": [ { "type": "Identifier", "name": "subscriber", "range": [ 2310, 2320 ], "loc": { "start": { "line": 53, "column": 59 }, "end": { "line": 53, "column": 69 } } }, { "type": "MemberExpression", "computed": false, "object": { "type": "ThisExpression", "range": [ 2322, 2326 ], "loc": { "start": { "line": 53, "column": 71 }, "end": { "line": 53, "column": 75 } } }, "property": { "type": "Identifier", "name": "bufferSize", "range": [ 2327, 2337 ], "loc": { "start": { "line": 53, "column": 76 }, "end": { "line": 53, "column": 86 } } }, "range": [ 2322, 2337 ], "loc": { "start": { "line": 53, "column": 71 }, "end": { "line": 53, "column": 86 } } }, { "type": "MemberExpression", "computed": false, "object": { "type": "ThisExpression", "range": [ 2339, 2343 ], "loc": { "start": { "line": 53, "column": 88 }, "end": { "line": 53, "column": 92 } } }, "property": { "type": "Identifier", "name": "startBufferEvery", "range": [ 2344, 2360 ], "loc": { "start": { "line": 53, "column": 93 }, "end": { "line": 53, "column": 109 } } }, "range": [ 2339, 2360 ], "loc": { "start": { "line": 53, "column": 88 }, "end": { "line": 53, "column": 109 } } } ], "range": [ 2284, 2361 ], "loc": { "start": { "line": 53, "column": 33 }, "end": { "line": 53, "column": 110 } } } ], "range": [ 2266, 2362 ], "loc": { "start": { "line": 53, "column": 15 }, "end": {