UNPKG

monad-ts

Version:

Monad-ts is a small library implements some of key monads and way to chain them in a pipe (flow) in JavaScript and TypeScript. Angular 2+ compatible.

1,387 lines 92.8 kB
{ "type": "File", "start": 0, "end": 783, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 25, "column": 0 } }, "program": { "type": "Program", "start": 0, "end": 783, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 25, "column": 0 } }, "sourceType": "module", "body": [ { "type": "ExportNamedDeclaration", "start": 294, "end": 720, "loc": { "start": { "line": 9, "column": 0 }, "end": { "line": 23, "column": 1 } }, "specifiers": [], "source": null, "declaration": { "type": "FunctionDeclaration", "start": 301, "end": 720, "loc": { "start": { "line": 9, "column": 7 }, "end": { "line": 23, "column": 1 } }, "id": { "type": "Identifier", "start": 310, "end": 322, "loc": { "start": { "line": 9, "column": 16 }, "end": { "line": 9, "column": 28 }, "identifierName": "debounceTime" }, "name": "debounceTime", "leadingComments": null }, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 323, "end": 324, "loc": { "start": { "line": 9, "column": 29 }, "end": { "line": 9, "column": 30 }, "identifierName": "f" }, "name": "f" }, { "type": "Identifier", "start": 326, "end": 327, "loc": { "start": { "line": 9, "column": 32 }, "end": { "line": 9, "column": 33 }, "identifierName": "d" }, "name": "d" }, { "type": "AssignmentPattern", "start": 329, "end": 345, "loc": { "start": { "line": 9, "column": 35 }, "end": { "line": 9, "column": 51 } }, "left": { "type": "Identifier", "start": 329, "end": 338, "loc": { "start": { "line": 9, "column": 35 }, "end": { "line": 9, "column": 44 }, "identifierName": "immediate" }, "name": "immediate" }, "right": { "type": "BooleanLiteral", "start": 341, "end": 345, "loc": { "start": { "line": 9, "column": 47 }, "end": { "line": 9, "column": 51 } }, "value": true } } ], "body": { "type": "BlockStatement", "start": 347, "end": 720, "loc": { "start": { "line": 9, "column": 53 }, "end": { "line": 23, "column": 1 } }, "body": [ { "type": "VariableDeclaration", "start": 354, "end": 366, "loc": { "start": { "line": 10, "column": 4 }, "end": { "line": 10, "column": 16 } }, "declarations": [ { "type": "VariableDeclarator", "start": 358, "end": 365, "loc": { "start": { "line": 10, "column": 8 }, "end": { "line": 10, "column": 15 } }, "id": { "type": "Identifier", "start": 358, "end": 365, "loc": { "start": { "line": 10, "column": 8 }, "end": { "line": 10, "column": 15 }, "identifierName": "timeout" }, "name": "timeout" }, "init": null } ], "kind": "let" }, { "type": "ReturnStatement", "start": 372, "end": 717, "loc": { "start": { "line": 11, "column": 4 }, "end": { "line": 22, "column": 6 } }, "argument": { "type": "ArrowFunctionExpression", "start": 379, "end": 716, "loc": { "start": { "line": 11, "column": 11 }, "end": { "line": 22, "column": 5 } }, "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "RestElement", "start": 380, "end": 387, "loc": { "start": { "line": 11, "column": 12 }, "end": { "line": 11, "column": 19 } }, "argument": { "type": "Identifier", "start": 383, "end": 387, "loc": { "start": { "line": 11, "column": 15 }, "end": { "line": 11, "column": 19 }, "identifierName": "args" }, "name": "args" } } ], "body": { "type": "BlockStatement", "start": 392, "end": 716, "loc": { "start": { "line": 11, "column": 24 }, "end": { "line": 22, "column": 5 } }, "body": [ { "type": "VariableDeclaration", "start": 403, "end": 532, "loc": { "start": { "line": 12, "column": 8 }, "end": { "line": 16, "column": 10 } }, "declarations": [ { "type": "VariableDeclarator", "start": 409, "end": 531, "loc": { "start": { "line": 12, "column": 14 }, "end": { "line": 16, "column": 9 } }, "id": { "type": "Identifier", "start": 409, "end": 414, "loc": { "start": { "line": 12, "column": 14 }, "end": { "line": 12, "column": 19 }, "identifierName": "later" }, "name": "later" }, "init": { "type": "ArrowFunctionExpression", "start": 417, "end": 531, "loc": { "start": { "line": 12, "column": 22 }, "end": { "line": 16, "column": 9 } }, "id": null, "generator": false, "expression": false, "async": false, "params": [], "body": { "type": "BlockStatement", "start": 423, "end": 531, "loc": { "start": { "line": 12, "column": 28 }, "end": { "line": 16, "column": 9 } }, "body": [ { "type": "ExpressionStatement", "start": 438, "end": 453, "loc": { "start": { "line": 13, "column": 12 }, "end": { "line": 13, "column": 27 } }, "expression": { "type": "AssignmentExpression", "start": 438, "end": 452, "loc": { "start": { "line": 13, "column": 12 }, "end": { "line": 13, "column": 26 } }, "operator": "=", "left": { "type": "Identifier", "start": 438, "end": 445, "loc": { "start": { "line": 13, "column": 12 }, "end": { "line": 13, "column": 19 }, "identifierName": "timeout" }, "name": "timeout" }, "right": { "type": "NullLiteral", "start": 448, "end": 452, "loc": { "start": { "line": 13, "column": 22 }, "end": { "line": 13, "column": 26 } } } } }, { "type": "IfStatement", "start": 467, "end": 520, "loc": { "start": { "line": 14, "column": 12 }, "end": { "line": 15, "column": 36 } }, "test": { "type": "UnaryExpression", "start": 471, "end": 481, "loc": { "start": { "line": 14, "column": 16 }, "end": { "line": 14, "column": 26 } }, "operator": "!", "prefix": true, "argument": { "type": "Identifier", "start": 472, "end": 481, "loc": { "start": { "line": 14, "column": 17 }, "end": { "line": 14, "column": 26 }, "identifierName": "immediate" }, "name": "immediate" }, "extra": { "parenthesizedArgument": false } }, "consequent": { "type": "ExpressionStatement", "start": 500, "end": 520, "loc": { "start": { "line": 15, "column": 16 }, "end": { "line": 15, "column": 36 } }, "expression": { "type": "CallExpression", "start": 500, "end": 519, "loc": { "start": { "line": 15, "column": 16 }, "end": { "line": 15, "column": 35 } }, "callee": { "type": "MemberExpression", "start": 500, "end": 507, "loc": { "start": { "line": 15, "column": 16 }, "end": { "line": 15, "column": 23 } }, "object": { "type": "Identifier", "start": 500, "end": 501, "loc": { "start": { "line": 15, "column": 16 }, "end": { "line": 15, "column": 17 }, "identifierName": "f" }, "name": "f" }, "property": { "type": "Identifier", "start": 502, "end": 507, "loc": { "start": { "line": 15, "column": 18 }, "end": { "line": 15, "column": 23 }, "identifierName": "apply" }, "name": "apply" }, "computed": false }, "arguments": [ { "type": "ThisExpression", "start": 508, "end": 512, "loc": { "start": { "line": 15, "column": 24 }, "end": { "line": 15, "column": 28 } } }, { "type": "Identifier", "start": 514, "end": 518, "loc": { "start": { "line": 15, "column": 30 }, "end": { "line": 15, "column": 34 }, "identifierName": "args" }, "name": "args" } ] } }, "alternate": null } ], "directives": [] } } } ], "kind": "const" }, { "type": "VariableDeclaration", "start": 542, "end": 580, "loc": { "start": { "line": 17, "column": 8 }, "end": { "line": 17, "column": 46 } }, "declarations": [ { "type": "VariableDeclarator", "start": 548, "end": 579, "loc": { "start": { "line": 17, "column": 14 }, "end": { "line": 17, "column": 45 } }, "id": { "type": "Identifier", "start": 548, "end": 555, "loc": { "start": { "line": 17, "column": 14 }, "end": { "line": 17, "column": 21 }, "identifierName": "callNow" }, "name": "callNow" }, "init": { "type": "LogicalExpression", "start": 558, "end": 579, "loc": { "start": { "line": 17, "column": 24 }, "end": { "line": 17, "column": 45 } }, "left": { "type": "Identifier", "start": 558, "end": 567, "loc": { "start": { "line": 17, "column": 24 }, "end": { "line": 17, "column": 33 }, "identifierName": "immediate" }, "name": "immediate" }, "operator": "&&", "right": { "type": "UnaryExpression", "start": 571, "end": 579, "loc": { "start": { "line": 17, "column": 37 }, "end": { "line": 17, "column": 45 } }, "operator": "!", "prefix": true, "argument": { "type": "Identifier", "start": 572, "end": 579, "loc": { "start": { "line": 17, "column": 38 }, "end": { "line": 17, "column": 45 }, "identifierName": "timeout" }, "name": "timeout" }, "extra": { "parenthesizedArgument": false } } } } ], "kind": "const" }, { "type": "ExpressionStatement", "start": 590, "end": 612, "loc": { "start": { "line": 18, "column": 8 }, "end": { "line": 18, "column": 30 } }, "expression": { "type": "CallExpression", "start": 590, "end": 611, "loc": { "start": { "line": 18, "column": 8 }, "end": { "line": 18, "column": 29 } }, "callee": { "type": "Identifier", "start": 590, "end": 602, "loc": { "start": { "line": 18, "column": 8 }, "end": { "line": 18, "column": 20 }, "identifierName": "clearTimeout" }, "name": "clearTimeout" }, "arguments": [ { "type": "Identifier", "start": 603, "end": 610, "loc": { "start": { "line": 18, "column": 21 }, "end": { "line": 18, "column": 28 }, "identifierName": "timeout" }, "name": "timeout" } ] } }, { "type": "ExpressionStatement", "start": 622, "end": 653, "loc": { "start": { "line": 19, "column": 8 }, "end": { "line": 19, "column": 39 } }, "expression": { "type": "AssignmentExpression", "start": 622, "end": 652, "loc": { "start": { "line": 19, "column": 8 }, "end": { "line": 19, "column": 38 } }, "operator": "=", "left": { "type": "Identifier", "start": 622, "end": 629, "loc": { "start": { "line": 19, "column": 8 }, "end": { "line": 19, "column": 15 }, "identifierName": "timeout" }, "name": "timeout" }, "right": { "type": "CallExpression", "start": 632, "end": 652, "loc": { "start": { "line": 19, "column": 18 }, "end": { "line": 19, "column": 38 } }, "callee": { "type": "Identifier", "start": 632, "end": 642, "loc": { "start": { "line": 19, "column": 18 }, "end": { "line": 19, "column": 28 }, "identifierName": "setTimeout" }, "name": "setTimeout" }, "arguments": [ { "type": "Identifier", "start": 643, "end": 648, "loc": { "start": { "line": 19, "column": 29 }, "end": { "line": 19, "column": 34 }, "identifierName": "later" }, "name": "later" }, { "type": "Identifier", "start": 650, "end": 651, "loc": { "start": { "line": 19, "column": 36 }, "end": { "line": 19, "column": 37 }, "identifierName": "d" }, "name": "d" } ] } } }, { "type": "IfStatement", "start": 663, "end": 709, "loc": { "start": { "line": 20, "column": 8 }, "end": { "line": 21, "column": 32 } }, "test": { "type": "Identifier", "start": 667, "end": 674, "loc": { "start": { "line": 20, "column": 12 }, "end": { "line": 20, "column": 19 }, "identifierName": "callNow" }, "name": "callNow" }, "consequent": { "type": "ExpressionStatement", "start": 689, "end": 709, "loc": { "start": { "line": 21, "column": 12 }, "end": { "line": 21, "column": 32 } }, "expression": { "type": "CallExpression", "start": 689, "end": 708, "loc": { "start": { "line": 21, "column": 12 }, "end": { "line": 21, "column": 31 } }, "callee": { "type": "MemberExpression", "start": 689, "end": 696, "loc": { "start": { "line": 21, "column": 12 }, "end": { "line": 21, "column": 19 } }, "object": { "type": "Identifier", "start": 689, "end": 690, "loc": { "start": { "line": 21, "column": 12 }, "end": { "line": 21, "column": 13 }, "identifierName": "f" }, "name": "f" }, "property": { "type": "Identifier", "start": 691, "end": 696, "loc": { "start": { "line": 21, "column": 14 }, "end": { "line": 21, "column": 19 }, "identifierName": "apply" }, "name": "apply" }, "computed": false }, "arguments": [ { "type": "ThisExpression", "start": 697, "end": 701, "loc": { "start": { "line": 21, "column": 20 }, "end": { "line": 21, "column": 24 } } }, { "type": "Identifier", "start": 703, "end": 707, "loc": { "start": { "line": 21, "column": 26 }, "end": { "line": 21, "column": 30 }, "identifierName": "args" }, "name": "args" } ] } }, "alternate": null } ], "directives": [] } } } ], "directives": [], "trailingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "*\r\n * Execute a function given a delay time.\r\n * @method debounceTime\r\n * @param {function} f - invoked function.\r\n * @param {number} d - a delay time.\r\n * @param {boolean} [immediate = true] immediate - first func call is immediate if true.\r\n * @return {function(...args:any[])=>void}\r\n ", "start": 0, "end": 292, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 8, "column": 3 } } } ], "trailingComments": [ { "type": "CommentLine", "value": "Copyright (c) 2017 Alex Tranchenko. All rights reserved. ", "start": 722, "end": 781, "loc": { "start": { "line": 24, "column": 0 }, "end": { "line": 24, "column": 59 } } } ] }, "leadingComments": [ { "type": "CommentBlock", "value": "*\r\n * Execute a function given a delay time.\r\n * @method debounceTime\r\n * @param {function} f - invoked function.\r\n * @param {number} d - a delay time.\r\n * @param {boolean} [immediate = true] immediate - first func call is immediate if true.\r\n * @return {function(...args:any[])=>void}\r\n ", "start": 0, "end": 292, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 8, "column": 3 } } } ], "trailingComments": [ { "type": "CommentLine", "value": "Copyright (c) 2017 Alex Tranchenko. All rights reserved. ", "start": 722, "end": 781, "loc": { "start": { "line": 24, "column": 0 }, "end": { "line": 24, "column": 59 } } } ] } ], "directives": [] }, "comments": [ { "type": "CommentBlock", "value": "*\r\n * Execute a function given a delay time.\r\n * @method debounceTime\r\n * @param {function} f - invoked function.\r\n * @param {number} d - a delay time.\r\n * @param {boolean} [immediate = true] immediate - first func call is immediate if true.\r\n * @return {function(...args:any[])=>void}\r\n ", "start": 0, "end": 292, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 8, "column": 3 } } }, { "type": "CommentLine", "value": "Copyright (c) 2017 Alex Tranchenko. All rights reserved. ", "start": 722, "end": 781, "loc": { "start": { "line": 24, "column": 0 }, "end": { "line": 24, "column": 59 } } } ], "tokens": [ { "type": "CommentBlock", "value": "*\r\n * Execute a function given a delay time.\r\n * @method debounceTime\r\n * @param {function} f - invoked function.\r\n * @param {number} d - a delay time.\r\n * @param {boolean} [immediate = true] immediate - first func call is immediate if true.\r\n * @return {function(...args:any[])=>void}\r\n ", "start": 0, "end": 292, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 8, "column": 3 } } }, { "type": { "label": "export", "keyword": "export", "beforeExpr": false, "startsExpr": false, "rightAssociative": false, "isLoop": false, "isAssign": false, "prefix": false, "postfix": false, "binop": null, "updateContext": null }, "value": "export", "start": 294, "end": 300, "loc": { "start": { "line": 9, "column": 0 }, "end": { "line": 9, "column": 6 } } }, { "type": { "label": "function", "keyword": "function", "beforeExpr": false, "startsExpr": true, "rightAssociative": false, "isLoop": false, "isAssign": false, "prefix": false, "postfix": false, "binop": null }, "value": "function", "start": 301, "end": 309, "loc": { "start": { "line": 9, "column": 7 }, "end": { "line": 9, "column": 15 } } }, { "type": { "label": "name", "beforeExpr": false, "startsExpr": true, "rightAssociative": false, "isLoop": false, "isAssign": false, "prefix": false, "postfix": false, "binop": null }, "value": "debounceTime", "start": 310, "end": 322, "loc": { "start": { "line": 9, "column": 16 }, "end": { "line": 9, "column": 28 } } }, { "type": { "label": "(", "beforeExpr": true, "startsExpr": true, "rightAssociative": false, "isLoop": false, "isAssign": false, "prefix": false, "postfix": false, "binop": null }, "start": 322, "end": 323, "loc": { "start": { "line": 9, "column": 28 }, "end": { "line": 9, "column": 29 } } }, { "type": { "label": "name", "beforeExpr": false, "startsExpr": true, "rightAssociative": false, "isLoop": false, "isAssign": false, "prefix": false, "postfix": false, "binop": null }, "value": "f", "start": 323, "end": 324, "loc": { "start": { "line": 9, "column": 29 }, "end": { "line": 9, "column": 30 } } }, { "type": { "label": ",", "beforeExpr": true, "startsExpr": false, "rightAssociative": false, "isLoop": false, "isAssign": false, "prefix": false, "postfix": false, "binop": null, "updateContext": null }, "start": 324, "end": 325, "loc": { "start": { "line": 9, "column": 30 }, "end": { "line": 9, "column": 31 } } }, { "type": { "label": "name", "beforeExpr": false, "startsExpr": true, "rightAssociative": false, "isLoop": false, "isAssign": false, "prefix": false, "postfix": false, "binop": null }, "value"