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,435 lines 99.7 kB
{ "type": "File", "start": 0, "end": 749, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 23, "column": 0 } }, "program": { "type": "Program", "start": 0, "end": 749, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 23, "column": 0 } }, "sourceType": "module", "body": [ { "type": "ExportNamedDeclaration", "start": 253, "end": 686, "loc": { "start": { "line": 9, "column": 0 }, "end": { "line": 21, "column": 1 } }, "specifiers": [], "source": null, "declaration": { "type": "FunctionDeclaration", "start": 260, "end": 686, "loc": { "start": { "line": 9, "column": 7 }, "end": { "line": 21, "column": 1 } }, "id": { "type": "Identifier", "start": 269, "end": 273, "loc": { "start": { "line": 9, "column": 16 }, "end": { "line": 9, "column": 20 }, "identifierName": "hash" }, "name": "hash", "leadingComments": null }, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 274, "end": 277, "loc": { "start": { "line": 9, "column": 21 }, "end": { "line": 9, "column": 24 }, "identifierName": "str" }, "name": "str" }, { "type": "AssignmentPattern", "start": 279, "end": 297, "loc": { "start": { "line": 9, "column": 26 }, "end": { "line": 9, "column": 44 } }, "left": { "type": "Identifier", "start": 279, "end": 284, "loc": { "start": { "line": 9, "column": 26 }, "end": { "line": 9, "column": 31 }, "identifierName": "pHash" }, "name": "pHash" }, "right": { "type": "NumericLiteral", "start": 287, "end": 297, "loc": { "start": { "line": 9, "column": 34 }, "end": { "line": 9, "column": 44 } }, "extra": { "rawValue": 2166136261, "raw": "2166136261" }, "value": 2166136261 } } ], "body": { "type": "BlockStatement", "start": 299, "end": 686, "loc": { "start": { "line": 9, "column": 46 }, "end": { "line": 21, "column": 1 } }, "body": [ { "type": "IfStatement", "start": 306, "end": 357, "loc": { "start": { "line": 10, "column": 4 }, "end": { "line": 11, "column": 20 } }, "test": { "type": "LogicalExpression", "start": 310, "end": 334, "loc": { "start": { "line": 10, "column": 8 }, "end": { "line": 10, "column": 32 } }, "left": { "type": "BinaryExpression", "start": 310, "end": 326, "loc": { "start": { "line": 10, "column": 8 }, "end": { "line": 10, "column": 24 } }, "left": { "type": "MemberExpression", "start": 310, "end": 320, "loc": { "start": { "line": 10, "column": 8 }, "end": { "line": 10, "column": 18 } }, "object": { "type": "Identifier", "start": 310, "end": 313, "loc": { "start": { "line": 10, "column": 8 }, "end": { "line": 10, "column": 11 }, "identifierName": "str" }, "name": "str" }, "property": { "type": "Identifier", "start": 314, "end": 320, "loc": { "start": { "line": 10, "column": 12 }, "end": { "line": 10, "column": 18 }, "identifierName": "length" }, "name": "length" }, "computed": false }, "operator": "===", "right": { "type": "NumericLiteral", "start": 325, "end": 326, "loc": { "start": { "line": 10, "column": 23 }, "end": { "line": 10, "column": 24 } }, "extra": { "rawValue": 0, "raw": "0" }, "value": 0 } }, "operator": "||", "right": { "type": "UnaryExpression", "start": 330, "end": 334, "loc": { "start": { "line": 10, "column": 28 }, "end": { "line": 10, "column": 32 } }, "operator": "!", "prefix": true, "argument": { "type": "Identifier", "start": 331, "end": 334, "loc": { "start": { "line": 10, "column": 29 }, "end": { "line": 10, "column": 32 }, "identifierName": "str" }, "name": "str" }, "extra": { "parenthesizedArgument": false } } }, "consequent": { "type": "ReturnStatement", "start": 345, "end": 357, "loc": { "start": { "line": 11, "column": 8 }, "end": { "line": 11, "column": 20 } }, "argument": { "type": "NullLiteral", "start": 352, "end": 356, "loc": { "start": { "line": 11, "column": 15 }, "end": { "line": 11, "column": 19 } } } }, "alternate": null }, { "type": "VariableDeclaration", "start": 363, "end": 386, "loc": { "start": { "line": 12, "column": 4 }, "end": { "line": 12, "column": 27 } }, "declarations": [ { "type": "VariableDeclarator", "start": 367, "end": 385, "loc": { "start": { "line": 12, "column": 8 }, "end": { "line": 12, "column": 26 } }, "id": { "type": "Identifier", "start": 367, "end": 368, "loc": { "start": { "line": 12, "column": 8 }, "end": { "line": 12, "column": 9 }, "identifierName": "n" }, "name": "n" }, "init": { "type": "BinaryExpression", "start": 371, "end": 385, "loc": { "start": { "line": 12, "column": 12 }, "end": { "line": 12, "column": 26 } }, "left": { "type": "MemberExpression", "start": 371, "end": 381, "loc": { "start": { "line": 12, "column": 12 }, "end": { "line": 12, "column": 22 } }, "object": { "type": "Identifier", "start": 371, "end": 374, "loc": { "start": { "line": 12, "column": 12 }, "end": { "line": 12, "column": 15 }, "identifierName": "str" }, "name": "str" }, "property": { "type": "Identifier", "start": 375, "end": 381, "loc": { "start": { "line": 12, "column": 16 }, "end": { "line": 12, "column": 22 }, "identifierName": "length" }, "name": "length" }, "computed": false }, "operator": "-", "right": { "type": "NumericLiteral", "start": 384, "end": 385, "loc": { "start": { "line": 12, "column": 25 }, "end": { "line": 12, "column": 26 } }, "extra": { "rawValue": 1, "raw": "1" }, "value": 1 } } } ], "kind": "let" }, { "type": "VariableDeclaration", "start": 392, "end": 409, "loc": { "start": { "line": 13, "column": 4 }, "end": { "line": 13, "column": 21 } }, "declarations": [ { "type": "VariableDeclarator", "start": 396, "end": 408, "loc": { "start": { "line": 13, "column": 8 }, "end": { "line": 13, "column": 20 } }, "id": { "type": "Identifier", "start": 396, "end": 400, "loc": { "start": { "line": 13, "column": 8 }, "end": { "line": 13, "column": 12 }, "identifierName": "hash" }, "name": "hash" }, "init": { "type": "Identifier", "start": 403, "end": 408, "loc": { "start": { "line": 13, "column": 15 }, "end": { "line": 13, "column": 20 }, "identifierName": "pHash" }, "name": "pHash" } } ], "kind": "let" }, { "type": "WhileStatement", "start": 415, "end": 665, "loc": { "start": { "line": 14, "column": 4 }, "end": { "line": 19, "column": 5 } }, "test": { "type": "BinaryExpression", "start": 422, "end": 428, "loc": { "start": { "line": 14, "column": 11 }, "end": { "line": 14, "column": 17 } }, "left": { "type": "Identifier", "start": 422, "end": 423, "loc": { "start": { "line": 14, "column": 11 }, "end": { "line": 14, "column": 12 }, "identifierName": "n" }, "name": "n" }, "operator": ">=", "right": { "type": "NumericLiteral", "start": 427, "end": 428, "loc": { "start": { "line": 14, "column": 16 }, "end": { "line": 14, "column": 17 } }, "extra": { "rawValue": 0, "raw": "0" }, "value": 0 } }, "body": { "type": "BlockStatement", "start": 430, "end": 665, "loc": { "start": { "line": 14, "column": 19 }, "end": { "line": 19, "column": 5 } }, "body": [ { "type": "ExpressionStatement", "start": 492, "end": 520, "loc": { "start": { "line": 16, "column": 8 }, "end": { "line": 16, "column": 36 } }, "expression": { "type": "AssignmentExpression", "start": 492, "end": 519, "loc": { "start": { "line": 16, "column": 8 }, "end": { "line": 16, "column": 35 } }, "operator": "^=", "left": { "type": "Identifier", "start": 492, "end": 496, "loc": { "start": { "line": 16, "column": 8 }, "end": { "line": 16, "column": 12 }, "identifierName": "hash" }, "name": "hash", "leadingComments": null }, "right": { "type": "CallExpression", "start": 500, "end": 519, "loc": { "start": { "line": 16, "column": 16 }, "end": { "line": 16, "column": 35 } }, "callee": { "type": "MemberExpression", "start": 500, "end": 514, "loc": { "start": { "line": 16, "column": 16 }, "end": { "line": 16, "column": 30 } }, "object": { "type": "Identifier", "start": 500, "end": 503, "loc": { "start": { "line": 16, "column": 16 }, "end": { "line": 16, "column": 19 }, "identifierName": "str" }, "name": "str" }, "property": { "type": "Identifier", "start": 504, "end": 514, "loc": { "start": { "line": 16, "column": 20 }, "end": { "line": 16, "column": 30 }, "identifierName": "charCodeAt" }, "name": "charCodeAt" }, "computed": false }, "arguments": [ { "type": "UpdateExpression", "start": 515, "end": 518, "loc": { "start": { "line": 16, "column": 31 }, "end": { "line": 16, "column": 34 } }, "operator": "--", "prefix": false, "argument": { "type": "Identifier", "start": 515, "end": 516, "loc": { "start": { "line": 16, "column": 31 }, "end": { "line": 16, "column": 32 }, "identifierName": "n" }, "name": "n" } } ] }, "leadingComments": null }, "leadingComments": [ { "type": "CommentLine", "value": " xor the bottom with the current chunk.", "start": 441, "end": 482, "loc": { "start": { "line": 15, "column": 8 }, "end": { "line": 15, "column": 49 } } } ], "trailingComments": [ { "type": "CommentLine", "value": " multiply with a expression of shifts.", "start": 530, "end": 571, "loc": { "start": { "line": 17, "column": 8 }, "end": { "line": 17, "column": 49 } } } ] }, { "type": "ExpressionStatement", "start": 581, "end": 658, "loc": { "start": { "line": 18, "column": 8 }, "end": { "line": 18, "column": 85 } }, "expression": { "type": "AssignmentExpression", "start": 581, "end": 657, "loc": { "start": { "line": 18, "column": 8 }, "end": { "line": 18, "column": 84 } }, "operator": "+=", "left": { "type": "Identifier", "start": 581, "end": 585, "loc": { "start": { "line": 18, "column": 8 }, "end": { "line": 18, "column": 12 }, "identifierName": "hash" }, "name": "hash", "leadingComments": null }, "right": { "type": "BinaryExpression", "start": 589, "end": 657, "loc": { "start": { "line": 18, "column": 16 }, "end": { "line": 18, "column": 84 } }, "left": { "type": "BinaryExpression", "start": 589, "end": 642, "loc": { "start": { "line": 18, "column": 16 }, "end": { "line": 18, "column": 69 } }, "left": { "type": "BinaryExpression", "start": 589, "end": 628, "loc": { "start": { "line": 18, "column": 16 }, "end": { "line": 18, "column": 55 } }, "left": { "type": "BinaryExpression", "start": 589, "end": 614, "loc": { "start": { "line": 18, "column": 16 }, "end": { "line": 18, "column": 41 } }, "left": { "type": "BinaryExpression", "start": 590, "end": 599, "loc": { "start": { "line": 18, "column": 17 }, "end": { "line": 18, "column": 26 } }, "left": { "type": "Identifier", "start": 590, "end": 594, "loc": { "start": { "line": 18, "column": 17 }, "end": { "line": 18, "column": 21 }, "identifierName": "hash" }, "name": "hash" }, "operator": "<<", "right": { "type": "NumericLiteral", "start": 598, "end": 599, "loc": { "start": { "line": 18, "column": 25 }, "end": { "line": 18, "column": 26 } }, "extra": { "rawValue": 1, "raw": "1" }, "value": 1 }, "extra": { "parenthesized": true, "parenStart": 589 } }, "operator": "+", "right": { "type": "BinaryExpression", "start": 604, "end": 613, "loc": { "start": { "line": 18, "column": 31 }, "end": { "line": 18, "column": 40 } }, "left": { "type": "Identifier", "start": 604, "end": 608, "loc": { "start": { "line": 18, "column": 31 }, "end": { "line": 18, "column": 35 }, "identifierName": "hash" }, "name": "hash" }, "operator": "<<", "right": { "type": "NumericLiteral", "start": 612, "end": 613, "loc": { "start": { "line": 18, "column": 39 }, "end": { "line": 18, "column": 40 } }, "extra": { "rawValue": 4, "raw": "4" }, "value": 4 }, "extra": { "parenthesized": true, "parenStart": 603 } } }, "operator": "+", "right": { "type": "BinaryExpression", "start": 618, "end": 627, "loc": { "start": { "line": 18, "column": 45 }, "end": { "line": 18, "column": 54 } }, "left": { "type": "Identifier", "start": 618, "end": 622, "loc": { "start": { "line": 18, "column": 45 }, "end": { "line": 18, "column": 49 }, "identifierName": "hash" }, "name": "hash" }, "operator": "<<", "right": { "type": "NumericLiteral", "start": 626, "end": 627, "loc": { "start": { "line": 18, "column": 53 }, "end": { "line": 18, "column": 54 } }, "extra": { "rawValue": 7, "raw": "7" }, "value": 7 }, "extra": { "parenthesized": true, "parenStart": 617 } } }, "operator": "+", "right": { "type": "BinaryExpression", "start": 632, "end": 641, "loc": { "start": { "line": 18, "column": 59 }, "end": { "line": 18, "column": 68 } }, "left": { "type": "Identifier", "start": 632, "end": 636, "loc": { "start": { "line": 18, "column": 59 }, "end": { "line": 18, "column": 63 }, "identifierName": "hash" }, "name": "hash" }, "operator": "<<", "right": { "type": "NumericLiteral", "start": 640, "end": 641, "loc": { "start": { "line": 18, "column": 67 }, "end": { "line": 18, "column": 68 } }, "extra": { "rawValue": 8, "raw": "8" }, "value": 8 }, "extra": { "parenthesized": true, "parenStart": 631 } } }, "operator": "+", "right": { "type": "BinaryExpression", "start": 646, "end": 656, "loc": { "start": { "line": 18, "column": 73 }, "end": { "line": 18, "column": 83 } }, "left": { "type": "Identifier", "start": 646, "end": 650, "loc": { "start": { "line": 18, "column": 73 }, "end": { "line": 18, "column": 77 }, "identifierName": "hash" }, "name": "hash" }, "operator": "<<", "right": { "type": "NumericLiteral", "start": 654, "end": 656, "loc": { "start": { "line": 18, "column": 81 }, "end": { "line": 18, "column": 83 } }, "extra": { "rawValue": 24, "raw": "24" }, "value": 24 }, "extra": { "parenthesized": true, "parenStart": 645 } } }, "leadingComments": null }, "leadingComments": [ { "type": "CommentLine", "value": " multiply with a expression of shifts.", "start": 530, "end": 571, "loc": { "start": { "line": 17, "column": 8 }, "end": { "line": 17, "column": 49 } } } ] } ], "directives": [] } }, { "type": "ReturnStatement", "start": 671, "end": 683, "loc": { "start": { "line": 20, "column": 4 }, "end": { "line": 20, "column": 16 } }, "argument": { "type": "Identifier", "start": 678, "end": 682, "loc": { "start": { "line": 20, "column": 11 }, "end": { "line": 20, "column": 15 }, "identifierName": "hash" }, "name": "hash" } } ], "directives": [], "trailingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "*\r\n * Calculates a hash (32 bit).\r\n * Based on FNV-1a algorithm, ref: http://isthe.com/chongo/tech/comp/fnv/\r\n * @method hash\r\n * @param {string} str - string to hash\r\n * @param {number} [pHash = 2166136261] previous hash.\r\n * @returns {number}\r\n ", "start": 0, "end": 251, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 8, "column": 3 } } } ], "trailingComments": [ { "type": "CommentLine", "value": "Copyright (c) 2017 Alex Tranchenko. All rights reserved. ", "start": 688, "end": 747, "loc": { "start": { "line": 22, "column": 0 }, "end": { "line": 22, "column": 59 } } } ] }, "leadingComments": [ { "type": "CommentBlock", "value": "*\r\n * Calculates a hash (32 bit).\r\n * Based on FNV-1a algorithm, ref: http://isthe.com/chongo/tech/comp/fnv/\r\n * @method hash\r\n * @param {string} str - string to hash\r\n * @param {number} [pHash = 2166136261] previous hash.\r\n * @returns {number}\r\n ", "start": 0, "end": 251, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 8, "column": 3 } } } ], "trailingComments": [ { "type": "CommentLine", "value": "Copyright (c) 2017 Alex Tranchenko. All rights reserved. ", "start": 688, "end": 747, "loc": { "start": { "line": 22, "column": 0 }, "end": { "line": 22, "column": 59 } } } ] } ], "directives": [] }, "comments": [ { "type": "CommentBlock", "value": "*\r\n * Calculates a hash (32 bit).\r\n * Based on FNV-1a algorithm, ref: http://isthe.com/chongo/tech/comp/fnv/\r\n * @method hash\r\n * @param {string} str - string to hash\r\n * @param {number} [pHash = 2166136261] previous hash.\r\n * @returns {number}\r\n ", "start": 0, "end": 251, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 8, "column": 3 } } }, { "type": "CommentLine", "value": " xor the bottom with the current chunk.", "start": 441, "end": 482, "loc": { "start": { "line": 15, "column": 8 }, "end": { "line": 15, "column": 49 } } }, { "type": "CommentLine", "value": " multiply with a expression of shifts.", "start": 530, "end": 571, "loc": { "start": { "line": 17, "column": 8 }, "end": { "line": 17, "column": 49 } } }, { "type": "CommentLine", "value": "Copyright (c) 2017 Alex Tranchenko. All rights reserved. ", "start": 688, "end": 747, "loc": { "start": { "line": 22, "column": 0 }, "end": { "line": 22, "column": 59 } } } ], "tokens": [ { "type": "CommentBlock", "value": "*\r\n * Calculates a hash (32 bit).\r\n * Based on FNV-1a algorithm, ref: http://isthe.com/chongo/tech/comp/fnv/\r\n * @method hash\r\n * @param {string} str - string to hash\r\n * @param {number} [pHash = 2166136261] previous hash.\r\n * @returns {number}\r\n ", "start": 0, "end": 251, "loc": { "start": { "line": 1, "column": 0 },