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,245 lines • 107 kB
JSON
{
"type": "File",
"start": 0,
"end": 907,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 25,
"column": 0
}
},
"program": {
"type": "Program",
"start": 0,
"end": 907,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 25,
"column": 0
}
},
"sourceType": "module",
"body": [
{
"type": "ImportDeclaration",
"start": 0,
"end": 32,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 32
}
},
"specifiers": [
{
"type": "ImportSpecifier",
"start": 9,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 14
}
},
"imported": {
"type": "Identifier",
"start": 9,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 14
},
"identifierName": "Monad"
},
"name": "Monad"
},
"local": {
"type": "Identifier",
"start": 9,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 14
},
"identifierName": "Monad"
},
"name": "Monad"
}
}
],
"source": {
"type": "StringLiteral",
"start": 22,
"end": 31,
"loc": {
"start": {
"line": 1,
"column": 22
},
"end": {
"line": 1,
"column": 31
}
},
"extra": {
"rawValue": "./monad",
"raw": "\"./monad\""
},
"value": "./monad"
},
"trailingComments": [
{
"type": "CommentBlock",
"value": "*\r\n * Class ErrorM - return given value or produce Error if take Error or get Error after execution of f(v).\r\n * @extends {Monad}\r\n ",
"start": 34,
"end": 170,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 5,
"column": 3
}
}
}
]
},
{
"type": "ExportNamedDeclaration",
"start": 172,
"end": 844,
"loc": {
"start": {
"line": 6,
"column": 0
},
"end": {
"line": 23,
"column": 1
}
},
"specifiers": [],
"source": null,
"declaration": {
"type": "ClassDeclaration",
"start": 179,
"end": 844,
"loc": {
"start": {
"line": 6,
"column": 7
},
"end": {
"line": 23,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 185,
"end": 191,
"loc": {
"start": {
"line": 6,
"column": 13
},
"end": {
"line": 6,
"column": 19
},
"identifierName": "ErrorM"
},
"name": "ErrorM",
"leadingComments": null
},
"superClass": {
"type": "Identifier",
"start": 200,
"end": 205,
"loc": {
"start": {
"line": 6,
"column": 28
},
"end": {
"line": 6,
"column": 33
},
"identifierName": "Monad"
},
"name": "Monad"
},
"body": {
"type": "ClassBody",
"start": 206,
"end": 844,
"loc": {
"start": {
"line": 6,
"column": 34
},
"end": {
"line": 23,
"column": 1
}
},
"body": [
{
"type": "ClassMethod",
"start": 510,
"end": 841,
"loc": {
"start": {
"line": 14,
"column": 4
},
"end": {
"line": 22,
"column": 5
}
},
"computed": false,
"key": {
"type": "Identifier",
"start": 510,
"end": 514,
"loc": {
"start": {
"line": 14,
"column": 4
},
"end": {
"line": 14,
"column": 8
},
"identifierName": "bind"
},
"name": "bind",
"leadingComments": null
},
"static": false,
"kind": "method",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 515,
"end": 516,
"loc": {
"start": {
"line": 14,
"column": 9
},
"end": {
"line": 14,
"column": 10
},
"identifierName": "f"
},
"name": "f"
},
{
"type": "Identifier",
"start": 518,
"end": 519,
"loc": {
"start": {
"line": 14,
"column": 12
},
"end": {
"line": 14,
"column": 13
},
"identifierName": "v"
},
"name": "v"
}
],
"body": {
"type": "BlockStatement",
"start": 521,
"end": 841,
"loc": {
"start": {
"line": 14,
"column": 15
},
"end": {
"line": 22,
"column": 5
}
},
"body": [
{
"type": "IfStatement",
"start": 532,
"end": 834,
"loc": {
"start": {
"line": 15,
"column": 8
},
"end": {
"line": 21,
"column": 9
}
},
"test": {
"type": "LogicalExpression",
"start": 536,
"end": 602,
"loc": {
"start": {
"line": 15,
"column": 12
},
"end": {
"line": 15,
"column": 78
}
},
"left": {
"type": "LogicalExpression",
"start": 536,
"end": 580,
"loc": {
"start": {
"line": 15,
"column": 12
},
"end": {
"line": 15,
"column": 56
}
},
"left": {
"type": "LogicalExpression",
"start": 536,
"end": 561,
"loc": {
"start": {
"line": 15,
"column": 12
},
"end": {
"line": 15,
"column": 37
}
},
"left": {
"type": "BinaryExpression",
"start": 536,
"end": 543,
"loc": {
"start": {
"line": 15,
"column": 12
},
"end": {
"line": 15,
"column": 19
}
},
"left": {
"type": "Identifier",
"start": 536,
"end": 537,
"loc": {
"start": {
"line": 15,
"column": 12
},
"end": {
"line": 15,
"column": 13
},
"identifierName": "v"
},
"name": "v"
},
"operator": "!==",
"right": {
"type": "Identifier",
"start": 542,
"end": 543,
"loc": {
"start": {
"line": 15,
"column": 18
},
"end": {
"line": 15,
"column": 19
},
"identifierName": "v"
},
"name": "v"
}
},
"operator": "||",
"right": {
"type": "BinaryExpression",
"start": 547,
"end": 561,
"loc": {
"start": {
"line": 15,
"column": 23
},
"end": {
"line": 15,
"column": 37
}
},
"left": {
"type": "Identifier",
"start": 547,
"end": 548,
"loc": {
"start": {
"line": 15,
"column": 23
},
"end": {
"line": 15,
"column": 24
},
"identifierName": "v"
},
"name": "v"
},
"operator": "===",
"right": {
"type": "Identifier",
"start": 553,
"end": 561,
"loc": {
"start": {
"line": 15,
"column": 29
},
"end": {
"line": 15,
"column": 37
},
"identifierName": "Infinity"
},
"name": "Infinity"
}
}
},
"operator": "||",
"right": {
"type": "BinaryExpression",
"start": 565,
"end": 580,
"loc": {
"start": {
"line": 15,
"column": 41
},
"end": {
"line": 15,
"column": 56
}
},
"left": {
"type": "Identifier",
"start": 565,
"end": 566,
"loc": {
"start": {
"line": 15,
"column": 41
},
"end": {
"line": 15,
"column": 42
},
"identifierName": "v"
},
"name": "v"
},
"operator": "===",
"right": {
"type": "UnaryExpression",
"start": 571,
"end": 580,
"loc": {
"start": {
"line": 15,
"column": 47
},
"end": {
"line": 15,
"column": 56
}
},
"operator": "-",
"prefix": true,
"argument": {
"type": "Identifier",
"start": 572,
"end": 580,
"loc": {
"start": {
"line": 15,
"column": 48
},
"end": {
"line": 15,
"column": 56
},
"identifierName": "Infinity"
},
"name": "Infinity"
},
"extra": {
"parenthesizedArgument": false
}
}
}
},
"operator": "||",
"right": {
"type": "BinaryExpression",
"start": 584,
"end": 602,
"loc": {
"start": {
"line": 15,
"column": 60
},
"end": {
"line": 15,
"column": 78
}
},
"left": {
"type": "Identifier",
"start": 584,
"end": 585,
"loc": {
"start": {
"line": 15,
"column": 60
},
"end": {
"line": 15,
"column": 61
},
"identifierName": "v"
},
"name": "v"
},
"operator": "instanceof",
"right": {
"type": "Identifier",
"start": 597,
"end": 602,
"loc": {
"start": {
"line": 15,
"column": 73
},
"end": {
"line": 15,
"column": 78
},
"identifierName": "Error"
},
"name": "Error"
}
}
},
"consequent": {
"type": "BlockStatement",
"start": 604,
"end": 650,
"loc": {
"start": {
"line": 15,
"column": 80
},
"end": {
"line": 17,
"column": 9
}
},
"body": [
{
"type": "ReturnStatement",
"start": 619,
"end": 639,
"loc": {
"start": {
"line": 16,
"column": 12
},
"end": {
"line": 16,
"column": 32
}
},
"argument": {
"type": "CallExpression",
"start": 626,
"end": 638,
"loc": {
"start": {
"line": 16,
"column": 19
},
"end": {
"line": 16,
"column": 31
}
},
"callee": {
"type": "MemberExpression",
"start": 626,
"end": 635,
"loc": {
"start": {
"line": 16,
"column": 19
},
"end": {
"line": 16,
"column": 28
}
},
"object": {
"type": "ThisExpression",
"start": 626,
"end": 630,
"loc": {
"start": {
"line": 16,
"column": 19
},
"end": {
"line": 16,
"column": 23
}
}
},
"property": {
"type": "Identifier",
"start": 631,
"end": 635,
"loc": {
"start": {
"line": 16,
"column": 24
},
"end": {
"line": 16,
"column": 28
},
"identifierName": "fail"
},
"name": "fail"
},
"computed": false
},
"arguments": [
{
"type": "Identifier",
"start": 636,
"end": 637,
"loc": {
"start": {
"line": 16,
"column": 29
},
"end": {
"line": 16,
"column": 30
},
"identifierName": "v"
},
"name": "v"
}
]
}
}
],
"directives": []
},
"alternate": {
"type": "BlockStatement",
"start": 665,
"end": 834,
"loc": {
"start": {
"line": 18,
"column": 13
},
"end": {
"line": 21,
"column": 9
}
},
"body": [
{
"type": "VariableDeclaration",
"start": 680,
"end": 707,
"loc": {
"start": {
"line": 19,
"column": 12
},
"end": {
"line": 19,
"column": 39
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 686,
"end": 706,
"loc": {
"start": {
"line": 19,
"column": 18
},
"end": {
"line": 19,
"column": 38
}
},
"id": {
"type": "Identifier",
"start": 686,
"end": 688,
"loc": {
"start": {
"line": 19,
"column": 18
},
"end": {
"line": 19,
"column": 20
},
"identifierName": "vL"
},
"name": "vL"
},
"init": {
"type": "CallExpression",
"start": 691,
"end": 706,
"loc": {
"start": {
"line": 19,
"column": 23
},
"end": {
"line": 19,
"column": 38
}
},
"callee": {
"type": "MemberExpression",
"start": 691,
"end": 700,
"loc": {
"start": {
"line": 19,
"column": 23
},
"end": {
"line": 19,
"column": 32
}
},
"object": {
"type": "ThisExpression",
"start": 691,
"end": 695,
"loc": {
"start": {
"line": 19,
"column": 23
},
"end": {
"line": 19,
"column": 27
}
}
},
"property": {
"type": "Identifier",
"start": 696,
"end": 700,
"loc": {
"start": {
"line": 19,
"column": 28
},
"end": {
"line": 19,
"column": 32
},
"identifierName": "just"
},
"name": "just"
},
"computed": false
},
"arguments": [
{
"type": "Identifier",
"start": 701,
"end": 702,
"loc": {
"start": {
"line": 19,
"column": 33
},
"end": {
"line": 19,
"column": 34
},
"identifierName": "f"
},
"name": "f"
},
{
"type": "Identifier",
"start": 704,
"end": 705,
"loc": {
"start": {
"line": 19,
"column": 36
},
"end": {
"line": 19,
"column": 37
},
"identifierName": "v"
},
"name": "v"
}
]
}
}
],
"kind": "const"
},
{
"type": "ReturnStatement",
"start": 721,
"end": 823,
"loc": {
"start": {
"line": 20,
"column": 12
},
"end": {
"line": 20,
"column": 114
}
},
"argument": {
"type": "ConditionalExpression",
"start": 728,
"end": 822,
"loc": {
"start": {
"line": 20,
"column": 19
},
"end": {
"line": 20,
"column": 113
}
},
"test": {
"type": "LogicalExpression",
"start": 729,
"end": 800,
"loc": {
"start": {
"line": 20,
"column": 20
},
"end": {
"line": 20,
"column": 91
}
},
"left": {
"type": "LogicalExpression",
"start": 729,
"end": 777,
"loc": {
"start": {
"line": 20,
"column": 20
},
"end": {
"line": 20,
"column": 68
}
},
"left": {
"type": "LogicalExpression",
"start": 729,
"end": 757,
"loc": {
"start": {
"line": 20,
"column": 20
},
"end": {
"line": 20,
"column": 48
}
},
"left": {
"type": "BinaryExpression",
"start": 729,
"end": 738,
"loc": {
"start": {
"line": 20,
"column": 20
},
"end": {
"line": 20,
"column": 29
}
},
"left": {
"type": "Identifier",
"start": 729,
"end": 731,
"loc": {
"start": {
"line": 20,
"column": 20
},
"end": {
"line": 20,
"column": 22
},
"identifierName": "vL"
},
"name": "vL"
},
"operator": "!==",
"right": {
"type": "Identifier",
"start": 736,
"end": 738,
"loc": {
"start": {
"line": 20,
"column": 27
},
"end": {
"line": 20,
"column": 29
},
"identifierName": "vL"
},
"name": "vL"
}
},
"operator": "||",
"right": {
"type": "BinaryExpression",
"start": 742,
"end": 757,
"loc": {
"start": {
"line": 20,
"column": 33
},
"end": {
"line": 20,
"column": 48
}
},
"left": {
"type": "Identifier",
"start": 742,
"end": 744,
"loc": {
"start": {
"line": 20,
"column": 33
},
"end": {
"line": 20,
"column": 35
},
"identifierName": "vL"
},
"name": "vL"
},
"operator": "===",
"right": {
"type": "Identifier",
"start": 749,
"end": 757,
"loc": {
"start": {
"line": 20,
"column": 40
},
"end": {
"line": 20,
"column": 48
},
"identifierName": "Infinity"
},
"name": "Infinity"
}
}
},
"operator": "||",
"right": {
"type": "BinaryExpression",
"start": 761,
"end": 777,
"loc": {
"start": {
"line": 20,
"column": 52
},
"end": {
"line": 20,
"column": 68
}
},
"left": {
"type": "Identifier",
"start": 761,
"end": 763,
"loc": {
"start": {
"line": 20,
"column": 52
},
"end": {
"line": 20,
"column": 54
},
"identifierName": "vL"
},
"name": "vL"
},
"operator": "===",
"right": {
"type": "UnaryExpression",
"start": 768,
"end": 777,
"loc": {
"start": {
"line": 20,
"column": 59
},
"end": {
"line": 20,
"column": 68
}
},
"operator": "-",
"prefix": true,
"argument": {
"type": "Identifier",
"start": 769,
"end": 777,
"loc": {
"start": {
"line": 20,
"column": 60
},
"end": {
"line": 20,
"column": 68
},
"identifierName": "Infinity"
},
"name": "Infinity"
},
"extra": {
"parenthesizedArgument": false
}
}
}
},
"operator": "||",
"right": {
"type": "BinaryExpression",
"start": 781,
"end": 800,
"loc": {
"start": {
"line": 20,
"column": 72
},
"end": {
"line": 20,
"column": 91
}
},
"left": {
"type": "Identifier",
"start": 781,
"end": 783,
"loc": {
"start": {
"line": 20,
"column": 72
},
"end": {
"line": 20,
"column": 74
},
"identifierName": "vL"
},
"name": "vL"
},
"operator": "instanceof",
"right": {
"type": "Identifier",
"start": 795,
"end": 800,
"loc": {
"start": {
"line": 20,
"column": 86
},
"end": {
"line": 20,
"column": 91
},
"identifierName": "Error"
},
"name": "Error"
}
},
"extra": {
"parenthesized": true,
"parenStart": 728
}
},
"consequent": {
"type": "CallExpression",
"start": 804,
"end": 817,
"loc": {
"start": {
"line": 20,
"column": 95
},
"end": {
"line": 20,
"column": 108
}
},
"callee": {
"type": "MemberExpression",
"start": 804,
"end": 813,
"loc": {
"start": {
"line": 20,
"column": 95
},
"end": {
"line": 20,
"column": 104
}
},
"object": {
"type": "ThisExpression",
"start": 804,
"end": 808,
"loc": {
"start": {
"line": 20,
"column": 95
},
"end": {
"line": 20,
"column": 99
}
}
},
"property": {
"type": "Identifier",
"start": 809,
"end": 813,
"loc": {
"start": {
"line": 20,
"column": 100
},
"end": {
"line": 20,
"column": 104
},
"identifierName": "fail"
},
"name": "fail"
},
"computed": false
},
"arguments": [
{
"type": "Identifier",
"start": 814,
"end": 816,
"loc": {
"start": {
"line": 20,
"column": 105
},
"end": {
"line": 20,
"column": 107
},
"identifierName": "vL"
},
"name": "vL"
}