123456789101112131415161718192021222324252627282930313233343536373839 |
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- var MathUtil = /** @class */ (function () {
- function MathUtil() {
- }
- /**
- * 判断一个字符串是不是数字
- * @param val
- */
- MathUtil.isNumber = function (val) {
- var regPos = /^\d+(\.\d+)?$/; //非负浮点数
- var regNeg = /^(-(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*)))$/; //负浮点数
- return regPos.test(val) || regNeg.test(val);
- };
- /**
- * 查找数值中的重复
- * @param array
- * @param newUnit
- */
- MathUtil.findSame = function (array, newUnit, name) {
- if (name === void 0) { name = undefined; }
- var ret = -1;
- array.forEach(function (val, index) {
- if (name) {
- if (val[name] == newUnit) {
- ret = index;
- }
- }
- else {
- if (val == newUnit) {
- ret = index;
- }
- }
- });
- return ret;
- };
- return MathUtil;
- }());
- exports.default = MathUtil;
|