@eastsideco/escshopify
Version:
WIP JS library for Shopify, containing a variety of useful functionality.
1,433 lines (1,432 loc) • 136 kB
JSON
{
"type": "File",
"start": 0,
"end": 1420,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 50,
"column": 0
}
},
"program": {
"type": "Program",
"start": 0,
"end": 1420,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 50,
"column": 0
}
},
"sourceType": "module",
"body": [
{
"type": "ImportDeclaration",
"start": 0,
"end": 55,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 55
}
},
"specifiers": [
{
"type": "ImportNamespaceSpecifier",
"start": 7,
"end": 22,
"loc": {
"start": {
"line": 1,
"column": 7
},
"end": {
"line": 1,
"column": 22
}
},
"local": {
"type": "Identifier",
"start": 12,
"end": 22,
"loc": {
"start": {
"line": 1,
"column": 12
},
"end": {
"line": 1,
"column": 22
},
"identifierName": "currencies"
},
"name": "currencies"
}
}
],
"source": {
"type": "StringLiteral",
"start": 28,
"end": 54,
"loc": {
"start": {
"line": 1,
"column": 28
},
"end": {
"line": 1,
"column": 54
}
},
"extra": {
"rawValue": "js-money/lib/currency.js",
"raw": "'js-money/lib/currency.js'"
},
"value": "js-money/lib/currency.js"
}
},
{
"type": "ImportDeclaration",
"start": 56,
"end": 92,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 36
}
},
"specifiers": [
{
"type": "ImportDefaultSpecifier",
"start": 63,
"end": 72,
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 16
}
},
"local": {
"type": "Identifier",
"start": 63,
"end": 72,
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 16
},
"identifierName": "Formatter"
},
"name": "Formatter"
}
}
],
"source": {
"type": "StringLiteral",
"start": 78,
"end": 91,
"loc": {
"start": {
"line": 2,
"column": 22
},
"end": {
"line": 2,
"column": 35
}
},
"extra": {
"rawValue": "./Formatter",
"raw": "'./Formatter'"
},
"value": "./Formatter"
},
"trailingComments": [
{
"type": "CommentBlock",
"value": "*\n * A default formatting implementation.\n * Formats most currencies as $00.00, except JPY which is 00 $\n ",
"start": 95,
"end": 205,
"loc": {
"start": {
"line": 5,
"column": 0
},
"end": {
"line": 8,
"column": 3
}
}
}
]
},
{
"type": "ExportDefaultDeclaration",
"start": 206,
"end": 1419,
"loc": {
"start": {
"line": 9,
"column": 0
},
"end": {
"line": 49,
"column": 1
}
},
"declaration": {
"type": "ClassDeclaration",
"start": 221,
"end": 1419,
"loc": {
"start": {
"line": 9,
"column": 15
},
"end": {
"line": 49,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 227,
"end": 243,
"loc": {
"start": {
"line": 9,
"column": 21
},
"end": {
"line": 9,
"column": 37
},
"identifierName": "DefaultFormatter"
},
"name": "DefaultFormatter",
"leadingComments": null
},
"superClass": {
"type": "Identifier",
"start": 252,
"end": 261,
"loc": {
"start": {
"line": 9,
"column": 46
},
"end": {
"line": 9,
"column": 55
},
"identifierName": "Formatter"
},
"name": "Formatter"
},
"body": {
"type": "ClassBody",
"start": 262,
"end": 1419,
"loc": {
"start": {
"line": 9,
"column": 56
},
"end": {
"line": 49,
"column": 1
}
},
"body": [
{
"type": "ClassMethod",
"start": 442,
"end": 735,
"loc": {
"start": {
"line": 16,
"column": 4
},
"end": {
"line": 24,
"column": 5
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 442,
"end": 448,
"loc": {
"start": {
"line": 16,
"column": 4
},
"end": {
"line": 16,
"column": 10
},
"identifierName": "format"
},
"name": "format",
"leadingComments": null
},
"kind": "method",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 449,
"end": 455,
"loc": {
"start": {
"line": 16,
"column": 11
},
"end": {
"line": 16,
"column": 17
},
"identifierName": "amount"
},
"name": "amount"
},
{
"type": "Identifier",
"start": 457,
"end": 465,
"loc": {
"start": {
"line": 16,
"column": 19
},
"end": {
"line": 16,
"column": 27
},
"identifierName": "currency"
},
"name": "currency"
}
],
"body": {
"type": "BlockStatement",
"start": 467,
"end": 735,
"loc": {
"start": {
"line": 16,
"column": 29
},
"end": {
"line": 24,
"column": 5
}
},
"body": [
{
"type": "VariableDeclaration",
"start": 477,
"end": 517,
"loc": {
"start": {
"line": 17,
"column": 8
},
"end": {
"line": 17,
"column": 48
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 481,
"end": 516,
"loc": {
"start": {
"line": 17,
"column": 12
},
"end": {
"line": 17,
"column": 47
}
},
"id": {
"type": "Identifier",
"start": 481,
"end": 493,
"loc": {
"start": {
"line": 17,
"column": 12
},
"end": {
"line": 17,
"column": 24
},
"identifierName": "currencyInfo"
},
"name": "currencyInfo"
},
"init": {
"type": "MemberExpression",
"start": 496,
"end": 516,
"loc": {
"start": {
"line": 17,
"column": 27
},
"end": {
"line": 17,
"column": 47
}
},
"object": {
"type": "Identifier",
"start": 496,
"end": 506,
"loc": {
"start": {
"line": 17,
"column": 27
},
"end": {
"line": 17,
"column": 37
},
"identifierName": "currencies"
},
"name": "currencies"
},
"property": {
"type": "Identifier",
"start": 507,
"end": 515,
"loc": {
"start": {
"line": 17,
"column": 38
},
"end": {
"line": 17,
"column": 46
},
"identifierName": "currency"
},
"name": "currency"
},
"computed": true
}
}
],
"kind": "var"
},
{
"type": "IfStatement",
"start": 527,
"end": 646,
"loc": {
"start": {
"line": 19,
"column": 8
},
"end": {
"line": 21,
"column": 9
}
},
"test": {
"type": "BinaryExpression",
"start": 531,
"end": 557,
"loc": {
"start": {
"line": 19,
"column": 12
},
"end": {
"line": 19,
"column": 38
}
},
"left": {
"type": "MemberExpression",
"start": 531,
"end": 548,
"loc": {
"start": {
"line": 19,
"column": 12
},
"end": {
"line": 19,
"column": 29
}
},
"object": {
"type": "Identifier",
"start": 531,
"end": 543,
"loc": {
"start": {
"line": 19,
"column": 12
},
"end": {
"line": 19,
"column": 24
},
"identifierName": "currencyInfo"
},
"name": "currencyInfo"
},
"property": {
"type": "Identifier",
"start": 544,
"end": 548,
"loc": {
"start": {
"line": 19,
"column": 25
},
"end": {
"line": 19,
"column": 29
},
"identifierName": "code"
},
"name": "code"
},
"computed": false
},
"operator": "==",
"right": {
"type": "StringLiteral",
"start": 552,
"end": 557,
"loc": {
"start": {
"line": 19,
"column": 33
},
"end": {
"line": 19,
"column": 38
}
},
"extra": {
"rawValue": "JPY",
"raw": "'JPY'"
},
"value": "JPY"
}
},
"consequent": {
"type": "BlockStatement",
"start": 559,
"end": 646,
"loc": {
"start": {
"line": 19,
"column": 40
},
"end": {
"line": 21,
"column": 9
}
},
"body": [
{
"type": "ReturnStatement",
"start": 573,
"end": 636,
"loc": {
"start": {
"line": 20,
"column": 12
},
"end": {
"line": 20,
"column": 75
}
},
"argument": {
"type": "CallExpression",
"start": 580,
"end": 635,
"loc": {
"start": {
"line": 20,
"column": 19
},
"end": {
"line": 20,
"column": 74
}
},
"callee": {
"type": "MemberExpression",
"start": 580,
"end": 607,
"loc": {
"start": {
"line": 20,
"column": 19
},
"end": {
"line": 20,
"column": 46
}
},
"object": {
"type": "ThisExpression",
"start": 580,
"end": 584,
"loc": {
"start": {
"line": 20,
"column": 19
},
"end": {
"line": 20,
"column": 23
}
}
},
"property": {
"type": "Identifier",
"start": 585,
"end": 607,
"loc": {
"start": {
"line": 20,
"column": 24
},
"end": {
"line": 20,
"column": 46
},
"identifierName": "_suffixSymbolNoDecimal"
},
"name": "_suffixSymbolNoDecimal"
},
"computed": false
},
"arguments": [
{
"type": "Identifier",
"start": 608,
"end": 614,
"loc": {
"start": {
"line": 20,
"column": 47
},
"end": {
"line": 20,
"column": 53
},
"identifierName": "amount"
},
"name": "amount"
},
{
"type": "Identifier",
"start": 616,
"end": 628,
"loc": {
"start": {
"line": 20,
"column": 55
},
"end": {
"line": 20,
"column": 67
},
"identifierName": "currencyInfo"
},
"name": "currencyInfo"
},
{
"type": "BooleanLiteral",
"start": 630,
"end": 634,
"loc": {
"start": {
"line": 20,
"column": 69
},
"end": {
"line": 20,
"column": 73
}
},
"value": true
}
]
}
}
],
"directives": []
},
"alternate": null
},
{
"type": "ReturnStatement",
"start": 656,
"end": 729,
"loc": {
"start": {
"line": 23,
"column": 8
},
"end": {
"line": 23,
"column": 81
}
},
"argument": {
"type": "CallExpression",
"start": 663,
"end": 728,
"loc": {
"start": {
"line": 23,
"column": 15
},
"end": {
"line": 23,
"column": 80
}
},
"callee": {
"type": "MemberExpression",
"start": 663,
"end": 699,
"loc": {
"start": {
"line": 23,
"column": 15
},
"end": {
"line": 23,
"column": 51
}
},
"object": {
"type": "ThisExpression",
"start": 663,
"end": 667,
"loc": {
"start": {
"line": 23,
"column": 15
},
"end": {
"line": 23,
"column": 19
}
}
},
"property": {
"type": "Identifier",
"start": 668,
"end": 699,
"loc": {
"start": {
"line": 23,
"column": 20
},
"end": {
"line": 23,
"column": 51
},
"identifierName": "_formatPrefixedSymbolTwoDecimal"
},
"name": "_formatPrefixedSymbolTwoDecimal"
},
"computed": false
},
"arguments": [
{
"type": "Identifier",
"start": 700,
"end": 706,
"loc": {
"start": {
"line": 23,
"column": 52
},
"end": {
"line": 23,
"column": 58
},
"identifierName": "amount"
},
"name": "amount"
},
{
"type": "Identifier",
"start": 708,
"end": 720,
"loc": {
"start": {
"line": 23,
"column": 60
},
"end": {
"line": 23,
"column": 72
},
"identifierName": "currencyInfo"
},
"name": "currencyInfo"
},
{
"type": "BooleanLiteral",
"start": 722,
"end": 727,
"loc": {
"start": {
"line": 23,
"column": 74
},
"end": {
"line": 23,
"column": 79
}
},
"value": false
}
]
}
}
],
"directives": [],
"trailingComments": null
},
"leadingComments": [
{
"type": "CommentBlock",
"value": "*\n * Format a currency.\n * @param {type}\tamount - Amount in cents.\n * @param {type}\tcurrency - Currency code to convert to.\n * @return {String}\n ",
"start": 268,
"end": 437,
"loc": {
"start": {
"line": 10,
"column": 4
},
"end": {
"line": 15,
"column": 7
}
}
}
],
"trailingComments": [
{
"type": "CommentBlock",
"value": "*\n * Format as 00 $\n * @param {Number}\tamount\n * @param {Object}\tcurrencyInfo\n * @param {Boolean}\tspace\n * @return {String}\n ",
"start": 742,
"end": 895,
"loc": {
"start": {
"line": 27,
"column": 4
},
"end": {
"line": 33,
"column": 7
}
}
}
]
},
{
"type": "ClassMethod",
"start": 900,
"end": 1091,
"loc": {
"start": {
"line": 34,
"column": 4
},
"end": {
"line": 37,
"column": 5
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 900,
"end": 922,
"loc": {
"start": {
"line": 34,
"column": 4
},
"end": {
"line": 34,
"column": 26
},
"identifierName": "_suffixSymbolNoDecimal"
},
"name": "_suffixSymbolNoDecimal",
"leadingComments": null
},
"kind": "method",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 923,
"end": 929,
"loc": {
"start": {
"line": 34,
"column": 27
},
"end": {
"line": 34,
"column": 33
},
"identifierName": "amount"
},
"name": "amount"
},
{
"type": "Identifier",
"start": 931,
"end": 943,
"loc": {
"start": {
"line": 34,
"column": 35
},
"end": {
"line": 34,
"column": 47
},
"identifierName": "currencyInfo"
},
"name": "currencyInfo"
},
{
"type": "Identifier",
"start": 945,
"end": 950,
"loc": {
"start": {
"line": 34,
"column": 49
},
"end": {
"line": 34,
"column": 54
},
"identifierName": "space"
},
"name": "space"
}
],
"body": {
"type": "BlockStatement",
"start": 952,
"end": 1091,
"loc": {
"start": {
"line": 34,
"column": 56
},
"end": {
"line": 37,
"column": 5
}
},
"body": [
{
"type": "ReturnStatement",
"start": 1013,
"end": 1085,
"loc": {
"start": {
"line": 36,
"column": 8
},
"end": {
"line": 36,
"column": 80
}
},
"argument": {
"type": "BinaryExpression",
"start": 1020,
"end": 1084,
"loc": {
"start": {
"line": 36,
"column": 15
},
"end": {
"line": 36,
"column": 79
}
},
"left": {
"type": "BinaryExpression",
"start": 1020,
"end": 1055,
"loc": {
"start": {
"line": 36,
"column": 15
},
"end": {
"line": 36,
"column": 50
}
},
"left": {
"type": "BinaryExpression",
"start": 1021,
"end": 1033,
"loc": {
"start": {
"line": 36,
"column": 16
},
"end": {
"line": 36,
"column": 28
}
},
"left": {
"type": "Identifier",
"start": 1021,
"end": 1027,
"loc": {
"start": {
"line": 36,
"column": 16
},
"end": {
"line": 36,
"column": 22
},
"identifierName": "amount"
},
"name": "amount",
"leadingComments": null
},
"operator": "/",
"right": {
"type": "NumericLiteral",
"start": 1030,
"end": 1033,
"loc": {
"start": {
"line": 36,
"column": 25
},
"end": {
"line": 36,
"column": 28
}
},
"extra": {
"rawValue": 100,
"raw": "100"
},
"value": 100
},
"leadingComments": null,
"extra": {
"parenthesized": true,
"parenStart": 1020
}
},
"operator": "+",
"right": {
"type": "ConditionalExpression",
"start": 1038,
"end": 1054,
"loc": {
"start": {
"line": 36,
"column": 33
},
"end": {
"line": 36,
"column": 49
}
},
"test": {
"type": "Identifier",
"start": 1038,
"end": 1043,
"loc": {
"start": {
"line": 36,
"column": 33
},
"end": {
"line": 36,
"column": 38
},
"identifierName": "space"
},
"name": "space"
},
"consequent": {
"type": "StringLiteral",
"start": 1046,
"end": 1049,
"loc": {
"start": {
"line": 36,
"column": 41
},
"end": {
"line": 36,
"column": 44
}
},
"extra": {
"rawValue": " ",
"raw": "' '"
},
"value": " "
},
"alternate": {
"type": "StringLiteral",
"start": 1052,
"end": 1054,
"loc": {
"start": {
"line": 36,
"column": 47
},
"end": {
"line": 36,
"column": 49
}
},
"extra": {
"rawValue": "",
"raw": "''"
},
"value": ""
},
"extra": {
"parenthesized": true,
"parenStart": 1037
}
},
"leadingComments": null
},
"operator": "+",
"right": {
"type": "MemberExpression",
"start": 1058,
"end": 1084,
"loc": {
"start": {
"line": 36,
"column": 53
},
"end": {
"line": 36,
"column": 79
}
},
"object": {
"type": "Identifier",
"start": 1058,
"end": 1070,
"loc": {
"start": {
"line": 36,
"column": 53
},
"end": {
"line": 36,
"column": 65
},
"identifierName": "currencyInfo"
},
"name": "currencyInfo"
},
"property": {
"type": "Identifier",
"start": 1071,
"end": 1084,
"loc": {
"start": {
"line": 36,
"column": 66
},
"end": {
"line": 36,
"column": 79
},
"identifierName": "symbol_native"
},
"name": "symbol_native"
},
"computed": false
},
"leadingComments": null
},
"leadingComments": [
{
"type": "CommentLine",
"value": " Amount is always in cents, even for JPY",
"start": 962,
"end": 1004,
"loc": {
"start": {
"line": 35,
"column": 8
},
"end": {
"line": 35,
"column": 50
}
}
}
]
}
],
"directives": [],
"trailingComments": null
},
"leadingComments": [
{
"type": "CommentBlock",
"value": "*\n * Format as 00 $\n * @param {Number}\tamount\n * @param {Object}\tcurrencyInfo\n * @param {Boolean}\tspace\n * @return {String}\n ",
"start": 742,
"end": 895,
"loc": {
"start": {
"line": 27,
"column": 4
},
"end": {
"line": 33,
"column": 7
}
}
}
],
"trailingComments": [
{
"type": "CommentBlock",
"value": "*\n * Format as $00.00\n * @param {Number}\tamount\n * @param {Object}\tcurrencyInfo\n * @param {Boolean}\tspace\n * @return {String}\n ",
"start": 1097,
"end": 1252,
"loc": {
"start": {
"line": 39,
"column": 4
},
"end": {
"line": 45,
"column": 7
}
}
}
]
},
{
"type": "ClassMethod",
"start": 1257,
"end": 1417,
"loc": {
"start": {
"line": 46,
"column": 4
},
"end": {
"line": 48,
"column": 5
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 1257,
"end": 1288,
"loc": {
"start": {
"line": 46,
"column": 4
},
"end": {
"line": 46,
"column": 35
},
"identifierName": "_formatPrefixedSymbolTwoDecimal"
},
"name": "_formatPrefixedSymbolTwoDecimal",
"leadingComments": null
},
"kind": "method",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 1289,
"end": 1295,
"loc": {
"start": {
"line": 46,
"column": 36
},
"end": {
"line": 46,
"column": 42
},
"identifierName": "amount"
},
"name": "amount"
},
{
"type": "Identifier",
"start": 1297,
"end": 1309,
"loc": {
"start": {
"line": 46,
"column": 44
},
"end": {
"line": 46,
"column": 56
},
"identifierName": "currencyInfo"
},
"name": "currencyInfo"
},
{
"type": "Identifier",
"start": 1311,
"end": 1316,
"loc": {
"start": {
"line": 46,
"column": 58
},
"end": {
"line": 46,
"column": 63
},
"identifierName": "space"
},
"name": "space"
}
],
"body": {
"type": "BlockStatement",
"start": 1318,
"end": 1417,
"loc": {
"start": {
"line": 46,
"column": 65
},
"end": {
"line": 48,
"column": 5
}
},
"body": [
{
"type": "ReturnStatement",
"start": 1328,
"end": 1411,
"loc": {
"start": {
"line": 47,
"column": 8
},
"end": {
"line": 47,
"column": 91
}
},
"argument": {
"type": "BinaryExpression",
"start": 1335,
"end": 1410,
"loc": {
"start": {
"line": 47,
"column": 15
},
"end": {
"line": 47,
"column": 90
}
},
"left": {
"type": "BinaryExpression",
"start": 1335,
"end": 1382,
"loc": {
"start": {
"line": 47,
"column": 15
},
"end": {
"line": 47,
"column": 62
}
},
"left": {
"type": "MemberExpression",
"start": 1335,
"end": 1361,
"loc": {
"start": {
"line": 47,
"column": 15