PromoCursed/node_modules/.cache/babel-loader/aa08438c35cf26f05be1ddb96f73716665fb8db1f57aa99e2134ed2a7fde7db8.json

1 line
11 KiB
JSON
Raw Normal View History

2024-08-20 23:25:37 +04:00
{"ast":null,"code":"import _classCallCheck from \"@babel/runtime/helpers/esm/classCallCheck\";\nimport _createClass from \"@babel/runtime/helpers/esm/createClass\";\nimport _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nimport { getNumberPrecision, isEmpty, num2str } from \"./numberUtil\";\n\n/**\n * We can remove this when IE not support anymore\n */\nvar NumberDecimal = /*#__PURE__*/function () {\n function NumberDecimal(value) {\n _classCallCheck(this, NumberDecimal);\n _defineProperty(this, \"origin\", '');\n _defineProperty(this, \"number\", void 0);\n _defineProperty(this, \"empty\", void 0);\n if (isEmpty(value)) {\n this.empty = true;\n return;\n }\n this.origin = String(value);\n this.number = Number(value);\n }\n _createClass(NumberDecimal, [{\n key: \"negate\",\n value: function negate() {\n return new NumberDecimal(-this.toNumber());\n }\n }, {\n key: \"add\",\n value: function add(value) {\n if (this.isInvalidate()) {\n return new NumberDecimal(value);\n }\n var target = Number(value);\n if (Number.isNaN(target)) {\n return this;\n }\n var number = this.number + target;\n\n // [Legacy] Back to safe integer\n if (number > Number.MAX_SAFE_INTEGER) {\n return new NumberDecimal(Number.MAX_SAFE_INTEGER);\n }\n if (number < Number.MIN_SAFE_INTEGER) {\n return new NumberDecimal(Number.MIN_SAFE_INTEGER);\n }\n var maxPrecision = Math.max(getNumberPrecision(this.number), getNumberPrecision(target));\n return new NumberDecimal(number.toFixed(maxPrecision));\n }\n }, {\n key: \"multi\",\n value: function multi(value) {\n var target = Number(value);\n if (this.isInvalidate() || Number.isNaN(target)) {\n return new NumberDecimal(NaN);\n }\n var number = this.number * target;\n\n // [Legacy] Back to safe integer\n if (number > Number.MAX_SAFE_INTEGER) {\n return new NumberDecimal(Number.MAX_SAFE_INTEGER);\n }\n if (number < Number.MIN_SAFE_INTEGER) {\n return new NumberDecimal(Number.MIN_SAFE_INTEGER);\n }\n var maxPrecision = Math.max(getNumberPrecision(this.number), getNumberPrecision(target));\n return new NumberDecimal(number.toFixed(maxPrecision));\n }\n }, {\n key: \"isEmpty\",\n value: function isEmpty() {\n return this.empty;\n }\n }, {\n key: \"isNaN\",\n value: function isNaN() {\n return Number.isNaN(this.number);\n }\n }, {\n key: \"isInvalidate\",\n value: function isInvalidate() {\n return this.isEmpty() || this.isNaN();\n }\n }, {\n key: \"equals\",\n value: function equals(target) {\n return this.toNumber() === (target === null || target === void 0 ? void 0 : target.toNumber());\n }\n }, {\n key: \"lessEquals\",\n value: function lessEquals(target) {\n return this.add(target.negate().toString()).toNumber() <= 0;\n }\n }, {\n key: \"toNumber\",\n value: function toNumber() {\n return this.number;\n }\n }, {\n key: \"toString\",\n value: function toString() {\n var safe = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;\n if (!safe) {\n return this.origin;\n }\n if (this.isInvalidate()) {\n return '';\n }\n return num2str(this.number);\n }\n }]);\n return NumberDecimal;\n}();\nexport { NumberDecimal as default };","map":{"version":3,"names":["_classCallCheck","_createClass","_defineProperty","getNumberPrecision","isEmpty","num2str","NumberDecimal","value","empty","origin","String","number","Number","key","negate","toNumber","add","isInvalidate","target","isNaN","MAX_SAFE_INTEGER","MIN_SAFE_INTEGER","maxPrecision","Math","max","toFixed","multi","NaN","equals","lessEquals","toString","safe","arguments","length","undefined","default"],"sources":["C:/Users/Аришина)/source/repos/PromoCursed/node_modules/@rc-component/mini-decimal/es/NumberDecimal.js"],"sourcesContent":["import _cl