@reactivex/rxjs
Version:
Reactive Extensions for modern JavaScript
1,334 lines (1,333 loc) • 158 kB
JSON
{
"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": "ArgumentOutOfRangeError",
"range": [
53,
76
],
"loc": {
"start": {
"line": 2,
"column": 9
},
"end": {
"line": 2,
"column": 32
}
}
},
"imported": {
"type": "Identifier",
"name": "ArgumentOutOfRangeError",
"range": [
53,
76
],
"loc": {
"start": {
"line": 2,
"column": 9
},
"end": {
"line": 2,
"column": 32
}
}
},
"range": [
53,
76
],
"loc": {
"start": {
"line": 2,
"column": 9
},
"end": {
"line": 2,
"column": 32
}
}
}
],
"source": {
"type": "Literal",
"value": "../util/ArgumentOutOfRangeError",
"raw": "'../util/ArgumentOutOfRangeError'",
"range": [
84,
117
],
"loc": {
"start": {
"line": 2,
"column": 40
},
"end": {
"line": 2,
"column": 73
}
}
},
"range": [
44,
118
],
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 74
}
},
"trailingComments": [
{
"type": "Block",
"value": "*\n * Emits the single value at the specified `index` in a sequence of emissions\n * from the source Observable.\n *\n * <span class=\"informal\">Emits only the i-th value, then completes.</span>\n *\n * <img src=\"./img/elementAt.png\" width=\"100%\">\n *\n * `elementAt` returns an Observable that emits the item at the specified\n * `index` in the source Observable, or a default value if that `index` is out\n * of range and the `default` argument is provided. If the `default` argument is\n * not given and the `index` is out of range, the output Observable will emit an\n * `ArgumentOutOfRangeError` error.\n *\n * @example <caption>Emit only the third click event</caption>\n * var clicks = Rx.Observable.fromEvent(document, 'click');\n * var result = clicks.elementAt(2);\n * result.subscribe(x => console.log(x));\n *\n * @see {@link first}\n * @see {@link last}\n * @see {@link skip}\n * @see {@link single}\n * @see {@link take}\n *\n * @throws {ArgumentOutOfRangeError} When using `elementAt(i)`, it delivers an\n * ArgumentOutOrRangeError to the Observer's `error` callback if `i < 0` or the\n * Observable has completed before emitting the i-th `next` notification.\n *\n * @param {number} index Is the number `i` for the i-th source emission that has\n * happened since the subscription, starting from the number `0`.\n * @param {T} [defaultValue] The default value returned for missing indices.\n * @return {Observable} An Observable that emits a single item, if it is found.\n * Otherwise, will emit the default value if given. If not, then emits an error.\n * @method elementAt\n * @owner Observable\n ",
"range": [
119,
1701
],
"loc": {
"start": {
"line": 3,
"column": 0
},
"end": {
"line": 39,
"column": 3
}
}
}
]
},
{
"type": "ExportNamedDeclaration",
"declaration": {
"type": "FunctionDeclaration",
"id": {
"type": "Identifier",
"name": "elementAt",
"range": [
1718,
1727
],
"loc": {
"start": {
"line": 40,
"column": 16
},
"end": {
"line": 40,
"column": 25
}
}
},
"params": [
{
"type": "Identifier",
"name": "index",
"range": [
1728,
1733
],
"loc": {
"start": {
"line": 40,
"column": 26
},
"end": {
"line": 40,
"column": 31
}
}
},
{
"type": "Identifier",
"name": "defaultValue",
"range": [
1735,
1747
],
"loc": {
"start": {
"line": 40,
"column": 33
},
"end": {
"line": 40,
"column": 45
}
}
}
],
"body": {
"type": "BlockStatement",
"body": [
{
"type": "ReturnStatement",
"argument": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "ThisExpression",
"range": [
1762,
1766
],
"loc": {
"start": {
"line": 41,
"column": 11
},
"end": {
"line": 41,
"column": 15
}
}
},
"property": {
"type": "Identifier",
"name": "lift",
"range": [
1767,
1771
],
"loc": {
"start": {
"line": 41,
"column": 16
},
"end": {
"line": 41,
"column": 20
}
}
},
"range": [
1762,
1771
],
"loc": {
"start": {
"line": 41,
"column": 11
},
"end": {
"line": 41,
"column": 20
}
}
},
"arguments": [
{
"type": "NewExpression",
"callee": {
"type": "Identifier",
"name": "ElementAtOperator",
"range": [
1776,
1793
],
"loc": {
"start": {
"line": 41,
"column": 25
},
"end": {
"line": 41,
"column": 42
}
}
},
"arguments": [
{
"type": "Identifier",
"name": "index",
"range": [
1794,
1799
],
"loc": {
"start": {
"line": 41,
"column": 43
},
"end": {
"line": 41,
"column": 48
}
}
},
{
"type": "Identifier",
"name": "defaultValue",
"range": [
1801,
1813
],
"loc": {
"start": {
"line": 41,
"column": 50
},
"end": {
"line": 41,
"column": 62
}
}
}
],
"range": [
1772,
1814
],
"loc": {
"start": {
"line": 41,
"column": 21
},
"end": {
"line": 41,
"column": 63
}
}
}
],
"range": [
1762,
1815
],
"loc": {
"start": {
"line": 41,
"column": 11
},
"end": {
"line": 41,
"column": 64
}
}
},
"range": [
1755,
1816
],
"loc": {
"start": {
"line": 41,
"column": 4
},
"end": {
"line": 41,
"column": 65
}
}
}
],
"range": [
1749,
1818
],
"loc": {
"start": {
"line": 40,
"column": 47
},
"end": {
"line": 42,
"column": 1
}
}
},
"generator": false,
"expression": false,
"range": [
1709,
1818
],
"loc": {
"start": {
"line": 40,
"column": 7
},
"end": {
"line": 42,
"column": 1
}
},
"leadingComments": [
{
"type": "Block",
"value": "*\n * Emits the single value at the specified `index` in a sequence of emissions\n * from the source Observable.\n *\n * <span class=\"informal\">Emits only the i-th value, then completes.</span>\n *\n * <img src=\"./img/elementAt.png\" width=\"100%\">\n *\n * `elementAt` returns an Observable that emits the item at the specified\n * `index` in the source Observable, or a default value if that `index` is out\n * of range and the `default` argument is provided. If the `default` argument is\n * not given and the `index` is out of range, the output Observable will emit an\n * `ArgumentOutOfRangeError` error.\n *\n * @example <caption>Emit only the third click event</caption>\n * var clicks = Rx.Observable.fromEvent(document, 'click');\n * var result = clicks.elementAt(2);\n * result.subscribe(x => console.log(x));\n *\n * @see {@link first}\n * @see {@link last}\n * @see {@link skip}\n * @see {@link single}\n * @see {@link take}\n *\n * @throws {ArgumentOutOfRangeError} When using `elementAt(i)`, it delivers an\n * ArgumentOutOrRangeError to the Observer's `error` callback if `i < 0` or the\n * Observable has completed before emitting the i-th `next` notification.\n *\n * @param {number} index Is the number `i` for the i-th source emission that has\n * happened since the subscription, starting from the number `0`.\n * @param {T} [defaultValue] The default value returned for missing indices.\n * @return {Observable} An Observable that emits a single item, if it is found.\n * Otherwise, will emit the default value if given. If not, then emits an error.\n * @method elementAt\n * @owner Observable\n ",
"range": [
119,
1701
],
"loc": {
"start": {
"line": 3,
"column": 0
},
"end": {
"line": 39,
"column": 3
}
}
}
],
"trailingComments": []
},
"specifiers": [],
"source": null,
"range": [
1702,
1818
],
"loc": {
"start": {
"line": 40,
"column": 0
},
"end": {
"line": 42,
"column": 1
}
},
"leadingComments": [
{
"type": "Block",
"value": "*\n * Emits the single value at the specified `index` in a sequence of emissions\n * from the source Observable.\n *\n * <span class=\"informal\">Emits only the i-th value, then completes.</span>\n *\n * <img src=\"./img/elementAt.png\" width=\"100%\">\n *\n * `elementAt` returns an Observable that emits the item at the specified\n * `index` in the source Observable, or a default value if that `index` is out\n * of range and the `default` argument is provided. If the `default` argument is\n * not given and the `index` is out of range, the output Observable will emit an\n * `ArgumentOutOfRangeError` error.\n *\n * @example <caption>Emit only the third click event</caption>\n * var clicks = Rx.Observable.fromEvent(document, 'click');\n * var result = clicks.elementAt(2);\n * result.subscribe(x => console.log(x));\n *\n * @see {@link first}\n * @see {@link last}\n * @see {@link skip}\n * @see {@link single}\n * @see {@link take}\n *\n * @throws {ArgumentOutOfRangeError} When using `elementAt(i)`, it delivers an\n * ArgumentOutOrRangeError to the Observer's `error` callback if `i < 0` or the\n * Observable has completed before emitting the i-th `next` notification.\n *\n * @param {number} index Is the number `i` for the i-th source emission that has\n * happened since the subscription, starting from the number `0`.\n * @param {T} [defaultValue] The default value returned for missing indices.\n * @return {Observable} An Observable that emits a single item, if it is found.\n * Otherwise, will emit the default value if given. If not, then emits an error.\n * @method elementAt\n * @owner Observable\n ",
"range": [
119,
1701
],
"loc": {
"start": {
"line": 3,
"column": 0
},
"end": {
"line": 39,
"column": 3
}
}
}
]
},
{
"type": "VariableDeclaration",
"declarations": [
{
"type": "VariableDeclarator",
"id": {
"type": "Identifier",
"name": "ElementAtOperator",
"range": [
1823,
1840
],
"loc": {
"start": {
"line": 43,
"column": 4
},
"end": {
"line": 43,
"column": 21
}
}
},
"init": {
"type": "CallExpression",
"callee": {
"type": "FunctionExpression",
"id": null,
"params": [],
"body": {
"type": "BlockStatement",
"body": [
{
"type": "FunctionDeclaration",
"id": {
"type": "Identifier",
"name": "ElementAtOperator",
"range": [
1871,
1888
],
"loc": {
"start": {
"line": 44,
"column": 13
},
"end": {
"line": 44,
"column": 30
}
}
},
"params": [
{
"type": "Identifier",
"name": "index",
"range": [
1889,
1894
],
"loc": {
"start": {
"line": 44,
"column": 31
},
"end": {
"line": 44,
"column": 36
}
}
},
{
"type": "Identifier",
"name": "defaultValue",
"range": [
1896,
1908
],
"loc": {
"start": {
"line": 44,
"column": 38
},
"end": {
"line": 44,
"column": 50
}
}
}
],
"body": {
"type": "BlockStatement",
"body": [
{
"type": "ExpressionStatement",
"expression": {
"type": "AssignmentExpression",
"operator": "=",
"left": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "ThisExpression",
"range": [
1920,
1924
],
"loc": {
"start": {
"line": 45,
"column": 8
},
"end": {
"line": 45,
"column": 12
}
}
},
"property": {
"type": "Identifier",
"name": "index",
"range": [
1925,
1930
],
"loc": {
"start": {
"line": 45,
"column": 13
},
"end": {
"line": 45,
"column": 18
}
}
},
"range": [
1920,
1930
],
"loc": {
"start": {
"line": 45,
"column": 8
},
"end": {
"line": 45,
"column": 18
}
}
},
"right": {
"type": "Identifier",
"name": "index",
"range": [
1933,
1938
],
"loc": {
"start": {
"line": 45,
"column": 21
},
"end": {
"line": 45,
"column": 26
}
}
},
"range": [
1920,
1938
],
"loc": {
"start": {
"line": 45,
"column": 8
},
"end": {
"line": 45,
"column": 26
}
}
},
"range": [
1920,
1939
],
"loc": {
"start": {
"line": 45,
"column": 8
},
"end": {
"line": 45,
"column": 27
}
}
},
{
"type": "ExpressionStatement",
"expression": {
"type": "AssignmentExpression",
"operator": "=",
"left": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "ThisExpression",
"range": [
1948,
1952
],
"loc": {
"start": {
"line": 46,
"column": 8
},
"end": {
"line": 46,
"column": 12
}
}
},
"property": {
"type": "Identifier",
"name": "defaultValue",
"range": [
1953,
1965
],
"loc": {
"start": {
"line": 46,
"column": 13
},
"end": {
"line": 46,
"column": 25
}
}
},
"range": [
1948,
1965
],
"loc": {
"start": {
"line": 46,
"column": 8
},
"end": {
"line": 46,
"column": 25
}
}
},
"right": {
"type": "Identifier",
"name": "defaultValue",
"range": [
1968,
1980
],
"loc": {
"start": {
"line": 46,
"column": 28
},
"end": {
"line": 46,
"column": 40
}
}
},
"range": [
1948,
1980
],
"loc": {
"start": {
"line": 46,
"column": 8
},
"end": {
"line": 46,
"column": 40
}
}
},
"range": [
1948,
1981
],
"loc": {
"start": {
"line": 46,
"column": 8
},
"end": {
"line": 46,
"column": 41
}
}
},
{
"type": "IfStatement",
"test": {
"type": "BinaryExpression",
"operator": "<",
"left": {
"type": "Identifier",
"name": "index",
"range": [
1994,
1999
],
"loc": {
"start": {
"line": 47,
"column": 12
},
"end": {
"line": 47,
"column": 17
}
}
},
"right": {
"type": "Literal",
"value": 0,
"raw": "0",
"range": [
2002,
2003
],
"loc": {
"start": {
"line": 47,
"column": 20
},
"end": {
"line": 47,
"column": 21
}
}
},
"range": [
1994,
2003
],
"loc": {
"start": {
"line": 47,
"column": 12
},
"end": {
"line": 47,
"column": 21
}
}
},
"consequent": {
"type": "BlockStatement",
"body": [
{
"type": "ThrowStatement",
"argument": {
"type": "NewExpression",
"callee": {
"type": "Identifier",
"name": "ArgumentOutOfRangeError",
"range": [
2029,
2052
],
"loc": {
"start": {
"line": 48,
"column": 22
},
"end": {
"line": 48,
"column": 45
}
}
},
"arguments": [],
"range": [
2025,
2052
],
"loc": {
"start": {
"line": 48,
"column": 18
},
"end": {
"line": 48,
"column": 45
}
}
},
"range": [
2019,
2053
],
"loc": {
"start": {
"line": 48,
"column": 12
},
"end": {
"line": 48,
"column": 46
}
}
}
],
"range": [
2005,
2063
],
"loc": {
"start": {
"line": 47,
"column": 23
},
"end": {
"line": 49,
"column": 9
}
}
},
"alternate": null,
"range": [
1990,
2063
],
"loc": {
"start": {
"line": 47,
"column": 8
},
"end": {
"line": 49,
"column": 9
}
}
}
],
"range": [
1910,
2069
],
"loc": {
"start": {
"line": 44,
"column": 52
},
"end": {
"line": 50,
"column": 5
}
}
},
"generator": false,
"expression": false,
"range": [
1862,
2069
],
"loc": {
"start": {
"line": 44,
"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": "ElementAtOperator",
"range": [
2074,
2091
],
"loc": {
"start": {
"line": 51,
"column": 4
},
"end": {
"line": 51,
"column": 21
}
}
},
"property": {
"type": "Identifier",
"name": "prototype",
"range": [
2092,
2101
],
"loc": {
"start": {
"line": 51,
"column": 22
},
"end": {
"line": 51,
"column": 31
}
}
},
"range": [
2074,
2101
],
"loc": {
"start": {
"line": 51,
"column": 4
},
"end": {
"line": 51,
"column": 31
}
}
},
"property": {
"type": "Identifier",
"name": "call",
"range": [
2102,
2106
],
"loc": {
"start": {
"line": 51,
"column": 32
},
"end": {
"line": 51,
"column": 36
}
}
},
"range": [
2074,
2106
],
"loc": {
"start": {
"line": 51,
"column": 4
},
"end": {
"line": 51,
"column": 36
}
}
},
"right": {
"type": "FunctionExpression",
"id": null,
"params": [
{
"type": "Identifier",
"name": "subscriber",
"range": [
2119,
2129
],
"loc": {
"start": {
"line": 51,
"column": 49
},
"end": {
"line": 51,
"column": 59
}
}
},
{
"type": "Identifier",
"name": "source",
"range": [
2131,
2137
],
"loc": {
"start": {
"line": 51,
"column": 61
},
"end": {
"line": 51,
"column": 67
}
}
}
],
"body": {
"type": "BlockStatement",
"body": [
{
"type": "ReturnStatement",
"argument": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "Identifier",
"name": "source",
"range": [
2156,
2162
],
"loc": {
"start": {
"line": 52,
"column": 15
},
"end": {
"line": 52,
"column": 21
}
}
},
"property": {
"type": "Identifier",
"name": "_subscribe",
"range": [
2163,
2173
],
"loc": {
"start": {
"line": 52,
"column": 22
},
"end": {
"line": 52,
"column": 32
}
}
},
"range": [
2156,
2173
],
"loc": {
"start": {
"line": 52,
"column": 15
},
"end": {
"line": 52,
"column": 32
}
}
},
"arguments": [
{
"type": "NewExpression",
"callee": {
"type": "Identifier",
"name": "ElementAtSubscriber",
"range": [
2178,
2197
],
"loc": {
"start": {
"line": 52,
"column": 37
},
"end": {
"line": 52,
"column": 56
}
}
},
"arguments": [
{
"type": "Identifier",
"name": "subscriber",
"range": [
2198,
2208
],
"loc": {
"start": {
"line": 52,
"column": 57
},
"end": {
"line": 52,
"column": 67
}
}
},
{
"type": "MemberExpression",
"computed": false,
"object": {
"type": "ThisExpression",
"range": [
2210,
2214
],
"loc": {
"start": {
"line": 52,
"column": 69
},
"end": {
"line": 52,
"column": 73
}
}
},
"property": {
"type": "Identifier",
"name": "index",
"range": [
2215,
2220
],
"loc": {
"start": {
"line": 52,
"column": 74
},
"end": {
"line": 52,
"column": 79
}
}
},
"range": [
2210,
2220
],
"loc": {
"start": {
"line": 52,
"column": 69
},
"end": {
"line": 52,
"column": 79
}
}
},
{
"type": "MemberExpression",
"computed": false,
"object": {
"type": "ThisExpression",
"range": [
2222,
2226
],
"loc": {
"start": {
"line": 52,
"column": 81
},
"end": {
"line": 52,
"column": 85
}
}
},
"property": {
"type": "Identifier",
"name": "defaultValue",
"range": [
2227,
2239
],
"loc": {
"start": {
"line": 52,
"column": 86
},
"end": {
"line": 52,
"column": 98
}
}
},
"range": [