@reactivex/rxjs
Version:
Reactive Extensions for modern JavaScript
1,309 lines (1,308 loc) • 140 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
}
},
"trailingComments": [
{
"type": "Block",
"value": "*\n * Applies a given `project` function to each value emitted by the source\n * Observable, and emits the resulting values as an Observable.\n *\n * <span class=\"informal\">Like [Array.prototype.map()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map),\n * it passes each source value through a transformation function to get\n * corresponding output values.</span>\n *\n * <img src=\"./img/map.png\" width=\"100%\">\n *\n * Similar to the well known `Array.prototype.map` function, this operator\n * applies a projection to each value and emits that projection in the output\n * Observable.\n *\n * @example <caption>Map every every click to the clientX position of that click</caption>\n * var clicks = Rx.Observable.fromEvent(document, 'click');\n * var positions = clicks.map(ev => ev.clientX);\n * positions.subscribe(x => console.log(x));\n *\n * @see {@link mapTo}\n * @see {@link pluck}\n *\n * @param {function(value: T, index: number): R} project The function to apply\n * to each `value` emitted by the source Observable. The `index` parameter is\n * the number `i` for the i-th emission that has happened since the\n * subscription, starting from the number `0`.\n * @param {any} [thisArg] An optional argument to define what `this` is in the\n * `project` function.\n * @return {Observable<R>} An Observable that emits the values from the source\n * Observable transformed by the given `project` function.\n * @method map\n * @owner Observable\n ",
"range": [
44,
1513
],
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 34,
"column": 3
}
}
}
]
},
{
"type": "ExportNamedDeclaration",
"declaration": {
"type": "FunctionDeclaration",
"id": {
"type": "Identifier",
"name": "map",
"range": [
1530,
1533
],
"loc": {
"start": {
"line": 35,
"column": 16
},
"end": {
"line": 35,
"column": 19
}
}
},
"params": [
{
"type": "Identifier",
"name": "project",
"range": [
1534,
1541
],
"loc": {
"start": {
"line": 35,
"column": 20
},
"end": {
"line": 35,
"column": 27
}
}
},
{
"type": "Identifier",
"name": "thisArg",
"range": [
1543,
1550
],
"loc": {
"start": {
"line": 35,
"column": 29
},
"end": {
"line": 35,
"column": 36
}
}
}
],
"body": {
"type": "BlockStatement",
"body": [
{
"type": "IfStatement",
"test": {
"type": "BinaryExpression",
"operator": "!==",
"left": {
"type": "UnaryExpression",
"operator": "typeof",
"argument": {
"type": "Identifier",
"name": "project",
"range": [
1569,
1576
],
"loc": {
"start": {
"line": 36,
"column": 15
},
"end": {
"line": 36,
"column": 22
}
}
},
"prefix": true,
"range": [
1562,
1576
],
"loc": {
"start": {
"line": 36,
"column": 8
},
"end": {
"line": 36,
"column": 22
}
}
},
"right": {
"type": "Literal",
"value": "function",
"raw": "'function'",
"range": [
1581,
1591
],
"loc": {
"start": {
"line": 36,
"column": 27
},
"end": {
"line": 36,
"column": 37
}
}
},
"range": [
1562,
1591
],
"loc": {
"start": {
"line": 36,
"column": 8
},
"end": {
"line": 36,
"column": 37
}
}
},
"consequent": {
"type": "BlockStatement",
"body": [
{
"type": "ThrowStatement",
"argument": {
"type": "NewExpression",
"callee": {
"type": "Identifier",
"name": "TypeError",
"range": [
1613,
1622
],
"loc": {
"start": {
"line": 37,
"column": 18
},
"end": {
"line": 37,
"column": 27
}
}
},
"arguments": [
{
"type": "Literal",
"value": "argument is not a function. Are you looking for `mapTo()`?",
"raw": "'argument is not a function. Are you looking for `mapTo()`?'",
"range": [
1623,
1683
],
"loc": {
"start": {
"line": 37,
"column": 28
},
"end": {
"line": 37,
"column": 88
}
}
}
],
"range": [
1609,
1684
],
"loc": {
"start": {
"line": 37,
"column": 14
},
"end": {
"line": 37,
"column": 89
}
}
},
"range": [
1603,
1685
],
"loc": {
"start": {
"line": 37,
"column": 8
},
"end": {
"line": 37,
"column": 90
}
}
}
],
"range": [
1593,
1691
],
"loc": {
"start": {
"line": 36,
"column": 39
},
"end": {
"line": 38,
"column": 5
}
}
},
"alternate": null,
"range": [
1558,
1691
],
"loc": {
"start": {
"line": 36,
"column": 4
},
"end": {
"line": 38,
"column": 5
}
}
},
{
"type": "ReturnStatement",
"argument": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "ThisExpression",
"range": [
1703,
1707
],
"loc": {
"start": {
"line": 39,
"column": 11
},
"end": {
"line": 39,
"column": 15
}
}
},
"property": {
"type": "Identifier",
"name": "lift",
"range": [
1708,
1712
],
"loc": {
"start": {
"line": 39,
"column": 16
},
"end": {
"line": 39,
"column": 20
}
}
},
"range": [
1703,
1712
],
"loc": {
"start": {
"line": 39,
"column": 11
},
"end": {
"line": 39,
"column": 20
}
}
},
"arguments": [
{
"type": "NewExpression",
"callee": {
"type": "Identifier",
"name": "MapOperator",
"range": [
1717,
1728
],
"loc": {
"start": {
"line": 39,
"column": 25
},
"end": {
"line": 39,
"column": 36
}
}
},
"arguments": [
{
"type": "Identifier",
"name": "project",
"range": [
1729,
1736
],
"loc": {
"start": {
"line": 39,
"column": 37
},
"end": {
"line": 39,
"column": 44
}
}
},
{
"type": "Identifier",
"name": "thisArg",
"range": [
1738,
1745
],
"loc": {
"start": {
"line": 39,
"column": 46
},
"end": {
"line": 39,
"column": 53
}
}
}
],
"range": [
1713,
1746
],
"loc": {
"start": {
"line": 39,
"column": 21
},
"end": {
"line": 39,
"column": 54
}
}
}
],
"range": [
1703,
1747
],
"loc": {
"start": {
"line": 39,
"column": 11
},
"end": {
"line": 39,
"column": 55
}
}
},
"range": [
1696,
1748
],
"loc": {
"start": {
"line": 39,
"column": 4
},
"end": {
"line": 39,
"column": 56
}
}
}
],
"range": [
1552,
1750
],
"loc": {
"start": {
"line": 35,
"column": 38
},
"end": {
"line": 40,
"column": 1
}
}
},
"generator": false,
"expression": false,
"range": [
1521,
1750
],
"loc": {
"start": {
"line": 35,
"column": 7
},
"end": {
"line": 40,
"column": 1
}
},
"leadingComments": [
{
"type": "Block",
"value": "*\n * Applies a given `project` function to each value emitted by the source\n * Observable, and emits the resulting values as an Observable.\n *\n * <span class=\"informal\">Like [Array.prototype.map()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map),\n * it passes each source value through a transformation function to get\n * corresponding output values.</span>\n *\n * <img src=\"./img/map.png\" width=\"100%\">\n *\n * Similar to the well known `Array.prototype.map` function, this operator\n * applies a projection to each value and emits that projection in the output\n * Observable.\n *\n * @example <caption>Map every every click to the clientX position of that click</caption>\n * var clicks = Rx.Observable.fromEvent(document, 'click');\n * var positions = clicks.map(ev => ev.clientX);\n * positions.subscribe(x => console.log(x));\n *\n * @see {@link mapTo}\n * @see {@link pluck}\n *\n * @param {function(value: T, index: number): R} project The function to apply\n * to each `value` emitted by the source Observable. The `index` parameter is\n * the number `i` for the i-th emission that has happened since the\n * subscription, starting from the number `0`.\n * @param {any} [thisArg] An optional argument to define what `this` is in the\n * `project` function.\n * @return {Observable<R>} An Observable that emits the values from the source\n * Observable transformed by the given `project` function.\n * @method map\n * @owner Observable\n ",
"range": [
44,
1513
],
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 34,
"column": 3
}
}
}
],
"trailingComments": []
},
"specifiers": [],
"source": null,
"range": [
1514,
1750
],
"loc": {
"start": {
"line": 35,
"column": 0
},
"end": {
"line": 40,
"column": 1
}
},
"leadingComments": [
{
"type": "Block",
"value": "*\n * Applies a given `project` function to each value emitted by the source\n * Observable, and emits the resulting values as an Observable.\n *\n * <span class=\"informal\">Like [Array.prototype.map()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map),\n * it passes each source value through a transformation function to get\n * corresponding output values.</span>\n *\n * <img src=\"./img/map.png\" width=\"100%\">\n *\n * Similar to the well known `Array.prototype.map` function, this operator\n * applies a projection to each value and emits that projection in the output\n * Observable.\n *\n * @example <caption>Map every every click to the clientX position of that click</caption>\n * var clicks = Rx.Observable.fromEvent(document, 'click');\n * var positions = clicks.map(ev => ev.clientX);\n * positions.subscribe(x => console.log(x));\n *\n * @see {@link mapTo}\n * @see {@link pluck}\n *\n * @param {function(value: T, index: number): R} project The function to apply\n * to each `value` emitted by the source Observable. The `index` parameter is\n * the number `i` for the i-th emission that has happened since the\n * subscription, starting from the number `0`.\n * @param {any} [thisArg] An optional argument to define what `this` is in the\n * `project` function.\n * @return {Observable<R>} An Observable that emits the values from the source\n * Observable transformed by the given `project` function.\n * @method map\n * @owner Observable\n ",
"range": [
44,
1513
],
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 34,
"column": 3
}
}
}
]
},
{
"type": "ExportNamedDeclaration",
"declaration": {
"type": "VariableDeclaration",
"declarations": [
{
"type": "VariableDeclarator",
"id": {
"type": "Identifier",
"name": "MapOperator",
"range": [
1762,
1773
],
"loc": {
"start": {
"line": 41,
"column": 11
},
"end": {
"line": 41,
"column": 22
}
}
},
"init": {
"type": "CallExpression",
"callee": {
"type": "FunctionExpression",
"id": null,
"params": [],
"body": {
"type": "BlockStatement",
"body": [
{
"type": "FunctionDeclaration",
"id": {
"type": "Identifier",
"name": "MapOperator",
"range": [
1804,
1815
],
"loc": {
"start": {
"line": 42,
"column": 13
},
"end": {
"line": 42,
"column": 24
}
}
},
"params": [
{
"type": "Identifier",
"name": "project",
"range": [
1816,
1823
],
"loc": {
"start": {
"line": 42,
"column": 25
},
"end": {
"line": 42,
"column": 32
}
}
},
{
"type": "Identifier",
"name": "thisArg",
"range": [
1825,
1832
],
"loc": {
"start": {
"line": 42,
"column": 34
},
"end": {
"line": 42,
"column": 41
}
}
}
],
"body": {
"type": "BlockStatement",
"body": [
{
"type": "ExpressionStatement",
"expression": {
"type": "AssignmentExpression",
"operator": "=",
"left": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "ThisExpression",
"range": [
1844,
1848
],
"loc": {
"start": {
"line": 43,
"column": 8
},
"end": {
"line": 43,
"column": 12
}
}
},
"property": {
"type": "Identifier",
"name": "project",
"range": [
1849,
1856
],
"loc": {
"start": {
"line": 43,
"column": 13
},
"end": {
"line": 43,
"column": 20
}
}
},
"range": [
1844,
1856
],
"loc": {
"start": {
"line": 43,
"column": 8
},
"end": {
"line": 43,
"column": 20
}
}
},
"right": {
"type": "Identifier",
"name": "project",
"range": [
1859,
1866
],
"loc": {
"start": {
"line": 43,
"column": 23
},
"end": {
"line": 43,
"column": 30
}
}
},
"range": [
1844,
1866
],
"loc": {
"start": {
"line": 43,
"column": 8
},
"end": {
"line": 43,
"column": 30
}
}
},
"range": [
1844,
1867
],
"loc": {
"start": {
"line": 43,
"column": 8
},
"end": {
"line": 43,
"column": 31
}
}
},
{
"type": "ExpressionStatement",
"expression": {
"type": "AssignmentExpression",
"operator": "=",
"left": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "ThisExpression",
"range": [
1876,
1880
],
"loc": {
"start": {
"line": 44,
"column": 8
},
"end": {
"line": 44,
"column": 12
}
}
},
"property": {
"type": "Identifier",
"name": "thisArg",
"range": [
1881,
1888
],
"loc": {
"start": {
"line": 44,
"column": 13
},
"end": {
"line": 44,
"column": 20
}
}
},
"range": [
1876,
1888
],
"loc": {
"start": {
"line": 44,
"column": 8
},
"end": {
"line": 44,
"column": 20
}
}
},
"right": {
"type": "Identifier",
"name": "thisArg",
"range": [
1891,
1898
],
"loc": {
"start": {
"line": 44,
"column": 23
},
"end": {
"line": 44,
"column": 30
}
}
},
"range": [
1876,
1898
],
"loc": {
"start": {
"line": 44,
"column": 8
},
"end": {
"line": 44,
"column": 30
}
}
},
"range": [
1876,
1899
],
"loc": {
"start": {
"line": 44,
"column": 8
},
"end": {
"line": 44,
"column": 31
}
}
}
],
"range": [
1834,
1905
],
"loc": {
"start": {
"line": 42,
"column": 43
},
"end": {
"line": 45,
"column": 5
}
}
},
"generator": false,
"expression": false,
"range": [
1795,
1905
],
"loc": {
"start": {
"line": 42,
"column": 4
},
"end": {
"line": 45,
"column": 5
}
}
},
{
"type": "ExpressionStatement",
"expression": {
"type": "AssignmentExpression",
"operator": "=",
"left": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "Identifier",
"name": "MapOperator",
"range": [
1910,
1921
],
"loc": {
"start": {
"line": 46,
"column": 4
},
"end": {
"line": 46,
"column": 15
}
}
},
"property": {
"type": "Identifier",
"name": "prototype",
"range": [
1922,
1931
],
"loc": {
"start": {
"line": 46,
"column": 16
},
"end": {
"line": 46,
"column": 25
}
}
},
"range": [
1910,
1931
],
"loc": {
"start": {
"line": 46,
"column": 4
},
"end": {
"line": 46,
"column": 25
}
}
},
"property": {
"type": "Identifier",
"name": "call",
"range": [
1932,
1936
],
"loc": {
"start": {
"line": 46,
"column": 26
},
"end": {
"line": 46,
"column": 30
}
}
},
"range": [
1910,
1936
],
"loc": {
"start": {
"line": 46,
"column": 4
},
"end": {
"line": 46,
"column": 30
}
}
},
"right": {
"type": "FunctionExpression",
"id": null,
"params": [
{
"type": "Identifier",
"name": "subscriber",
"range": [
1949,
1959
],
"loc": {
"start": {
"line": 46,
"column": 43
},
"end": {
"line": 46,
"column": 53
}
}
},
{
"type": "Identifier",
"name": "source",
"range": [
1961,
1967
],
"loc": {
"start": {
"line": 46,
"column": 55
},
"end": {
"line": 46,
"column": 61
}
}
}
],
"body": {
"type": "BlockStatement",
"body": [
{
"type": "ReturnStatement",
"argument": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "Identifier",
"name": "source",
"range": [
1986,
1992
],
"loc": {
"start": {
"line": 47,
"column": 15
},
"end": {
"line": 47,
"column": 21
}
}
},
"property": {
"type": "Identifier",
"name": "_subscribe",
"range": [
1993,
2003
],
"loc": {
"start": {
"line": 47,
"column": 22
},
"end": {
"line": 47,
"column": 32
}
}
},
"range": [
1986,
2003
],
"loc": {
"start": {
"line": 47,
"column": 15
},
"end": {
"line": 47,
"column": 32
}
}
},
"arguments": [
{
"type": "NewExpression",
"callee": {
"type": "Identifier",
"name": "MapSubscriber",
"range": [
2008,
2021
],
"loc": {
"start": {
"line": 47,
"column": 37
},
"end": {
"line": 47,
"column": 50
}
}
},
"arguments": [
{
"type": "Identifier",
"name": "subscriber",
"range": [
2022,
2032
],
"loc": {
"start": {
"line": 47,
"column": 51
},
"end": {
"line": 47,
"column": 61
}
}
},
{
"type": "MemberExpression",
"computed": false,
"object": {
"type": "ThisExpression",
"range": [
2034,
2038
],
"loc": {
"start": {
"line": 47,
"column": 63
},
"end": {
"line": 47,
"column": 67
}
}
},
"property": {
"type": "Identifier",
"name": "project",
"range": [
2039,
2046
],
"loc": {
"start": {
"line": 47,
"column": 68
},
"end": {
"line": 47,
"column": 75
}
}
},
"range": [
2034,
2046
],
"loc": {
"start": {
"line": 47,
"column": 63
},
"end": {
"line": 47,
"column": 75
}
}
},
{
"type": "MemberExpression",
"computed": false,
"object": {
"type": "ThisExpression",
"range": [
2048,
2052
],
"loc": {
"start": {
"line": 47,
"column": 77
},
"end": {
"line": 47,
"column": 81
}
}
},
"property": {
"type": "Identifier",
"name": "thisArg",
"range": [
2053,
2060
],
"loc": {
"start": {
"line": 47,
"column": 82
},
"end": {
"line": 47,
"column": 89
}
}
},
"range": [
2048,
2060
],
"loc": {
"start": {
"line": 47,
"column": 77
},
"end": {
"line": 47,
"column": 89
}
}
}
],
"range": [
2004,
2061
],
"loc": {
"start": {
"line": 47,
"column": 33
},
"end": {