feat:node-modules
This commit is contained in:
36
node_modules/mathjs/lib/cjs/function/utils/clone.js
generated
vendored
Normal file
36
node_modules/mathjs/lib/cjs/function/utils/clone.js
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.createClone = void 0;
|
||||
var _object = require("../../utils/object.js");
|
||||
var _factory = require("../../utils/factory.js");
|
||||
const name = 'clone';
|
||||
const dependencies = ['typed'];
|
||||
const createClone = exports.createClone = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
|
||||
let {
|
||||
typed
|
||||
} = _ref;
|
||||
/**
|
||||
* Clone an object. Will make a deep copy of the data.
|
||||
*
|
||||
* Syntax:
|
||||
*
|
||||
* math.clone(x)
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* math.clone(3.5) // returns number 3.5
|
||||
* math.clone(math.complex('2-4i')) // returns Complex 2 - 4i
|
||||
* math.clone(math.unit(45, 'deg')) // returns Unit 45 deg
|
||||
* math.clone([[1, 2], [3, 4]]) // returns Array [[1, 2], [3, 4]]
|
||||
* math.clone("hello world") // returns string "hello world"
|
||||
*
|
||||
* @param {*} x Object to be cloned
|
||||
* @return {*} A clone of object x
|
||||
*/
|
||||
return typed(name, {
|
||||
any: _object.clone
|
||||
});
|
||||
});
|
||||
56
node_modules/mathjs/lib/cjs/function/utils/hasNumericValue.js
generated
vendored
Normal file
56
node_modules/mathjs/lib/cjs/function/utils/hasNumericValue.js
generated
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.createHasNumericValue = void 0;
|
||||
var _factory = require("../../utils/factory.js");
|
||||
const name = 'hasNumericValue';
|
||||
const dependencies = ['typed', 'isNumeric'];
|
||||
const createHasNumericValue = exports.createHasNumericValue = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
|
||||
let {
|
||||
typed,
|
||||
isNumeric
|
||||
} = _ref;
|
||||
/**
|
||||
* Test whether a value is an numeric value.
|
||||
*
|
||||
* In case of a string, true is returned if the string contains a numeric value.
|
||||
*
|
||||
* Syntax:
|
||||
*
|
||||
* math.hasNumericValue(x)
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* math.hasNumericValue(2) // returns true
|
||||
* math.hasNumericValue('2') // returns true
|
||||
* math.isNumeric('2') // returns false
|
||||
* math.hasNumericValue(0) // returns true
|
||||
* math.hasNumericValue(math.bignumber('500')) // returns true
|
||||
* math.hasNumericValue(math.bigint('42')) // returns true
|
||||
* math.hasNumericValue(42n) // returns true
|
||||
* math.hasNumericValue(math.fraction(4)) // returns true
|
||||
* math.hasNumericValue(math.complex('2-4i')) // returns false
|
||||
* math.hasNumericValue(false) // returns true
|
||||
* math.hasNumericValue([2.3, 'foo', false]) // returns [true, false, true]
|
||||
*
|
||||
* See also:
|
||||
*
|
||||
* isZero, isPositive, isNegative, isInteger, isNumeric
|
||||
*
|
||||
* @param {*} x Value to be tested
|
||||
* @return {boolean} Returns true when `x` is a `number`, `BigNumber`,
|
||||
* `Fraction`, `Boolean`, or a `String` containing number. Returns false for other types.
|
||||
* Throws an error in case of unknown types.
|
||||
*/
|
||||
return typed(name, {
|
||||
boolean: () => true,
|
||||
string: function (x) {
|
||||
return x.trim().length > 0 && !isNaN(Number(x));
|
||||
},
|
||||
any: function (x) {
|
||||
return isNumeric(x);
|
||||
}
|
||||
});
|
||||
});
|
||||
60
node_modules/mathjs/lib/cjs/function/utils/isInteger.js
generated
vendored
Normal file
60
node_modules/mathjs/lib/cjs/function/utils/isInteger.js
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.createIsInteger = void 0;
|
||||
var _collection = require("../../utils/collection.js");
|
||||
var _number = require("../../utils/number.js");
|
||||
var _factory = require("../../utils/factory.js");
|
||||
const name = 'isInteger';
|
||||
const dependencies = ['typed'];
|
||||
const createIsInteger = exports.createIsInteger = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
|
||||
let {
|
||||
typed
|
||||
} = _ref;
|
||||
/**
|
||||
* Test whether a value is an integer number.
|
||||
* The function supports `number`, `BigNumber`, and `Fraction`.
|
||||
*
|
||||
* The function is evaluated element-wise in case of Array or Matrix input.
|
||||
*
|
||||
* Syntax:
|
||||
*
|
||||
* math.isInteger(x)
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* math.isInteger(2) // returns true
|
||||
* math.isInteger(0) // returns true
|
||||
* math.isInteger(0.5) // returns false
|
||||
* math.isInteger(math.bignumber(500)) // returns true
|
||||
* math.isInteger(math.fraction(4)) // returns true
|
||||
* math.isInteger('3') // returns true
|
||||
* math.isInteger([3, 0.5, -2]) // returns [true, false, true]
|
||||
* math.isInteger(math.complex('2-4i')) // throws an error
|
||||
*
|
||||
* See also:
|
||||
*
|
||||
* isNumeric, isPositive, isNegative, isZero
|
||||
*
|
||||
* @param {number | BigNumber | bigint | Fraction | Array | Matrix} x Value to be tested
|
||||
* @return {boolean} Returns true when `x` contains a numeric, integer value.
|
||||
* Throws an error in case of an unknown data type.
|
||||
*/
|
||||
return typed(name, {
|
||||
number: _number.isInteger,
|
||||
// TODO: what to do with isInteger(add(0.1, 0.2)) ?
|
||||
|
||||
BigNumber: function (x) {
|
||||
return x.isInt();
|
||||
},
|
||||
bigint: function (x) {
|
||||
return true;
|
||||
},
|
||||
Fraction: function (x) {
|
||||
return x.d === 1 && isFinite(x.n);
|
||||
},
|
||||
'Array | Matrix': typed.referToSelf(self => x => (0, _collection.deepMap)(x, self))
|
||||
});
|
||||
});
|
||||
64
node_modules/mathjs/lib/cjs/function/utils/isNaN.js
generated
vendored
Normal file
64
node_modules/mathjs/lib/cjs/function/utils/isNaN.js
generated
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.createIsNaN = void 0;
|
||||
var _collection = require("../../utils/collection.js");
|
||||
var _factory = require("../../utils/factory.js");
|
||||
var _index = require("../../plain/number/index.js");
|
||||
const name = 'isNaN';
|
||||
const dependencies = ['typed'];
|
||||
const createIsNaN = exports.createIsNaN = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
|
||||
let {
|
||||
typed
|
||||
} = _ref;
|
||||
/**
|
||||
* Test whether a value is NaN (not a number).
|
||||
* The function supports types `number`, `BigNumber`, `Fraction`, `Unit` and `Complex`.
|
||||
*
|
||||
* The function is evaluated element-wise in case of Array or Matrix input.
|
||||
*
|
||||
* Syntax:
|
||||
*
|
||||
* math.isNaN(x)
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* math.isNaN(3) // returns false
|
||||
* math.isNaN(NaN) // returns true
|
||||
* math.isNaN(0) // returns false
|
||||
* math.isNaN(math.bignumber(NaN)) // returns true
|
||||
* math.isNaN(math.bignumber(0)) // returns false
|
||||
* math.isNaN(math.fraction(-2, 5)) // returns false
|
||||
* math.isNaN('-2') // returns false
|
||||
* math.isNaN([2, 0, -3, NaN]) // returns [false, false, false, true]
|
||||
*
|
||||
* See also:
|
||||
*
|
||||
* isNumeric, isNegative, isPositive, isZero, isInteger
|
||||
*
|
||||
* @param {number | BigNumber | bigint | Fraction | Unit | Array | Matrix} x Value to be tested
|
||||
* @return {boolean} Returns true when `x` is NaN.
|
||||
* Throws an error in case of an unknown data type.
|
||||
*/
|
||||
return typed(name, {
|
||||
number: _index.isNaNNumber,
|
||||
BigNumber: function (x) {
|
||||
return x.isNaN();
|
||||
},
|
||||
bigint: function (x) {
|
||||
return false;
|
||||
},
|
||||
Fraction: function (x) {
|
||||
return false;
|
||||
},
|
||||
Complex: function (x) {
|
||||
return x.isNaN();
|
||||
},
|
||||
Unit: function (x) {
|
||||
return Number.isNaN(x.value);
|
||||
},
|
||||
'Array | Matrix': typed.referToSelf(self => x => (0, _collection.deepMap)(x, self))
|
||||
});
|
||||
});
|
||||
58
node_modules/mathjs/lib/cjs/function/utils/isNegative.js
generated
vendored
Normal file
58
node_modules/mathjs/lib/cjs/function/utils/isNegative.js
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.createIsNegative = void 0;
|
||||
var _collection = require("../../utils/collection.js");
|
||||
var _factory = require("../../utils/factory.js");
|
||||
var _index = require("../../plain/number/index.js");
|
||||
var _nearlyEqual = require("../../utils/bignumber/nearlyEqual.js");
|
||||
var _number = require("../../utils/number.js");
|
||||
const name = 'isNegative';
|
||||
const dependencies = ['typed', 'config'];
|
||||
const createIsNegative = exports.createIsNegative = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
|
||||
let {
|
||||
typed,
|
||||
config
|
||||
} = _ref;
|
||||
/**
|
||||
* Test whether a value is negative: smaller than zero.
|
||||
* The function supports types `number`, `BigNumber`, `Fraction`, and `Unit`.
|
||||
*
|
||||
* The function is evaluated element-wise in case of Array or Matrix input.
|
||||
*
|
||||
* Syntax:
|
||||
*
|
||||
* math.isNegative(x)
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* math.isNegative(3) // returns false
|
||||
* math.isNegative(-2) // returns true
|
||||
* math.isNegative(0) // returns false
|
||||
* math.isNegative(-0) // returns false
|
||||
* math.isNegative(math.bignumber(2)) // returns false
|
||||
* math.isNegative(math.fraction(-2, 5)) // returns true
|
||||
* math.isNegative('-2') // returns true
|
||||
* math.isNegative([2, 0, -3]) // returns [false, false, true]
|
||||
*
|
||||
* See also:
|
||||
*
|
||||
* isNumeric, isPositive, isZero, isInteger
|
||||
*
|
||||
* @param {number | BigNumber | bigint | Fraction | Unit | Array | Matrix} x Value to be tested
|
||||
* @return {boolean} Returns true when `x` is larger than zero.
|
||||
* Throws an error in case of an unknown data type.
|
||||
*/
|
||||
return typed(name, {
|
||||
number: x => (0, _number.nearlyEqual)(x, 0, config.relTol, config.absTol) ? false : (0, _index.isNegativeNumber)(x),
|
||||
BigNumber: x => (0, _nearlyEqual.nearlyEqual)(x, new x.constructor(0), config.relTol, config.absTol) ? false : x.isNeg() && !x.isZero() && !x.isNaN(),
|
||||
bigint: x => x < 0n,
|
||||
Fraction: x => x.s < 0,
|
||||
// It's enough to decide on the sign
|
||||
|
||||
Unit: typed.referToSelf(self => x => typed.find(self, x.valueType())(x.value)),
|
||||
'Array | Matrix': typed.referToSelf(self => x => (0, _collection.deepMap)(x, self))
|
||||
});
|
||||
});
|
||||
50
node_modules/mathjs/lib/cjs/function/utils/isNumeric.js
generated
vendored
Normal file
50
node_modules/mathjs/lib/cjs/function/utils/isNumeric.js
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.createIsNumeric = void 0;
|
||||
var _collection = require("../../utils/collection.js");
|
||||
var _factory = require("../../utils/factory.js");
|
||||
const name = 'isNumeric';
|
||||
const dependencies = ['typed'];
|
||||
const createIsNumeric = exports.createIsNumeric = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
|
||||
let {
|
||||
typed
|
||||
} = _ref;
|
||||
/**
|
||||
* Test whether a value is an numeric value.
|
||||
*
|
||||
* The function is evaluated element-wise in case of Array or Matrix input.
|
||||
*
|
||||
* Syntax:
|
||||
*
|
||||
* math.isNumeric(x)
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* math.isNumeric(2) // returns true
|
||||
* math.isNumeric('2') // returns false
|
||||
* math.hasNumericValue('2') // returns true
|
||||
* math.isNumeric(0) // returns true
|
||||
* math.isNumeric(math.bignumber('42')) // returns true
|
||||
* math.isNumeric(math.bigint('42')) // returns true
|
||||
* math.isNumeric(math.fraction(4)) // returns true
|
||||
* math.isNumeric(math.complex('2-4i')) // returns false
|
||||
* math.isNumeric([2.3, 'foo', false]) // returns [true, false, true]
|
||||
*
|
||||
* See also:
|
||||
*
|
||||
* isZero, isPositive, isNegative, isInteger, hasNumericValue
|
||||
*
|
||||
* @param {*} x Value to be tested
|
||||
* @return {boolean} Returns true when `x` is a `number`, `BigNumber`,
|
||||
* `Fraction`, or `boolean`. Returns false for other types.
|
||||
* Throws an error in case of unknown types.
|
||||
*/
|
||||
return typed(name, {
|
||||
'number | BigNumber | bigint | Fraction | boolean': () => true,
|
||||
'Complex | Unit | string | null | undefined | Node': () => false,
|
||||
'Array | Matrix': typed.referToSelf(self => x => (0, _collection.deepMap)(x, self))
|
||||
});
|
||||
});
|
||||
58
node_modules/mathjs/lib/cjs/function/utils/isPositive.js
generated
vendored
Normal file
58
node_modules/mathjs/lib/cjs/function/utils/isPositive.js
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.createIsPositive = void 0;
|
||||
var _collection = require("../../utils/collection.js");
|
||||
var _factory = require("../../utils/factory.js");
|
||||
var _index = require("../../plain/number/index.js");
|
||||
var _nearlyEqual = require("../../utils/bignumber/nearlyEqual.js");
|
||||
var _number = require("../../utils/number.js");
|
||||
const name = 'isPositive';
|
||||
const dependencies = ['typed', 'config'];
|
||||
const createIsPositive = exports.createIsPositive = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
|
||||
let {
|
||||
typed,
|
||||
config
|
||||
} = _ref;
|
||||
/**
|
||||
* Test whether a value is positive: larger than zero.
|
||||
* The function supports types `number`, `BigNumber`, `Fraction`, and `Unit`.
|
||||
*
|
||||
* The function is evaluated element-wise in case of Array or Matrix input.
|
||||
*
|
||||
* Syntax:
|
||||
*
|
||||
* math.isPositive(x)
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* math.isPositive(3) // returns true
|
||||
* math.isPositive(-2) // returns false
|
||||
* math.isPositive(0) // returns false
|
||||
* math.isPositive(-0) // returns false
|
||||
* math.isPositive(0.5) // returns true
|
||||
* math.isPositive(math.bignumber(2)) // returns true
|
||||
* math.isPositive(math.fraction(-2, 5)) // returns false
|
||||
* math.isPositive(math.fraction(1, 3)) // returns true
|
||||
* math.isPositive('2') // returns true
|
||||
* math.isPositive([2, 0, -3]) // returns [true, false, false]
|
||||
*
|
||||
* See also:
|
||||
*
|
||||
* isNumeric, isZero, isNegative, isInteger
|
||||
*
|
||||
* @param {number | BigNumber | bigint | Fraction | Unit | Array | Matrix} x Value to be tested
|
||||
* @return {boolean} Returns true when `x` is larger than zero.
|
||||
* Throws an error in case of an unknown data type.
|
||||
*/
|
||||
return typed(name, {
|
||||
number: x => (0, _number.nearlyEqual)(x, 0, config.relTol, config.absTol) ? false : (0, _index.isPositiveNumber)(x),
|
||||
BigNumber: x => (0, _nearlyEqual.nearlyEqual)(x, new x.constructor(0), config.relTol, config.absTol) ? false : !x.isNeg() && !x.isZero() && !x.isNaN(),
|
||||
bigint: x => x > 0n,
|
||||
Fraction: x => x.s > 0 && x.n > 0,
|
||||
Unit: typed.referToSelf(self => x => typed.find(self, x.valueType())(x.value)),
|
||||
'Array | Matrix': typed.referToSelf(self => x => (0, _collection.deepMap)(x, self))
|
||||
});
|
||||
});
|
||||
136
node_modules/mathjs/lib/cjs/function/utils/isPrime.js
generated
vendored
Normal file
136
node_modules/mathjs/lib/cjs/function/utils/isPrime.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
55
node_modules/mathjs/lib/cjs/function/utils/isZero.js
generated
vendored
Normal file
55
node_modules/mathjs/lib/cjs/function/utils/isZero.js
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.createIsZero = void 0;
|
||||
var _collection = require("../../utils/collection.js");
|
||||
var _factory = require("../../utils/factory.js");
|
||||
const name = 'isZero';
|
||||
const dependencies = ['typed', 'equalScalar'];
|
||||
const createIsZero = exports.createIsZero = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
|
||||
let {
|
||||
typed,
|
||||
equalScalar
|
||||
} = _ref;
|
||||
/**
|
||||
* Test whether a value is zero.
|
||||
* The function can check for zero for types `number`, `BigNumber`, `Fraction`,
|
||||
* `Complex`, and `Unit`.
|
||||
*
|
||||
* The function is evaluated element-wise in case of Array or Matrix input.
|
||||
*
|
||||
* Syntax:
|
||||
*
|
||||
* math.isZero(x)
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* math.isZero(0) // returns true
|
||||
* math.isZero(2) // returns false
|
||||
* math.isZero(0.5) // returns false
|
||||
* math.isZero(math.bignumber(0)) // returns true
|
||||
* math.isZero(math.fraction(0)) // returns true
|
||||
* math.isZero(math.fraction(1,3)) // returns false
|
||||
* math.isZero(math.complex('2 - 4i')) // returns false
|
||||
* math.isZero(math.complex('0i')) // returns true
|
||||
* math.isZero('0') // returns true
|
||||
* math.isZero('2') // returns false
|
||||
* math.isZero([2, 0, -3]) // returns [false, true, false]
|
||||
*
|
||||
* See also:
|
||||
*
|
||||
* isNumeric, isPositive, isNegative, isInteger
|
||||
*
|
||||
* @param {number | BigNumber | bigint | Complex | Fraction | Unit | Array | Matrix} x Value to be tested
|
||||
* @return {boolean} Returns true when `x` is zero.
|
||||
* Throws an error in case of an unknown data type.
|
||||
*/
|
||||
return typed(name, {
|
||||
'number | BigNumber | Complex | Fraction': x => equalScalar(x, 0),
|
||||
bigint: x => x === 0n,
|
||||
Unit: typed.referToSelf(self => x => typed.find(self, x.valueType())(x.value)),
|
||||
'Array | Matrix': typed.referToSelf(self => x => (0, _collection.deepMap)(x, self))
|
||||
});
|
||||
});
|
||||
81
node_modules/mathjs/lib/cjs/function/utils/numeric.js
generated
vendored
Normal file
81
node_modules/mathjs/lib/cjs/function/utils/numeric.js
generated
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.createNumeric = void 0;
|
||||
var _is = require("../../utils/is.js");
|
||||
var _factory = require("../../utils/factory.js");
|
||||
var _noop = require("../../utils/noop.js");
|
||||
const name = 'numeric';
|
||||
const dependencies = ['number', '?bignumber', '?fraction'];
|
||||
const createNumeric = exports.createNumeric = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
|
||||
let {
|
||||
number,
|
||||
bignumber,
|
||||
fraction
|
||||
} = _ref;
|
||||
const validInputTypes = {
|
||||
string: true,
|
||||
number: true,
|
||||
BigNumber: true,
|
||||
Fraction: true
|
||||
};
|
||||
|
||||
// Load the conversion functions for each output type
|
||||
const validOutputTypes = {
|
||||
number: x => number(x),
|
||||
BigNumber: bignumber ? x => bignumber(x) : _noop.noBignumber,
|
||||
bigint: x => BigInt(x),
|
||||
Fraction: fraction ? x => fraction(x) : _noop.noFraction
|
||||
};
|
||||
|
||||
/**
|
||||
* Convert a numeric input to a specific numeric type: number, BigNumber, bigint, or Fraction.
|
||||
*
|
||||
* Syntax:
|
||||
*
|
||||
* math.numeric(x)
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* math.numeric('4') // returns 4
|
||||
* math.numeric('4', 'number') // returns 4
|
||||
* math.numeric('4', 'bigint') // returns 4n
|
||||
* math.numeric('4', 'BigNumber') // returns BigNumber 4
|
||||
* math.numeric('4', 'Fraction') // returns Fraction 4
|
||||
* math.numeric(4, 'Fraction') // returns Fraction 4
|
||||
* math.numeric(math.fraction(2, 5), 'number') // returns 0.4
|
||||
*
|
||||
* See also:
|
||||
*
|
||||
* number, fraction, bignumber, bigint, string, format
|
||||
*
|
||||
* @param {string | number | BigNumber | bigint | Fraction } value
|
||||
* A numeric value or a string containing a numeric value
|
||||
* @param {string} outputType
|
||||
* Desired numeric output type.
|
||||
* Available values: 'number', 'BigNumber', or 'Fraction'
|
||||
* @return {number | BigNumber | bigint | Fraction}
|
||||
* Returns an instance of the numeric in the requested type
|
||||
*/
|
||||
return function numeric(value) {
|
||||
let outputType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'number';
|
||||
let check = arguments.length > 2 ? arguments[2] : undefined;
|
||||
if (check !== undefined) {
|
||||
throw new SyntaxError('numeric() takes one or two arguments');
|
||||
}
|
||||
const inputType = (0, _is.typeOf)(value);
|
||||
if (!(inputType in validInputTypes)) {
|
||||
throw new TypeError('Cannot convert ' + value + ' of type "' + inputType + '"; valid input types are ' + Object.keys(validInputTypes).join(', '));
|
||||
}
|
||||
if (!(outputType in validOutputTypes)) {
|
||||
throw new TypeError('Cannot convert ' + value + ' to type "' + outputType + '"; valid output types are ' + Object.keys(validOutputTypes).join(', '));
|
||||
}
|
||||
if (outputType === inputType) {
|
||||
return value;
|
||||
} else {
|
||||
return validOutputTypes[outputType](value);
|
||||
}
|
||||
};
|
||||
});
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user