first commit
This commit is contained in:
21
frontend/node_modules/@rc-component/mini-decimal/LICENSE
generated
vendored
Normal file
21
frontend/node_modules/@rc-component/mini-decimal/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019-present react-component
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
21
frontend/node_modules/@rc-component/mini-decimal/README.md
generated
vendored
Normal file
21
frontend/node_modules/@rc-component/mini-decimal/README.md
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
# @rc-component/mini-decimal
|
||||
|
||||
React 18 supported Portal Component.
|
||||
|
||||
[![NPM version][npm-image]][npm-url] [](https://github.com/umijs/dumi) [![build status][github-actions-image]][github-actions-url] [![Codecov][codecov-image]][codecov-url] [![npm download][download-image]][download-url]
|
||||
|
||||
[npm-image]: http://img.shields.io/npm/v/@rc-component/mini-decimal.svg?style=flat-square
|
||||
[npm-url]: http://npmjs.org/package/@rc-component/mini-decimal
|
||||
[github-actions-image]: https://github.com/react-component/mini-decimal/workflows/CI/badge.svg
|
||||
[github-actions-url]: https://github.com/react-component/mini-decimal/actions
|
||||
[codecov-image]: https://img.shields.io/codecov/c/github/react-component/mini-decimal/master.svg?style=flat-square
|
||||
[codecov-url]: https://codecov.io/gh/react-component/mini-decimal/branch/master
|
||||
[download-image]: https://img.shields.io/npm/dm/@rc-component/mini-decimal.svg?style=flat-square
|
||||
[download-url]: https://npmjs.org/package/@rc-component/mini-decimal
|
||||
|
||||
## Development
|
||||
|
||||
```bash
|
||||
npm install
|
||||
npm test
|
||||
```
|
||||
34
frontend/node_modules/@rc-component/mini-decimal/es/BigIntDecimal.d.ts
generated
vendored
Normal file
34
frontend/node_modules/@rc-component/mini-decimal/es/BigIntDecimal.d.ts
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
import type { DecimalClass, ValueType } from './interface';
|
||||
export default class BigIntDecimal implements DecimalClass {
|
||||
origin: string;
|
||||
negative: boolean;
|
||||
integer: bigint;
|
||||
decimal: bigint;
|
||||
/** BigInt will convert `0009` to `9`. We need record the len of decimal */
|
||||
decimalLen: number;
|
||||
empty: boolean;
|
||||
nan: boolean;
|
||||
constructor(value: string | number);
|
||||
private getMark;
|
||||
private getIntegerStr;
|
||||
/**
|
||||
* @private get decimal string
|
||||
*/
|
||||
getDecimalStr(): string;
|
||||
/**
|
||||
* @private Align BigIntDecimal with same decimal length. e.g. 12.3 + 5 = 1230000
|
||||
* This is used for add function only.
|
||||
*/
|
||||
alignDecimal(decimalLength: number): bigint;
|
||||
negate(): BigIntDecimal;
|
||||
private cal;
|
||||
add(value: ValueType): BigIntDecimal;
|
||||
multi(value: ValueType): BigIntDecimal;
|
||||
isEmpty(): boolean;
|
||||
isNaN(): boolean;
|
||||
isInvalidate(): boolean;
|
||||
equals(target: DecimalClass): boolean;
|
||||
lessEquals(target: DecimalClass): boolean;
|
||||
toNumber(): number;
|
||||
toString(safe?: boolean): string;
|
||||
}
|
||||
177
frontend/node_modules/@rc-component/mini-decimal/es/BigIntDecimal.js
generated
vendored
Normal file
177
frontend/node_modules/@rc-component/mini-decimal/es/BigIntDecimal.js
generated
vendored
Normal file
@@ -0,0 +1,177 @@
|
||||
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
||||
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
||||
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
||||
import { isE, isEmpty, num2str, trimNumber, validateNumber } from "./numberUtil";
|
||||
var BigIntDecimal = /*#__PURE__*/function () {
|
||||
/** BigInt will convert `0009` to `9`. We need record the len of decimal */
|
||||
|
||||
function BigIntDecimal(value) {
|
||||
_classCallCheck(this, BigIntDecimal);
|
||||
_defineProperty(this, "origin", '');
|
||||
_defineProperty(this, "negative", void 0);
|
||||
_defineProperty(this, "integer", void 0);
|
||||
_defineProperty(this, "decimal", void 0);
|
||||
_defineProperty(this, "decimalLen", void 0);
|
||||
_defineProperty(this, "empty", void 0);
|
||||
_defineProperty(this, "nan", void 0);
|
||||
if (isEmpty(value)) {
|
||||
this.empty = true;
|
||||
return;
|
||||
}
|
||||
this.origin = String(value);
|
||||
|
||||
// Act like Number convert
|
||||
if (value === '-' || Number.isNaN(value)) {
|
||||
this.nan = true;
|
||||
return;
|
||||
}
|
||||
var mergedValue = value;
|
||||
|
||||
// We need convert back to Number since it require `toFixed` to handle this
|
||||
if (isE(mergedValue)) {
|
||||
mergedValue = Number(mergedValue);
|
||||
}
|
||||
mergedValue = typeof mergedValue === 'string' ? mergedValue : num2str(mergedValue);
|
||||
if (validateNumber(mergedValue)) {
|
||||
var trimRet = trimNumber(mergedValue);
|
||||
this.negative = trimRet.negative;
|
||||
var numbers = trimRet.trimStr.split('.');
|
||||
this.integer = BigInt(numbers[0]);
|
||||
var decimalStr = numbers[1] || '0';
|
||||
this.decimal = BigInt(decimalStr);
|
||||
this.decimalLen = decimalStr.length;
|
||||
} else {
|
||||
this.nan = true;
|
||||
}
|
||||
}
|
||||
_createClass(BigIntDecimal, [{
|
||||
key: "getMark",
|
||||
value: function getMark() {
|
||||
return this.negative ? '-' : '';
|
||||
}
|
||||
}, {
|
||||
key: "getIntegerStr",
|
||||
value: function getIntegerStr() {
|
||||
return this.integer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @private get decimal string
|
||||
*/
|
||||
}, {
|
||||
key: "getDecimalStr",
|
||||
value: function getDecimalStr() {
|
||||
return this.decimal.toString().padStart(this.decimalLen, '0');
|
||||
}
|
||||
|
||||
/**
|
||||
* @private Align BigIntDecimal with same decimal length. e.g. 12.3 + 5 = 1230000
|
||||
* This is used for add function only.
|
||||
*/
|
||||
}, {
|
||||
key: "alignDecimal",
|
||||
value: function alignDecimal(decimalLength) {
|
||||
var str = "".concat(this.getMark()).concat(this.getIntegerStr()).concat(this.getDecimalStr().padEnd(decimalLength, '0'));
|
||||
return BigInt(str);
|
||||
}
|
||||
}, {
|
||||
key: "negate",
|
||||
value: function negate() {
|
||||
var clone = new BigIntDecimal(this.toString());
|
||||
clone.negative = !clone.negative;
|
||||
return clone;
|
||||
}
|
||||
}, {
|
||||
key: "cal",
|
||||
value: function cal(offset, calculator, calDecimalLen) {
|
||||
var maxDecimalLength = Math.max(this.getDecimalStr().length, offset.getDecimalStr().length);
|
||||
var myAlignedDecimal = this.alignDecimal(maxDecimalLength);
|
||||
var offsetAlignedDecimal = offset.alignDecimal(maxDecimalLength);
|
||||
var valueStr = calculator(myAlignedDecimal, offsetAlignedDecimal).toString();
|
||||
var nextDecimalLength = calDecimalLen(maxDecimalLength);
|
||||
|
||||
// We need fill string length back to `maxDecimalLength` to avoid parser failed
|
||||
var _trimNumber = trimNumber(valueStr),
|
||||
negativeStr = _trimNumber.negativeStr,
|
||||
trimStr = _trimNumber.trimStr;
|
||||
var hydrateValueStr = "".concat(negativeStr).concat(trimStr.padStart(nextDecimalLength + 1, '0'));
|
||||
return new BigIntDecimal("".concat(hydrateValueStr.slice(0, -nextDecimalLength), ".").concat(hydrateValueStr.slice(-nextDecimalLength)));
|
||||
}
|
||||
}, {
|
||||
key: "add",
|
||||
value: function add(value) {
|
||||
if (this.isInvalidate()) {
|
||||
return new BigIntDecimal(value);
|
||||
}
|
||||
var offset = new BigIntDecimal(value);
|
||||
if (offset.isInvalidate()) {
|
||||
return this;
|
||||
}
|
||||
return this.cal(offset, function (num1, num2) {
|
||||
return num1 + num2;
|
||||
}, function (len) {
|
||||
return len;
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "multi",
|
||||
value: function multi(value) {
|
||||
var target = new BigIntDecimal(value);
|
||||
if (this.isInvalidate() || target.isInvalidate()) {
|
||||
return new BigIntDecimal(NaN);
|
||||
}
|
||||
return this.cal(target, function (num1, num2) {
|
||||
return num1 * num2;
|
||||
}, function (len) {
|
||||
return len * 2;
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "isEmpty",
|
||||
value: function isEmpty() {
|
||||
return this.empty;
|
||||
}
|
||||
}, {
|
||||
key: "isNaN",
|
||||
value: function isNaN() {
|
||||
return this.nan;
|
||||
}
|
||||
}, {
|
||||
key: "isInvalidate",
|
||||
value: function isInvalidate() {
|
||||
return this.isEmpty() || this.isNaN();
|
||||
}
|
||||
}, {
|
||||
key: "equals",
|
||||
value: function equals(target) {
|
||||
return this.toString() === (target === null || target === void 0 ? void 0 : target.toString());
|
||||
}
|
||||
}, {
|
||||
key: "lessEquals",
|
||||
value: function lessEquals(target) {
|
||||
return this.add(target.negate().toString()).toNumber() <= 0;
|
||||
}
|
||||
}, {
|
||||
key: "toNumber",
|
||||
value: function toNumber() {
|
||||
if (this.isNaN()) {
|
||||
return NaN;
|
||||
}
|
||||
return Number(this.toString());
|
||||
}
|
||||
}, {
|
||||
key: "toString",
|
||||
value: function toString() {
|
||||
var safe = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
||||
if (!safe) {
|
||||
return this.origin;
|
||||
}
|
||||
if (this.isInvalidate()) {
|
||||
return '';
|
||||
}
|
||||
return trimNumber("".concat(this.getMark()).concat(this.getIntegerStr(), ".").concat(this.getDecimalStr())).fullStr;
|
||||
}
|
||||
}]);
|
||||
return BigIntDecimal;
|
||||
}();
|
||||
export { BigIntDecimal as default };
|
||||
11
frontend/node_modules/@rc-component/mini-decimal/es/MiniDecimal.d.ts
generated
vendored
Normal file
11
frontend/node_modules/@rc-component/mini-decimal/es/MiniDecimal.d.ts
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
import BigIntDecimal from './BigIntDecimal';
|
||||
import NumberDecimal from './NumberDecimal';
|
||||
import type { DecimalClass, ValueType } from './interface';
|
||||
export { NumberDecimal, BigIntDecimal };
|
||||
export type { DecimalClass, ValueType };
|
||||
export default function getMiniDecimal(value: ValueType): DecimalClass;
|
||||
/**
|
||||
* Align the logic of toFixed to around like 1.5 => 2.
|
||||
* If set `cutOnly`, will just remove the over decimal part.
|
||||
*/
|
||||
export declare function toFixed(numStr: string, separatorStr: string, precision?: number, cutOnly?: boolean): any;
|
||||
50
frontend/node_modules/@rc-component/mini-decimal/es/MiniDecimal.js
generated
vendored
Normal file
50
frontend/node_modules/@rc-component/mini-decimal/es/MiniDecimal.js
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
/* eslint-disable max-classes-per-file */
|
||||
|
||||
import BigIntDecimal from "./BigIntDecimal";
|
||||
import NumberDecimal from "./NumberDecimal";
|
||||
import { trimNumber } from "./numberUtil";
|
||||
import { supportBigInt } from "./supportUtil";
|
||||
|
||||
// Still support origin export
|
||||
export { NumberDecimal, BigIntDecimal };
|
||||
export default function getMiniDecimal(value) {
|
||||
// We use BigInt here.
|
||||
// Will fallback to Number if not support.
|
||||
if (supportBigInt()) {
|
||||
return new BigIntDecimal(value);
|
||||
}
|
||||
return new NumberDecimal(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Align the logic of toFixed to around like 1.5 => 2.
|
||||
* If set `cutOnly`, will just remove the over decimal part.
|
||||
*/
|
||||
export function toFixed(numStr, separatorStr, precision) {
|
||||
var cutOnly = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
||||
if (numStr === '') {
|
||||
return '';
|
||||
}
|
||||
var _trimNumber = trimNumber(numStr),
|
||||
negativeStr = _trimNumber.negativeStr,
|
||||
integerStr = _trimNumber.integerStr,
|
||||
decimalStr = _trimNumber.decimalStr;
|
||||
var precisionDecimalStr = "".concat(separatorStr).concat(decimalStr);
|
||||
var numberWithoutDecimal = "".concat(negativeStr).concat(integerStr);
|
||||
if (precision >= 0) {
|
||||
// We will get last + 1 number to check if need advanced number
|
||||
var advancedNum = Number(decimalStr[precision]);
|
||||
if (advancedNum >= 5 && !cutOnly) {
|
||||
var advancedDecimal = getMiniDecimal(numStr).add("".concat(negativeStr, "0.").concat('0'.repeat(precision)).concat(10 - advancedNum));
|
||||
return toFixed(advancedDecimal.toString(), separatorStr, precision, cutOnly);
|
||||
}
|
||||
if (precision === 0) {
|
||||
return numberWithoutDecimal;
|
||||
}
|
||||
return "".concat(numberWithoutDecimal).concat(separatorStr).concat(decimalStr.padEnd(precision, '0').slice(0, precision));
|
||||
}
|
||||
if (precisionDecimalStr === '.0') {
|
||||
return numberWithoutDecimal;
|
||||
}
|
||||
return "".concat(numberWithoutDecimal).concat(precisionDecimalStr);
|
||||
}
|
||||
20
frontend/node_modules/@rc-component/mini-decimal/es/NumberDecimal.d.ts
generated
vendored
Normal file
20
frontend/node_modules/@rc-component/mini-decimal/es/NumberDecimal.d.ts
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
import type { DecimalClass, ValueType } from './interface';
|
||||
/**
|
||||
* We can remove this when IE not support anymore
|
||||
*/
|
||||
export default class NumberDecimal implements DecimalClass {
|
||||
origin: string;
|
||||
number: number;
|
||||
empty: boolean;
|
||||
constructor(value: ValueType);
|
||||
negate(): NumberDecimal;
|
||||
add(value: ValueType): NumberDecimal;
|
||||
multi(value: ValueType): NumberDecimal;
|
||||
isEmpty(): boolean;
|
||||
isNaN(): boolean;
|
||||
isInvalidate(): boolean;
|
||||
equals(target: DecimalClass): boolean;
|
||||
lessEquals(target: DecimalClass): boolean;
|
||||
toNumber(): number;
|
||||
toString(safe?: boolean): string;
|
||||
}
|
||||
113
frontend/node_modules/@rc-component/mini-decimal/es/NumberDecimal.js
generated
vendored
Normal file
113
frontend/node_modules/@rc-component/mini-decimal/es/NumberDecimal.js
generated
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
||||
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
||||
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
||||
import { getNumberPrecision, isEmpty, num2str } from "./numberUtil";
|
||||
|
||||
/**
|
||||
* We can remove this when IE not support anymore
|
||||
*/
|
||||
var NumberDecimal = /*#__PURE__*/function () {
|
||||
function NumberDecimal(value) {
|
||||
_classCallCheck(this, NumberDecimal);
|
||||
_defineProperty(this, "origin", '');
|
||||
_defineProperty(this, "number", void 0);
|
||||
_defineProperty(this, "empty", void 0);
|
||||
if (isEmpty(value)) {
|
||||
this.empty = true;
|
||||
return;
|
||||
}
|
||||
this.origin = String(value);
|
||||
this.number = Number(value);
|
||||
}
|
||||
_createClass(NumberDecimal, [{
|
||||
key: "negate",
|
||||
value: function negate() {
|
||||
return new NumberDecimal(-this.toNumber());
|
||||
}
|
||||
}, {
|
||||
key: "add",
|
||||
value: function add(value) {
|
||||
if (this.isInvalidate()) {
|
||||
return new NumberDecimal(value);
|
||||
}
|
||||
var target = Number(value);
|
||||
if (Number.isNaN(target)) {
|
||||
return this;
|
||||
}
|
||||
var number = this.number + target;
|
||||
|
||||
// [Legacy] Back to safe integer
|
||||
if (number > Number.MAX_SAFE_INTEGER) {
|
||||
return new NumberDecimal(Number.MAX_SAFE_INTEGER);
|
||||
}
|
||||
if (number < Number.MIN_SAFE_INTEGER) {
|
||||
return new NumberDecimal(Number.MIN_SAFE_INTEGER);
|
||||
}
|
||||
var maxPrecision = Math.max(getNumberPrecision(this.number), getNumberPrecision(target));
|
||||
return new NumberDecimal(number.toFixed(maxPrecision));
|
||||
}
|
||||
}, {
|
||||
key: "multi",
|
||||
value: function multi(value) {
|
||||
var target = Number(value);
|
||||
if (this.isInvalidate() || Number.isNaN(target)) {
|
||||
return new NumberDecimal(NaN);
|
||||
}
|
||||
var number = this.number * target;
|
||||
|
||||
// [Legacy] Back to safe integer
|
||||
if (number > Number.MAX_SAFE_INTEGER) {
|
||||
return new NumberDecimal(Number.MAX_SAFE_INTEGER);
|
||||
}
|
||||
if (number < Number.MIN_SAFE_INTEGER) {
|
||||
return new NumberDecimal(Number.MIN_SAFE_INTEGER);
|
||||
}
|
||||
var maxPrecision = Math.max(getNumberPrecision(this.number), getNumberPrecision(target));
|
||||
return new NumberDecimal(number.toFixed(maxPrecision));
|
||||
}
|
||||
}, {
|
||||
key: "isEmpty",
|
||||
value: function isEmpty() {
|
||||
return this.empty;
|
||||
}
|
||||
}, {
|
||||
key: "isNaN",
|
||||
value: function isNaN() {
|
||||
return Number.isNaN(this.number);
|
||||
}
|
||||
}, {
|
||||
key: "isInvalidate",
|
||||
value: function isInvalidate() {
|
||||
return this.isEmpty() || this.isNaN();
|
||||
}
|
||||
}, {
|
||||
key: "equals",
|
||||
value: function equals(target) {
|
||||
return this.toNumber() === (target === null || target === void 0 ? void 0 : target.toNumber());
|
||||
}
|
||||
}, {
|
||||
key: "lessEquals",
|
||||
value: function lessEquals(target) {
|
||||
return this.add(target.negate().toString()).toNumber() <= 0;
|
||||
}
|
||||
}, {
|
||||
key: "toNumber",
|
||||
value: function toNumber() {
|
||||
return this.number;
|
||||
}
|
||||
}, {
|
||||
key: "toString",
|
||||
value: function toString() {
|
||||
var safe = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
||||
if (!safe) {
|
||||
return this.origin;
|
||||
}
|
||||
if (this.isInvalidate()) {
|
||||
return '';
|
||||
}
|
||||
return num2str(this.number);
|
||||
}
|
||||
}]);
|
||||
return NumberDecimal;
|
||||
}();
|
||||
export { NumberDecimal as default };
|
||||
5
frontend/node_modules/@rc-component/mini-decimal/es/index.d.ts
generated
vendored
Normal file
5
frontend/node_modules/@rc-component/mini-decimal/es/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import getMiniDecimal from './MiniDecimal';
|
||||
export * from './MiniDecimal';
|
||||
import { trimNumber, getNumberPrecision, num2str, validateNumber } from './numberUtil';
|
||||
export { trimNumber, getNumberPrecision, num2str, validateNumber };
|
||||
export default getMiniDecimal;
|
||||
5
frontend/node_modules/@rc-component/mini-decimal/es/index.js
generated
vendored
Normal file
5
frontend/node_modules/@rc-component/mini-decimal/es/index.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import getMiniDecimal from "./MiniDecimal";
|
||||
export * from "./MiniDecimal";
|
||||
import { trimNumber, getNumberPrecision, num2str, validateNumber } from "./numberUtil";
|
||||
export { trimNumber, getNumberPrecision, num2str, validateNumber };
|
||||
export default getMiniDecimal;
|
||||
17
frontend/node_modules/@rc-component/mini-decimal/es/interface.d.ts
generated
vendored
Normal file
17
frontend/node_modules/@rc-component/mini-decimal/es/interface.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
export declare type ValueType = string | number;
|
||||
export interface DecimalClass {
|
||||
add: (value: ValueType) => DecimalClass;
|
||||
multi: (value: ValueType) => DecimalClass;
|
||||
isEmpty: () => boolean;
|
||||
isNaN: () => boolean;
|
||||
isInvalidate: () => boolean;
|
||||
toNumber: () => number;
|
||||
/**
|
||||
* Parse value as string. Will return empty string if `isInvalidate`.
|
||||
* You can set `safe=false` to get origin string content.
|
||||
*/
|
||||
toString: (safe?: boolean) => string;
|
||||
equals: (target: DecimalClass) => boolean;
|
||||
lessEquals: (target: DecimalClass) => boolean;
|
||||
negate: () => DecimalClass;
|
||||
}
|
||||
1
frontend/node_modules/@rc-component/mini-decimal/es/interface.js
generated
vendored
Normal file
1
frontend/node_modules/@rc-component/mini-decimal/es/interface.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
24
frontend/node_modules/@rc-component/mini-decimal/es/numberUtil.d.ts
generated
vendored
Normal file
24
frontend/node_modules/@rc-component/mini-decimal/es/numberUtil.d.ts
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
import type { ValueType } from './interface';
|
||||
export declare function isEmpty(value: ValueType): boolean;
|
||||
/**
|
||||
* Format string number to readable number
|
||||
*/
|
||||
export declare function trimNumber(numStr: string): {
|
||||
negative: boolean;
|
||||
negativeStr: string;
|
||||
trimStr: string;
|
||||
integerStr: string;
|
||||
decimalStr: string;
|
||||
fullStr: string;
|
||||
};
|
||||
export declare function isE(number: string | number): boolean;
|
||||
/**
|
||||
* [Legacy] Convert 1e-9 to 0.000000001.
|
||||
* This may lose some precision if user really want 1e-9.
|
||||
*/
|
||||
export declare function getNumberPrecision(number: string | number): number;
|
||||
/**
|
||||
* Convert number (includes scientific notation) to -xxx.yyy format
|
||||
*/
|
||||
export declare function num2str(number: number): string;
|
||||
export declare function validateNumber(num: string | number): boolean;
|
||||
97
frontend/node_modules/@rc-component/mini-decimal/es/numberUtil.js
generated
vendored
Normal file
97
frontend/node_modules/@rc-component/mini-decimal/es/numberUtil.js
generated
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
import { supportBigInt } from "./supportUtil";
|
||||
export function isEmpty(value) {
|
||||
return !value && value !== 0 && !Number.isNaN(value) || !String(value).trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* Format string number to readable number
|
||||
*/
|
||||
export function trimNumber(numStr) {
|
||||
var str = numStr.trim();
|
||||
var negative = str.startsWith('-');
|
||||
if (negative) {
|
||||
str = str.slice(1);
|
||||
}
|
||||
str = str
|
||||
// Remove decimal 0. `1.000` => `1.`, `1.100` => `1.1`
|
||||
.replace(/(\.\d*[^0])0*$/, '$1')
|
||||
// Remove useless decimal. `1.` => `1`
|
||||
.replace(/\.0*$/, '')
|
||||
// Remove integer 0. `0001` => `1`, 000.1' => `.1`
|
||||
.replace(/^0+/, '');
|
||||
if (str.startsWith('.')) {
|
||||
str = "0".concat(str);
|
||||
}
|
||||
var trimStr = str || '0';
|
||||
var splitNumber = trimStr.split('.');
|
||||
var integerStr = splitNumber[0] || '0';
|
||||
var decimalStr = splitNumber[1] || '0';
|
||||
if (integerStr === '0' && decimalStr === '0') {
|
||||
negative = false;
|
||||
}
|
||||
var negativeStr = negative ? '-' : '';
|
||||
return {
|
||||
negative: negative,
|
||||
negativeStr: negativeStr,
|
||||
trimStr: trimStr,
|
||||
integerStr: integerStr,
|
||||
decimalStr: decimalStr,
|
||||
fullStr: "".concat(negativeStr).concat(trimStr)
|
||||
};
|
||||
}
|
||||
export function isE(number) {
|
||||
var str = String(number);
|
||||
return !Number.isNaN(Number(str)) && str.includes('e');
|
||||
}
|
||||
|
||||
/**
|
||||
* [Legacy] Convert 1e-9 to 0.000000001.
|
||||
* This may lose some precision if user really want 1e-9.
|
||||
*/
|
||||
export function getNumberPrecision(number) {
|
||||
var numStr = String(number);
|
||||
if (isE(number)) {
|
||||
var precision = Number(numStr.slice(numStr.indexOf('e-') + 2));
|
||||
var decimalMatch = numStr.match(/\.(\d+)/);
|
||||
if (decimalMatch !== null && decimalMatch !== void 0 && decimalMatch[1]) {
|
||||
precision += decimalMatch[1].length;
|
||||
}
|
||||
return precision;
|
||||
}
|
||||
return numStr.includes('.') && validateNumber(numStr) ? numStr.length - numStr.indexOf('.') - 1 : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert number (includes scientific notation) to -xxx.yyy format
|
||||
*/
|
||||
export function num2str(number) {
|
||||
var numStr = String(number);
|
||||
if (isE(number)) {
|
||||
if (number > Number.MAX_SAFE_INTEGER) {
|
||||
return String(supportBigInt() ? BigInt(number).toString() : Number.MAX_SAFE_INTEGER);
|
||||
}
|
||||
if (number < Number.MIN_SAFE_INTEGER) {
|
||||
return String(supportBigInt() ? BigInt(number).toString() : Number.MIN_SAFE_INTEGER);
|
||||
}
|
||||
numStr = number.toFixed(getNumberPrecision(numStr));
|
||||
}
|
||||
return trimNumber(numStr).fullStr;
|
||||
}
|
||||
export function validateNumber(num) {
|
||||
if (typeof num === 'number') {
|
||||
return !Number.isNaN(num);
|
||||
}
|
||||
|
||||
// Empty
|
||||
if (!num) {
|
||||
return false;
|
||||
}
|
||||
return (
|
||||
// Normal type: 11.28
|
||||
/^\s*-?\d+(\.\d+)?\s*$/.test(num) ||
|
||||
// Pre-number: 1.
|
||||
/^\s*-?\d+\.\s*$/.test(num) ||
|
||||
// Post-number: .1
|
||||
/^\s*-?\.\d+\s*$/.test(num)
|
||||
);
|
||||
}
|
||||
1
frontend/node_modules/@rc-component/mini-decimal/es/supportUtil.d.ts
generated
vendored
Normal file
1
frontend/node_modules/@rc-component/mini-decimal/es/supportUtil.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare function supportBigInt(): boolean;
|
||||
3
frontend/node_modules/@rc-component/mini-decimal/es/supportUtil.js
generated
vendored
Normal file
3
frontend/node_modules/@rc-component/mini-decimal/es/supportUtil.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export function supportBigInt() {
|
||||
return typeof BigInt === 'function';
|
||||
}
|
||||
34
frontend/node_modules/@rc-component/mini-decimal/lib/BigIntDecimal.d.ts
generated
vendored
Normal file
34
frontend/node_modules/@rc-component/mini-decimal/lib/BigIntDecimal.d.ts
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
import type { DecimalClass, ValueType } from './interface';
|
||||
export default class BigIntDecimal implements DecimalClass {
|
||||
origin: string;
|
||||
negative: boolean;
|
||||
integer: bigint;
|
||||
decimal: bigint;
|
||||
/** BigInt will convert `0009` to `9`. We need record the len of decimal */
|
||||
decimalLen: number;
|
||||
empty: boolean;
|
||||
nan: boolean;
|
||||
constructor(value: string | number);
|
||||
private getMark;
|
||||
private getIntegerStr;
|
||||
/**
|
||||
* @private get decimal string
|
||||
*/
|
||||
getDecimalStr(): string;
|
||||
/**
|
||||
* @private Align BigIntDecimal with same decimal length. e.g. 12.3 + 5 = 1230000
|
||||
* This is used for add function only.
|
||||
*/
|
||||
alignDecimal(decimalLength: number): bigint;
|
||||
negate(): BigIntDecimal;
|
||||
private cal;
|
||||
add(value: ValueType): BigIntDecimal;
|
||||
multi(value: ValueType): BigIntDecimal;
|
||||
isEmpty(): boolean;
|
||||
isNaN(): boolean;
|
||||
isInvalidate(): boolean;
|
||||
equals(target: DecimalClass): boolean;
|
||||
lessEquals(target: DecimalClass): boolean;
|
||||
toNumber(): number;
|
||||
toString(safe?: boolean): string;
|
||||
}
|
||||
184
frontend/node_modules/@rc-component/mini-decimal/lib/BigIntDecimal.js
generated
vendored
Normal file
184
frontend/node_modules/@rc-component/mini-decimal/lib/BigIntDecimal.js
generated
vendored
Normal file
@@ -0,0 +1,184 @@
|
||||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
||||
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
||||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
||||
var _numberUtil = require("./numberUtil");
|
||||
var BigIntDecimal = /*#__PURE__*/function () {
|
||||
/** BigInt will convert `0009` to `9`. We need record the len of decimal */
|
||||
|
||||
function BigIntDecimal(value) {
|
||||
(0, _classCallCheck2.default)(this, BigIntDecimal);
|
||||
(0, _defineProperty2.default)(this, "origin", '');
|
||||
(0, _defineProperty2.default)(this, "negative", void 0);
|
||||
(0, _defineProperty2.default)(this, "integer", void 0);
|
||||
(0, _defineProperty2.default)(this, "decimal", void 0);
|
||||
(0, _defineProperty2.default)(this, "decimalLen", void 0);
|
||||
(0, _defineProperty2.default)(this, "empty", void 0);
|
||||
(0, _defineProperty2.default)(this, "nan", void 0);
|
||||
if ((0, _numberUtil.isEmpty)(value)) {
|
||||
this.empty = true;
|
||||
return;
|
||||
}
|
||||
this.origin = String(value);
|
||||
|
||||
// Act like Number convert
|
||||
if (value === '-' || Number.isNaN(value)) {
|
||||
this.nan = true;
|
||||
return;
|
||||
}
|
||||
var mergedValue = value;
|
||||
|
||||
// We need convert back to Number since it require `toFixed` to handle this
|
||||
if ((0, _numberUtil.isE)(mergedValue)) {
|
||||
mergedValue = Number(mergedValue);
|
||||
}
|
||||
mergedValue = typeof mergedValue === 'string' ? mergedValue : (0, _numberUtil.num2str)(mergedValue);
|
||||
if ((0, _numberUtil.validateNumber)(mergedValue)) {
|
||||
var trimRet = (0, _numberUtil.trimNumber)(mergedValue);
|
||||
this.negative = trimRet.negative;
|
||||
var numbers = trimRet.trimStr.split('.');
|
||||
this.integer = BigInt(numbers[0]);
|
||||
var decimalStr = numbers[1] || '0';
|
||||
this.decimal = BigInt(decimalStr);
|
||||
this.decimalLen = decimalStr.length;
|
||||
} else {
|
||||
this.nan = true;
|
||||
}
|
||||
}
|
||||
(0, _createClass2.default)(BigIntDecimal, [{
|
||||
key: "getMark",
|
||||
value: function getMark() {
|
||||
return this.negative ? '-' : '';
|
||||
}
|
||||
}, {
|
||||
key: "getIntegerStr",
|
||||
value: function getIntegerStr() {
|
||||
return this.integer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @private get decimal string
|
||||
*/
|
||||
}, {
|
||||
key: "getDecimalStr",
|
||||
value: function getDecimalStr() {
|
||||
return this.decimal.toString().padStart(this.decimalLen, '0');
|
||||
}
|
||||
|
||||
/**
|
||||
* @private Align BigIntDecimal with same decimal length. e.g. 12.3 + 5 = 1230000
|
||||
* This is used for add function only.
|
||||
*/
|
||||
}, {
|
||||
key: "alignDecimal",
|
||||
value: function alignDecimal(decimalLength) {
|
||||
var str = "".concat(this.getMark()).concat(this.getIntegerStr()).concat(this.getDecimalStr().padEnd(decimalLength, '0'));
|
||||
return BigInt(str);
|
||||
}
|
||||
}, {
|
||||
key: "negate",
|
||||
value: function negate() {
|
||||
var clone = new BigIntDecimal(this.toString());
|
||||
clone.negative = !clone.negative;
|
||||
return clone;
|
||||
}
|
||||
}, {
|
||||
key: "cal",
|
||||
value: function cal(offset, calculator, calDecimalLen) {
|
||||
var maxDecimalLength = Math.max(this.getDecimalStr().length, offset.getDecimalStr().length);
|
||||
var myAlignedDecimal = this.alignDecimal(maxDecimalLength);
|
||||
var offsetAlignedDecimal = offset.alignDecimal(maxDecimalLength);
|
||||
var valueStr = calculator(myAlignedDecimal, offsetAlignedDecimal).toString();
|
||||
var nextDecimalLength = calDecimalLen(maxDecimalLength);
|
||||
|
||||
// We need fill string length back to `maxDecimalLength` to avoid parser failed
|
||||
var _trimNumber = (0, _numberUtil.trimNumber)(valueStr),
|
||||
negativeStr = _trimNumber.negativeStr,
|
||||
trimStr = _trimNumber.trimStr;
|
||||
var hydrateValueStr = "".concat(negativeStr).concat(trimStr.padStart(nextDecimalLength + 1, '0'));
|
||||
return new BigIntDecimal("".concat(hydrateValueStr.slice(0, -nextDecimalLength), ".").concat(hydrateValueStr.slice(-nextDecimalLength)));
|
||||
}
|
||||
}, {
|
||||
key: "add",
|
||||
value: function add(value) {
|
||||
if (this.isInvalidate()) {
|
||||
return new BigIntDecimal(value);
|
||||
}
|
||||
var offset = new BigIntDecimal(value);
|
||||
if (offset.isInvalidate()) {
|
||||
return this;
|
||||
}
|
||||
return this.cal(offset, function (num1, num2) {
|
||||
return num1 + num2;
|
||||
}, function (len) {
|
||||
return len;
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "multi",
|
||||
value: function multi(value) {
|
||||
var target = new BigIntDecimal(value);
|
||||
if (this.isInvalidate() || target.isInvalidate()) {
|
||||
return new BigIntDecimal(NaN);
|
||||
}
|
||||
return this.cal(target, function (num1, num2) {
|
||||
return num1 * num2;
|
||||
}, function (len) {
|
||||
return len * 2;
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "isEmpty",
|
||||
value: function isEmpty() {
|
||||
return this.empty;
|
||||
}
|
||||
}, {
|
||||
key: "isNaN",
|
||||
value: function isNaN() {
|
||||
return this.nan;
|
||||
}
|
||||
}, {
|
||||
key: "isInvalidate",
|
||||
value: function isInvalidate() {
|
||||
return this.isEmpty() || this.isNaN();
|
||||
}
|
||||
}, {
|
||||
key: "equals",
|
||||
value: function equals(target) {
|
||||
return this.toString() === (target === null || target === void 0 ? void 0 : target.toString());
|
||||
}
|
||||
}, {
|
||||
key: "lessEquals",
|
||||
value: function lessEquals(target) {
|
||||
return this.add(target.negate().toString()).toNumber() <= 0;
|
||||
}
|
||||
}, {
|
||||
key: "toNumber",
|
||||
value: function toNumber() {
|
||||
if (this.isNaN()) {
|
||||
return NaN;
|
||||
}
|
||||
return Number(this.toString());
|
||||
}
|
||||
}, {
|
||||
key: "toString",
|
||||
value: function toString() {
|
||||
var safe = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
||||
if (!safe) {
|
||||
return this.origin;
|
||||
}
|
||||
if (this.isInvalidate()) {
|
||||
return '';
|
||||
}
|
||||
return (0, _numberUtil.trimNumber)("".concat(this.getMark()).concat(this.getIntegerStr(), ".").concat(this.getDecimalStr())).fullStr;
|
||||
}
|
||||
}]);
|
||||
return BigIntDecimal;
|
||||
}();
|
||||
exports.default = BigIntDecimal;
|
||||
11
frontend/node_modules/@rc-component/mini-decimal/lib/MiniDecimal.d.ts
generated
vendored
Normal file
11
frontend/node_modules/@rc-component/mini-decimal/lib/MiniDecimal.d.ts
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
import BigIntDecimal from './BigIntDecimal';
|
||||
import NumberDecimal from './NumberDecimal';
|
||||
import type { DecimalClass, ValueType } from './interface';
|
||||
export { NumberDecimal, BigIntDecimal };
|
||||
export type { DecimalClass, ValueType };
|
||||
export default function getMiniDecimal(value: ValueType): DecimalClass;
|
||||
/**
|
||||
* Align the logic of toFixed to around like 1.5 => 2.
|
||||
* If set `cutOnly`, will just remove the over decimal part.
|
||||
*/
|
||||
export declare function toFixed(numStr: string, separatorStr: string, precision?: number, cutOnly?: boolean): any;
|
||||
69
frontend/node_modules/@rc-component/mini-decimal/lib/MiniDecimal.js
generated
vendored
Normal file
69
frontend/node_modules/@rc-component/mini-decimal/lib/MiniDecimal.js
generated
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "BigIntDecimal", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _BigIntDecimal.default;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "NumberDecimal", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _NumberDecimal.default;
|
||||
}
|
||||
});
|
||||
exports.default = getMiniDecimal;
|
||||
exports.toFixed = toFixed;
|
||||
var _BigIntDecimal = _interopRequireDefault(require("./BigIntDecimal"));
|
||||
var _NumberDecimal = _interopRequireDefault(require("./NumberDecimal"));
|
||||
var _numberUtil = require("./numberUtil");
|
||||
var _supportUtil = require("./supportUtil");
|
||||
/* eslint-disable max-classes-per-file */
|
||||
|
||||
// Still support origin export
|
||||
|
||||
function getMiniDecimal(value) {
|
||||
// We use BigInt here.
|
||||
// Will fallback to Number if not support.
|
||||
if ((0, _supportUtil.supportBigInt)()) {
|
||||
return new _BigIntDecimal.default(value);
|
||||
}
|
||||
return new _NumberDecimal.default(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Align the logic of toFixed to around like 1.5 => 2.
|
||||
* If set `cutOnly`, will just remove the over decimal part.
|
||||
*/
|
||||
function toFixed(numStr, separatorStr, precision) {
|
||||
var cutOnly = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
||||
if (numStr === '') {
|
||||
return '';
|
||||
}
|
||||
var _trimNumber = (0, _numberUtil.trimNumber)(numStr),
|
||||
negativeStr = _trimNumber.negativeStr,
|
||||
integerStr = _trimNumber.integerStr,
|
||||
decimalStr = _trimNumber.decimalStr;
|
||||
var precisionDecimalStr = "".concat(separatorStr).concat(decimalStr);
|
||||
var numberWithoutDecimal = "".concat(negativeStr).concat(integerStr);
|
||||
if (precision >= 0) {
|
||||
// We will get last + 1 number to check if need advanced number
|
||||
var advancedNum = Number(decimalStr[precision]);
|
||||
if (advancedNum >= 5 && !cutOnly) {
|
||||
var advancedDecimal = getMiniDecimal(numStr).add("".concat(negativeStr, "0.").concat('0'.repeat(precision)).concat(10 - advancedNum));
|
||||
return toFixed(advancedDecimal.toString(), separatorStr, precision, cutOnly);
|
||||
}
|
||||
if (precision === 0) {
|
||||
return numberWithoutDecimal;
|
||||
}
|
||||
return "".concat(numberWithoutDecimal).concat(separatorStr).concat(decimalStr.padEnd(precision, '0').slice(0, precision));
|
||||
}
|
||||
if (precisionDecimalStr === '.0') {
|
||||
return numberWithoutDecimal;
|
||||
}
|
||||
return "".concat(numberWithoutDecimal).concat(precisionDecimalStr);
|
||||
}
|
||||
20
frontend/node_modules/@rc-component/mini-decimal/lib/NumberDecimal.d.ts
generated
vendored
Normal file
20
frontend/node_modules/@rc-component/mini-decimal/lib/NumberDecimal.d.ts
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
import type { DecimalClass, ValueType } from './interface';
|
||||
/**
|
||||
* We can remove this when IE not support anymore
|
||||
*/
|
||||
export default class NumberDecimal implements DecimalClass {
|
||||
origin: string;
|
||||
number: number;
|
||||
empty: boolean;
|
||||
constructor(value: ValueType);
|
||||
negate(): NumberDecimal;
|
||||
add(value: ValueType): NumberDecimal;
|
||||
multi(value: ValueType): NumberDecimal;
|
||||
isEmpty(): boolean;
|
||||
isNaN(): boolean;
|
||||
isInvalidate(): boolean;
|
||||
equals(target: DecimalClass): boolean;
|
||||
lessEquals(target: DecimalClass): boolean;
|
||||
toNumber(): number;
|
||||
toString(safe?: boolean): string;
|
||||
}
|
||||
119
frontend/node_modules/@rc-component/mini-decimal/lib/NumberDecimal.js
generated
vendored
Normal file
119
frontend/node_modules/@rc-component/mini-decimal/lib/NumberDecimal.js
generated
vendored
Normal file
@@ -0,0 +1,119 @@
|
||||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
||||
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
||||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
||||
var _numberUtil = require("./numberUtil");
|
||||
/**
|
||||
* We can remove this when IE not support anymore
|
||||
*/
|
||||
var NumberDecimal = /*#__PURE__*/function () {
|
||||
function NumberDecimal(value) {
|
||||
(0, _classCallCheck2.default)(this, NumberDecimal);
|
||||
(0, _defineProperty2.default)(this, "origin", '');
|
||||
(0, _defineProperty2.default)(this, "number", void 0);
|
||||
(0, _defineProperty2.default)(this, "empty", void 0);
|
||||
if ((0, _numberUtil.isEmpty)(value)) {
|
||||
this.empty = true;
|
||||
return;
|
||||
}
|
||||
this.origin = String(value);
|
||||
this.number = Number(value);
|
||||
}
|
||||
(0, _createClass2.default)(NumberDecimal, [{
|
||||
key: "negate",
|
||||
value: function negate() {
|
||||
return new NumberDecimal(-this.toNumber());
|
||||
}
|
||||
}, {
|
||||
key: "add",
|
||||
value: function add(value) {
|
||||
if (this.isInvalidate()) {
|
||||
return new NumberDecimal(value);
|
||||
}
|
||||
var target = Number(value);
|
||||
if (Number.isNaN(target)) {
|
||||
return this;
|
||||
}
|
||||
var number = this.number + target;
|
||||
|
||||
// [Legacy] Back to safe integer
|
||||
if (number > Number.MAX_SAFE_INTEGER) {
|
||||
return new NumberDecimal(Number.MAX_SAFE_INTEGER);
|
||||
}
|
||||
if (number < Number.MIN_SAFE_INTEGER) {
|
||||
return new NumberDecimal(Number.MIN_SAFE_INTEGER);
|
||||
}
|
||||
var maxPrecision = Math.max((0, _numberUtil.getNumberPrecision)(this.number), (0, _numberUtil.getNumberPrecision)(target));
|
||||
return new NumberDecimal(number.toFixed(maxPrecision));
|
||||
}
|
||||
}, {
|
||||
key: "multi",
|
||||
value: function multi(value) {
|
||||
var target = Number(value);
|
||||
if (this.isInvalidate() || Number.isNaN(target)) {
|
||||
return new NumberDecimal(NaN);
|
||||
}
|
||||
var number = this.number * target;
|
||||
|
||||
// [Legacy] Back to safe integer
|
||||
if (number > Number.MAX_SAFE_INTEGER) {
|
||||
return new NumberDecimal(Number.MAX_SAFE_INTEGER);
|
||||
}
|
||||
if (number < Number.MIN_SAFE_INTEGER) {
|
||||
return new NumberDecimal(Number.MIN_SAFE_INTEGER);
|
||||
}
|
||||
var maxPrecision = Math.max((0, _numberUtil.getNumberPrecision)(this.number), (0, _numberUtil.getNumberPrecision)(target));
|
||||
return new NumberDecimal(number.toFixed(maxPrecision));
|
||||
}
|
||||
}, {
|
||||
key: "isEmpty",
|
||||
value: function isEmpty() {
|
||||
return this.empty;
|
||||
}
|
||||
}, {
|
||||
key: "isNaN",
|
||||
value: function isNaN() {
|
||||
return Number.isNaN(this.number);
|
||||
}
|
||||
}, {
|
||||
key: "isInvalidate",
|
||||
value: function isInvalidate() {
|
||||
return this.isEmpty() || this.isNaN();
|
||||
}
|
||||
}, {
|
||||
key: "equals",
|
||||
value: function equals(target) {
|
||||
return this.toNumber() === (target === null || target === void 0 ? void 0 : target.toNumber());
|
||||
}
|
||||
}, {
|
||||
key: "lessEquals",
|
||||
value: function lessEquals(target) {
|
||||
return this.add(target.negate().toString()).toNumber() <= 0;
|
||||
}
|
||||
}, {
|
||||
key: "toNumber",
|
||||
value: function toNumber() {
|
||||
return this.number;
|
||||
}
|
||||
}, {
|
||||
key: "toString",
|
||||
value: function toString() {
|
||||
var safe = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
||||
if (!safe) {
|
||||
return this.origin;
|
||||
}
|
||||
if (this.isInvalidate()) {
|
||||
return '';
|
||||
}
|
||||
return (0, _numberUtil.num2str)(this.number);
|
||||
}
|
||||
}]);
|
||||
return NumberDecimal;
|
||||
}();
|
||||
exports.default = NumberDecimal;
|
||||
5
frontend/node_modules/@rc-component/mini-decimal/lib/index.d.ts
generated
vendored
Normal file
5
frontend/node_modules/@rc-component/mini-decimal/lib/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import getMiniDecimal from './MiniDecimal';
|
||||
export * from './MiniDecimal';
|
||||
import { trimNumber, getNumberPrecision, num2str, validateNumber } from './numberUtil';
|
||||
export { trimNumber, getNumberPrecision, num2str, validateNumber };
|
||||
export default getMiniDecimal;
|
||||
52
frontend/node_modules/@rc-component/mini-decimal/lib/index.js
generated
vendored
Normal file
52
frontend/node_modules/@rc-component/mini-decimal/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
"use strict";
|
||||
|
||||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
var _exportNames = {
|
||||
trimNumber: true,
|
||||
getNumberPrecision: true,
|
||||
num2str: true,
|
||||
validateNumber: true
|
||||
};
|
||||
exports.default = void 0;
|
||||
Object.defineProperty(exports, "getNumberPrecision", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _numberUtil.getNumberPrecision;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "num2str", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _numberUtil.num2str;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "trimNumber", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _numberUtil.trimNumber;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "validateNumber", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _numberUtil.validateNumber;
|
||||
}
|
||||
});
|
||||
var _MiniDecimal = _interopRequireWildcard(require("./MiniDecimal"));
|
||||
Object.keys(_MiniDecimal).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
if (key in exports && exports[key] === _MiniDecimal[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _MiniDecimal[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
var _numberUtil = require("./numberUtil");
|
||||
var _default = _MiniDecimal.default;
|
||||
exports.default = _default;
|
||||
17
frontend/node_modules/@rc-component/mini-decimal/lib/interface.d.ts
generated
vendored
Normal file
17
frontend/node_modules/@rc-component/mini-decimal/lib/interface.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
export declare type ValueType = string | number;
|
||||
export interface DecimalClass {
|
||||
add: (value: ValueType) => DecimalClass;
|
||||
multi: (value: ValueType) => DecimalClass;
|
||||
isEmpty: () => boolean;
|
||||
isNaN: () => boolean;
|
||||
isInvalidate: () => boolean;
|
||||
toNumber: () => number;
|
||||
/**
|
||||
* Parse value as string. Will return empty string if `isInvalidate`.
|
||||
* You can set `safe=false` to get origin string content.
|
||||
*/
|
||||
toString: (safe?: boolean) => string;
|
||||
equals: (target: DecimalClass) => boolean;
|
||||
lessEquals: (target: DecimalClass) => boolean;
|
||||
negate: () => DecimalClass;
|
||||
}
|
||||
5
frontend/node_modules/@rc-component/mini-decimal/lib/interface.js
generated
vendored
Normal file
5
frontend/node_modules/@rc-component/mini-decimal/lib/interface.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
24
frontend/node_modules/@rc-component/mini-decimal/lib/numberUtil.d.ts
generated
vendored
Normal file
24
frontend/node_modules/@rc-component/mini-decimal/lib/numberUtil.d.ts
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
import type { ValueType } from './interface';
|
||||
export declare function isEmpty(value: ValueType): boolean;
|
||||
/**
|
||||
* Format string number to readable number
|
||||
*/
|
||||
export declare function trimNumber(numStr: string): {
|
||||
negative: boolean;
|
||||
negativeStr: string;
|
||||
trimStr: string;
|
||||
integerStr: string;
|
||||
decimalStr: string;
|
||||
fullStr: string;
|
||||
};
|
||||
export declare function isE(number: string | number): boolean;
|
||||
/**
|
||||
* [Legacy] Convert 1e-9 to 0.000000001.
|
||||
* This may lose some precision if user really want 1e-9.
|
||||
*/
|
||||
export declare function getNumberPrecision(number: string | number): number;
|
||||
/**
|
||||
* Convert number (includes scientific notation) to -xxx.yyy format
|
||||
*/
|
||||
export declare function num2str(number: number): string;
|
||||
export declare function validateNumber(num: string | number): boolean;
|
||||
108
frontend/node_modules/@rc-component/mini-decimal/lib/numberUtil.js
generated
vendored
Normal file
108
frontend/node_modules/@rc-component/mini-decimal/lib/numberUtil.js
generated
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.getNumberPrecision = getNumberPrecision;
|
||||
exports.isE = isE;
|
||||
exports.isEmpty = isEmpty;
|
||||
exports.num2str = num2str;
|
||||
exports.trimNumber = trimNumber;
|
||||
exports.validateNumber = validateNumber;
|
||||
var _supportUtil = require("./supportUtil");
|
||||
function isEmpty(value) {
|
||||
return !value && value !== 0 && !Number.isNaN(value) || !String(value).trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* Format string number to readable number
|
||||
*/
|
||||
function trimNumber(numStr) {
|
||||
var str = numStr.trim();
|
||||
var negative = str.startsWith('-');
|
||||
if (negative) {
|
||||
str = str.slice(1);
|
||||
}
|
||||
str = str
|
||||
// Remove decimal 0. `1.000` => `1.`, `1.100` => `1.1`
|
||||
.replace(/(\.\d*[^0])0*$/, '$1')
|
||||
// Remove useless decimal. `1.` => `1`
|
||||
.replace(/\.0*$/, '')
|
||||
// Remove integer 0. `0001` => `1`, 000.1' => `.1`
|
||||
.replace(/^0+/, '');
|
||||
if (str.startsWith('.')) {
|
||||
str = "0".concat(str);
|
||||
}
|
||||
var trimStr = str || '0';
|
||||
var splitNumber = trimStr.split('.');
|
||||
var integerStr = splitNumber[0] || '0';
|
||||
var decimalStr = splitNumber[1] || '0';
|
||||
if (integerStr === '0' && decimalStr === '0') {
|
||||
negative = false;
|
||||
}
|
||||
var negativeStr = negative ? '-' : '';
|
||||
return {
|
||||
negative: negative,
|
||||
negativeStr: negativeStr,
|
||||
trimStr: trimStr,
|
||||
integerStr: integerStr,
|
||||
decimalStr: decimalStr,
|
||||
fullStr: "".concat(negativeStr).concat(trimStr)
|
||||
};
|
||||
}
|
||||
function isE(number) {
|
||||
var str = String(number);
|
||||
return !Number.isNaN(Number(str)) && str.includes('e');
|
||||
}
|
||||
|
||||
/**
|
||||
* [Legacy] Convert 1e-9 to 0.000000001.
|
||||
* This may lose some precision if user really want 1e-9.
|
||||
*/
|
||||
function getNumberPrecision(number) {
|
||||
var numStr = String(number);
|
||||
if (isE(number)) {
|
||||
var precision = Number(numStr.slice(numStr.indexOf('e-') + 2));
|
||||
var decimalMatch = numStr.match(/\.(\d+)/);
|
||||
if (decimalMatch !== null && decimalMatch !== void 0 && decimalMatch[1]) {
|
||||
precision += decimalMatch[1].length;
|
||||
}
|
||||
return precision;
|
||||
}
|
||||
return numStr.includes('.') && validateNumber(numStr) ? numStr.length - numStr.indexOf('.') - 1 : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert number (includes scientific notation) to -xxx.yyy format
|
||||
*/
|
||||
function num2str(number) {
|
||||
var numStr = String(number);
|
||||
if (isE(number)) {
|
||||
if (number > Number.MAX_SAFE_INTEGER) {
|
||||
return String((0, _supportUtil.supportBigInt)() ? BigInt(number).toString() : Number.MAX_SAFE_INTEGER);
|
||||
}
|
||||
if (number < Number.MIN_SAFE_INTEGER) {
|
||||
return String((0, _supportUtil.supportBigInt)() ? BigInt(number).toString() : Number.MIN_SAFE_INTEGER);
|
||||
}
|
||||
numStr = number.toFixed(getNumberPrecision(numStr));
|
||||
}
|
||||
return trimNumber(numStr).fullStr;
|
||||
}
|
||||
function validateNumber(num) {
|
||||
if (typeof num === 'number') {
|
||||
return !Number.isNaN(num);
|
||||
}
|
||||
|
||||
// Empty
|
||||
if (!num) {
|
||||
return false;
|
||||
}
|
||||
return (
|
||||
// Normal type: 11.28
|
||||
/^\s*-?\d+(\.\d+)?\s*$/.test(num) ||
|
||||
// Pre-number: 1.
|
||||
/^\s*-?\d+\.\s*$/.test(num) ||
|
||||
// Post-number: .1
|
||||
/^\s*-?\.\d+\s*$/.test(num)
|
||||
);
|
||||
}
|
||||
1
frontend/node_modules/@rc-component/mini-decimal/lib/supportUtil.d.ts
generated
vendored
Normal file
1
frontend/node_modules/@rc-component/mini-decimal/lib/supportUtil.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare function supportBigInt(): boolean;
|
||||
9
frontend/node_modules/@rc-component/mini-decimal/lib/supportUtil.js
generated
vendored
Normal file
9
frontend/node_modules/@rc-component/mini-decimal/lib/supportUtil.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.supportBigInt = supportBigInt;
|
||||
function supportBigInt() {
|
||||
return typeof BigInt === 'function';
|
||||
}
|
||||
66
frontend/node_modules/@rc-component/mini-decimal/package.json
generated
vendored
Normal file
66
frontend/node_modules/@rc-component/mini-decimal/package.json
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
{
|
||||
"name": "@rc-component/mini-decimal",
|
||||
"version": "1.1.0",
|
||||
"description": "Lite lib to only support decimal add calculation",
|
||||
"keywords": [
|
||||
"decimal"
|
||||
],
|
||||
"homepage": "https://github.com/react-component/mini-decimal",
|
||||
"bugs": {
|
||||
"url": "https://github.com/react-component/mini-decimal/issues"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/react-component/mini-decimal.git"
|
||||
},
|
||||
"license": "MIT",
|
||||
"author": "smith3816@gmail.com",
|
||||
"main": "./lib/index",
|
||||
"module": "./es/index",
|
||||
"typings": "es/index.d.ts",
|
||||
"files": [
|
||||
"lib",
|
||||
"es",
|
||||
"dist"
|
||||
],
|
||||
"scripts": {
|
||||
"compile": "father build",
|
||||
"deploy": "npm run docs:build && npm run docs:deploy",
|
||||
"docs:build": "dumi build",
|
||||
"docs:deploy": "gh-pages -d docs-dist",
|
||||
"lint": "eslint src/ --ext .tsx,.ts",
|
||||
"lint:tsc": "tsc -p tsconfig.json --noEmit",
|
||||
"now-build": "npm run docs:build",
|
||||
"prepublishOnly": "npm run compile && np --no-cleanup --yolo --no-publish",
|
||||
"prettier": "prettier --write \"**/*.{js,jsx,tsx,ts,less,md,json}\"",
|
||||
"start": "dumi dev",
|
||||
"test": "umi-test",
|
||||
"test:coverage": "npm run test --coverage",
|
||||
"watch": "father dev"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.18.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rc-component/father-plugin": "^1.0.0",
|
||||
"@testing-library/jest-dom": "^5.16.4",
|
||||
"@testing-library/react": "^13.0.0",
|
||||
"@types/jest": "^26.0.20",
|
||||
"@types/react": "^18.0.0",
|
||||
"@types/react-dom": "^18.0.0",
|
||||
"@umijs/fabric": "^2.5.2",
|
||||
"dumi": "^1.1.0",
|
||||
"eslint": "^7.18.0",
|
||||
"father": "^4.0.0-rc.8",
|
||||
"gh-pages": "^3.1.0",
|
||||
"np": "^5.0.3",
|
||||
"prettier": "^2.1.2",
|
||||
"react": "^18.0.0",
|
||||
"react-dom": "^18.0.0",
|
||||
"typescript": "^4.6.3",
|
||||
"umi-test": "^1.9.7"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8.x"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user