UNPKG

@reactivex/rxjs

Version:

Reactive Extensions for modern JavaScript

1,401 lines (1,400 loc) 623 kB
{ "type": "Program", "body": [ { "type": "ImportDeclaration", "specifiers": [ { "type": "ImportSpecifier", "local": { "type": "Identifier", "name": "Observable", "range": [ 9, 19 ], "loc": { "start": { "line": 1, "column": 9 }, "end": { "line": 1, "column": 19 } } }, "imported": { "type": "Identifier", "name": "Observable", "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": "../Observable", "raw": "'../Observable'", "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": "tryCatch", "range": [ 53, 61 ], "loc": { "start": { "line": 2, "column": 9 }, "end": { "line": 2, "column": 17 } } }, "imported": { "type": "Identifier", "name": "tryCatch", "range": [ 53, 61 ], "loc": { "start": { "line": 2, "column": 9 }, "end": { "line": 2, "column": 17 } } }, "range": [ 53, 61 ], "loc": { "start": { "line": 2, "column": 9 }, "end": { "line": 2, "column": 17 } } } ], "source": { "type": "Literal", "value": "../util/tryCatch", "raw": "'../util/tryCatch'", "range": [ 69, 87 ], "loc": { "start": { "line": 2, "column": 25 }, "end": { "line": 2, "column": 43 } } }, "range": [ 44, 88 ], "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 2, "column": 44 } } }, { "type": "ImportDeclaration", "specifiers": [ { "type": "ImportSpecifier", "local": { "type": "Identifier", "name": "errorObject", "range": [ 98, 109 ], "loc": { "start": { "line": 3, "column": 9 }, "end": { "line": 3, "column": 20 } } }, "imported": { "type": "Identifier", "name": "errorObject", "range": [ 98, 109 ], "loc": { "start": { "line": 3, "column": 9 }, "end": { "line": 3, "column": 20 } } }, "range": [ 98, 109 ], "loc": { "start": { "line": 3, "column": 9 }, "end": { "line": 3, "column": 20 } } } ], "source": { "type": "Literal", "value": "../util/errorObject", "raw": "'../util/errorObject'", "range": [ 117, 138 ], "loc": { "start": { "line": 3, "column": 28 }, "end": { "line": 3, "column": 49 } } }, "range": [ 89, 139 ], "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 3, "column": 50 } } }, { "type": "ImportDeclaration", "specifiers": [ { "type": "ImportSpecifier", "local": { "type": "Identifier", "name": "AsyncSubject", "range": [ 149, 161 ], "loc": { "start": { "line": 4, "column": 9 }, "end": { "line": 4, "column": 21 } } }, "imported": { "type": "Identifier", "name": "AsyncSubject", "range": [ 149, 161 ], "loc": { "start": { "line": 4, "column": 9 }, "end": { "line": 4, "column": 21 } } }, "range": [ 149, 161 ], "loc": { "start": { "line": 4, "column": 9 }, "end": { "line": 4, "column": 21 } } } ], "source": { "type": "Literal", "value": "../AsyncSubject", "raw": "'../AsyncSubject'", "range": [ 169, 186 ], "loc": { "start": { "line": 4, "column": 29 }, "end": { "line": 4, "column": 46 } } }, "range": [ 140, 187 ], "loc": { "start": { "line": 4, "column": 0 }, "end": { "line": 4, "column": 47 } }, "trailingComments": [ { "type": "Block", "value": "*\n * We need this JSDoc comment for affecting ESDoc.\n * @extends {Ignored}\n * @hide true\n ", "range": [ 188, 282 ], "loc": { "start": { "line": 5, "column": 0 }, "end": { "line": 9, "column": 3 } } } ] }, { "type": "ExportNamedDeclaration", "declaration": { "type": "VariableDeclaration", "declarations": [ { "type": "VariableDeclarator", "id": { "type": "Identifier", "name": "BoundNodeCallbackObservable", "range": [ 294, 321 ], "loc": { "start": { "line": 10, "column": 11 }, "end": { "line": 10, "column": 38 } } }, "init": { "type": "CallExpression", "callee": { "type": "FunctionExpression", "id": null, "params": [ { "type": "Identifier", "name": "_super", "range": [ 335, 341 ], "loc": { "start": { "line": 10, "column": 52 }, "end": { "line": 10, "column": 58 } } } ], "body": { "type": "BlockStatement", "body": [ { "type": "ExpressionStatement", "expression": { "type": "CallExpression", "callee": { "type": "Identifier", "name": "__extends", "range": [ 349, 358 ], "loc": { "start": { "line": 11, "column": 4 }, "end": { "line": 11, "column": 13 } } }, "arguments": [ { "type": "Identifier", "name": "BoundNodeCallbackObservable", "range": [ 359, 386 ], "loc": { "start": { "line": 11, "column": 14 }, "end": { "line": 11, "column": 41 } } }, { "type": "Identifier", "name": "_super", "range": [ 388, 394 ], "loc": { "start": { "line": 11, "column": 43 }, "end": { "line": 11, "column": 49 } } } ], "range": [ 349, 395 ], "loc": { "start": { "line": 11, "column": 4 }, "end": { "line": 11, "column": 50 } } }, "range": [ 349, 396 ], "loc": { "start": { "line": 11, "column": 4 }, "end": { "line": 11, "column": 51 } } }, { "type": "FunctionDeclaration", "id": { "type": "Identifier", "name": "BoundNodeCallbackObservable", "range": [ 410, 437 ], "loc": { "start": { "line": 12, "column": 13 }, "end": { "line": 12, "column": 40 } } }, "params": [ { "type": "Identifier", "name": "callbackFunc", "range": [ 438, 450 ], "loc": { "start": { "line": 12, "column": 41 }, "end": { "line": 12, "column": 53 } } }, { "type": "Identifier", "name": "selector", "range": [ 452, 460 ], "loc": { "start": { "line": 12, "column": 55 }, "end": { "line": 12, "column": 63 } } }, { "type": "Identifier", "name": "args", "range": [ 462, 466 ], "loc": { "start": { "line": 12, "column": 65 }, "end": { "line": 12, "column": 69 } } }, { "type": "Identifier", "name": "scheduler", "range": [ 468, 477 ], "loc": { "start": { "line": 12, "column": 71 }, "end": { "line": 12, "column": 80 } } } ], "body": { "type": "BlockStatement", "body": [ { "type": "ExpressionStatement", "expression": { "type": "CallExpression", "callee": { "type": "MemberExpression", "computed": false, "object": { "type": "Identifier", "name": "_super", "range": [ 489, 495 ], "loc": { "start": { "line": 13, "column": 8 }, "end": { "line": 13, "column": 14 } } }, "property": { "type": "Identifier", "name": "call", "range": [ 496, 500 ], "loc": { "start": { "line": 13, "column": 15 }, "end": { "line": 13, "column": 19 } } }, "range": [ 489, 500 ], "loc": { "start": { "line": 13, "column": 8 }, "end": { "line": 13, "column": 19 } } }, "arguments": [ { "type": "ThisExpression", "range": [ 501, 505 ], "loc": { "start": { "line": 13, "column": 20 }, "end": { "line": 13, "column": 24 } } } ], "range": [ 489, 506 ], "loc": { "start": { "line": 13, "column": 8 }, "end": { "line": 13, "column": 25 } } }, "range": [ 489, 507 ], "loc": { "start": { "line": 13, "column": 8 }, "end": { "line": 13, "column": 26 } } }, { "type": "ExpressionStatement", "expression": { "type": "AssignmentExpression", "operator": "=", "left": { "type": "MemberExpression", "computed": false, "object": { "type": "ThisExpression", "range": [ 516, 520 ], "loc": { "start": { "line": 14, "column": 8 }, "end": { "line": 14, "column": 12 } } }, "property": { "type": "Identifier", "name": "callbackFunc", "range": [ 521, 533 ], "loc": { "start": { "line": 14, "column": 13 }, "end": { "line": 14, "column": 25 } } }, "range": [ 516, 533 ], "loc": { "start": { "line": 14, "column": 8 }, "end": { "line": 14, "column": 25 } } }, "right": { "type": "Identifier", "name": "callbackFunc", "range": [ 536, 548 ], "loc": { "start": { "line": 14, "column": 28 }, "end": { "line": 14, "column": 40 } } }, "range": [ 516, 548 ], "loc": { "start": { "line": 14, "column": 8 }, "end": { "line": 14, "column": 40 } } }, "range": [ 516, 549 ], "loc": { "start": { "line": 14, "column": 8 }, "end": { "line": 14, "column": 41 } } }, { "type": "ExpressionStatement", "expression": { "type": "AssignmentExpression", "operator": "=", "left": { "type": "MemberExpression", "computed": false, "object": { "type": "ThisExpression", "range": [ 558, 562 ], "loc": { "start": { "line": 15, "column": 8 }, "end": { "line": 15, "column": 12 } } }, "property": { "type": "Identifier", "name": "selector", "range": [ 563, 571 ], "loc": { "start": { "line": 15, "column": 13 }, "end": { "line": 15, "column": 21 } } }, "range": [ 558, 571 ], "loc": { "start": { "line": 15, "column": 8 }, "end": { "line": 15, "column": 21 } } }, "right": { "type": "Identifier", "name": "selector", "range": [ 574, 582 ], "loc": { "start": { "line": 15, "column": 24 }, "end": { "line": 15, "column": 32 } } }, "range": [ 558, 582 ], "loc": { "start": { "line": 15, "column": 8 }, "end": { "line": 15, "column": 32 } } }, "range": [ 558, 583 ], "loc": { "start": { "line": 15, "column": 8 }, "end": { "line": 15, "column": 33 } } }, { "type": "ExpressionStatement", "expression": { "type": "AssignmentExpression", "operator": "=", "left": { "type": "MemberExpression", "computed": false, "object": { "type": "ThisExpression", "range": [ 592, 596 ], "loc": { "start": { "line": 16, "column": 8 }, "end": { "line": 16, "column": 12 } } }, "property": { "type": "Identifier", "name": "args", "range": [ 597, 601 ], "loc": { "start": { "line": 16, "column": 13 }, "end": { "line": 16, "column": 17 } } }, "range": [ 592, 601 ], "loc": { "start": { "line": 16, "column": 8 }, "end": { "line": 16, "column": 17 } } }, "right": { "type": "Identifier", "name": "args", "range": [ 604, 608 ], "loc": { "start": { "line": 16, "column": 20 }, "end": { "line": 16, "column": 24 } } }, "range": [ 592, 608 ], "loc": { "start": { "line": 16, "column": 8 }, "end": { "line": 16, "column": 24 } } }, "range": [ 592, 609 ], "loc": { "start": { "line": 16, "column": 8 }, "end": { "line": 16, "column": 25 } } }, { "type": "ExpressionStatement", "expression": { "type": "AssignmentExpression", "operator": "=", "left": { "type": "MemberExpression", "computed": false, "object": { "type": "ThisExpression", "range": [ 618, 622 ], "loc": { "start": { "line": 17, "column": 8 }, "end": { "line": 17, "column": 12 } } }, "property": { "type": "Identifier", "name": "scheduler", "range": [ 623, 632 ], "loc": { "start": { "line": 17, "column": 13 }, "end": { "line": 17, "column": 22 } } }, "range": [ 618, 632 ], "loc": { "start": { "line": 17, "column": 8 }, "end": { "line": 17, "column": 22 } } }, "right": { "type": "Identifier", "name": "scheduler", "range": [ 635, 644 ], "loc": { "start": { "line": 17, "column": 25 }, "end": { "line": 17, "column": 34 } } }, "range": [ 618, 644 ], "loc": { "start": { "line": 17, "column": 8 }, "end": { "line": 17, "column": 34 } } }, "range": [ 618, 645 ], "loc": { "start": { "line": 17, "column": 8 }, "end": { "line": 17, "column": 35 } } } ], "range": [ 479, 651 ], "loc": { "start": { "line": 12, "column": 82 }, "end": { "line": 18, "column": 5 } } }, "generator": false, "expression": false, "range": [ 401, 651 ], "loc": { "start": { "line": 12, "column": 4 }, "end": { "line": 18, "column": 5 } }, "trailingComments": [ { "type": "Block", "value": " tslint:enable:max-line-length ", "range": [ 656, 691 ], "loc": { "start": { "line": 19, "column": 4 }, "end": { "line": 19, "column": 39 } } }, { "type": "Block", "value": "*\n * Converts a Node.js-style callback API to a function that returns an\n * Observable.\n *\n * <span class=\"informal\">It's just like {@link bindCallback}, but the\n * callback is expected to be of type `callback(error, result)`.</span>\n *\n * `bindNodeCallback` is not an operator because its input and output are not\n * Observables. The input is a function `func` with some parameters, but the\n * last parameter must be a callback function that `func` calls when it is\n * done. The callback function is expected to follow Node.js conventions,\n * where the first argument to the callback is an error, while remaining\n * arguments are the callback result. The output of `bindNodeCallback` is a\n * function that takes the same parameters as `func`, except the last one (the\n * callback). When the output function is called with arguments, it will\n * return an Observable where the results will be delivered to.\n *\n * @example <caption>Read a file from the filesystem and get the data as an Observable</caption>\n * import * as fs from 'fs';\n * var readFileAsObservable = Rx.Observable.bindNodeCallback(fs.readFile);\n * var result = readFileAsObservable('./roadNames.txt', 'utf8');\n * result.subscribe(x => console.log(x), e => console.error(e));\n *\n * @see {@link bindCallback}\n * @see {@link from}\n * @see {@link fromPromise}\n *\n * @param {function} func Function with a callback as the last parameter.\n * @param {function} [selector] A function which takes the arguments from the\n * callback and maps those a value to emit on the output Observable.\n * @param {Scheduler} [scheduler] The scheduler on which to schedule the\n * callbacks.\n * @return {function(...params: *): Observable} A function which returns the\n * Observable that delivers the same values the Node.js callback would\n * deliver.\n * @static true\n * @name bindNodeCallback\n * @owner Observable\n ", "range": [ 696, 2708 ], "loc": { "start": { "line": 20, "column": 4 }, "end": { "line": 58, "column": 7 } } } ] }, { "type": "ExpressionStatement", "expression": { "type": "AssignmentExpression", "operator": "=", "left": { "type": "MemberExpression", "computed": false, "object": { "type": "Identifier", "name": "BoundNodeCallbackObservable", "range": [ 2713, 2740 ], "loc": { "start": { "line": 59, "column": 4 }, "end": { "line": 59, "column": 31 } } }, "property": { "type": "Identifier", "name": "create", "range": [ 2741, 2747 ], "loc": { "start": { "line": 59, "column": 32 }, "end": { "line": 59, "column": 38 } } }, "range": [ 2713, 2747 ], "loc": { "start": { "line": 59, "column": 4 }, "end": { "line": 59, "column": 38 } } }, "right": { "type": "FunctionExpression", "id": null, "params": [ { "type": "Identifier", "name": "func", "range": [ 2760, 2764 ], "loc": { "start": { "line": 59, "column": 51 }, "end": { "line": 59, "column": 55 } } }, { "type": "Identifier", "name": "selector", "range": [ 2766, 2774 ], "loc": { "start": { "line": 59, "column": 57 }, "end": { "line": 59, "column": 65 } } }, { "type": "Identifier", "name": "scheduler", "range": [ 2776, 2785 ], "loc": { "start": { "line": 59, "column": 67 }, "end": { "line": 59, "column": 76 } } } ], "body": { "type": "BlockStatement", "body": [ { "type": "IfStatement", "test": { "type": "BinaryExpression", "operator": "===", "left": { "type": "Identifier", "name": "selector", "range": [ 2801, 2809 ], "loc": { "start": { "line": 60, "column": 12 }, "end": { "line": 60, "column": 20 } } }, "right": { "type": "UnaryExpression", "operator": "void", "argument": { "type": "Literal", "value": 0, "raw": "0", "range": [ 2819, 2820 ], "loc": { "start": { "line": 60, "column": 30 }, "end": { "line": 60, "column": 31 } } }, "prefix": true, "range": [ 2814, 2820 ],