--- node_modules/jsdom/lib/jsdom.js 2025-10-18 19:25:36.486580000 +0300 +++ jsdom-qjs/jsdom.js 2025-10-18 22:23:22.637363300 +0300 @@ -31876,7 +31876,7 @@ } else if (global.setImmediate) { nextTick = global.setImmediate; } else { - nextTick = global.setTimeout; + nextTick = global.setTimeout } return nextTick; } @@ -42052,7 +42052,7 @@ self.emit('error', reason) }) } else { - var xhr = self._xhr = new global.XMLHttpRequest() + var xhr = self._xhr = new XMLHttpRequest() try { xhr.open(self._opts.method, self._opts.url, true) } catch (err) { @@ -44670,66 +44670,58 @@ 'decodeURI', 'decodeURIComponent', 'encodeURI', 'encodeURIComponent', 'escape', 'eval', 'isFinite', 'isNaN', 'parseFloat', 'parseInt', 'undefined', 'unescape']; -function Context() {} -Context.prototype = {}; + + function Context() { } + Context.prototype = {}; + function sandbox(fn) { + + var keys = {}; + + for (var k in globalThis) { + keys[k] = globalThis[k] + } + + var result = fn(); + + for (var k in globalThis) { + if(keys[k]!=globalThis[k]){ + globalThis[k]=keys[k] + } + } -var Script = exports.Script = function NodeScript (code) { + return result; + } + var Script = exports.Script = function NodeScript(code) { if (!(this instanceof Script)) return new Script(code); this.code = code; -}; - -Script.prototype.runInContext = function (context) { - if (!(context instanceof Context)) { - throw new TypeError("needs a 'context' argument."); - } - - var iframe = document.createElement('iframe'); - if (!iframe.style) iframe.style = {}; - iframe.style.display = 'none'; - - document.body.appendChild(iframe); - - var win = iframe.contentWindow; - var wEval = win.eval, wExecScript = win.execScript; - - if (!wEval && wExecScript) { - // win.eval() magically appears when this is called in IE: - wExecScript.call(win, 'null'); - wEval = win.eval; - } - - forEach(Object_keys(context), function (key) { - win[key] = context[key]; - }); - forEach(globals, function (key) { - if (context[key]) { - win[key] = context[key]; - } - }); - - var winKeys = Object_keys(win); + }; - var res = wEval.call(win, this.code); - - forEach(Object_keys(win), function (key) { - // Avoid copying circular objects like `top` and `window` by only - // updating existing context properties or new properties in the `win` - // that was only introduced after the eval. - if (key in context || indexOf(winKeys, key) === -1) { - context[key] = win[key]; - } + Script.prototype.runInContext = function (context) { + let code = 'with(context){\n' + const keys = Object.keys(context); + for (const key of keys) { + code += `globalThis[${JSON.stringify(key)}] = context[${JSON.stringify(key)}];\n`; + } + let src = this.code; + if (/["']use strict["'];?/.test(src)) { + src = src.replace(/(["'])use strict\1/g,"$1use loose$1") + } + + if (typeof src !== 'string') { + src = `(${src.toString()})()`; + } + code += src +';\n'; + // for (const key of keys) { + // code += `context[${JSON.stringify(key)}] = globalThis[${JSON.stringify(key)}];\n`; + // } + code += "}" + return sandbox(() => { + //eval.bind(context).call(code) + Function('context', code).call(null, context); + return context; }); + }; - forEach(globals, function (key) { - if (!(key in context)) { - defineProp(context, key, win[key]); - } - }); - - document.body.removeChild(iframe); - - return res; -}; Script.prototype.runInThisContext = function () { return eval(this.code); // maybe... @@ -59783,12 +59775,12 @@ (function (globalScope) { 'use strict'; - /*! - * decimal.js v10.5.0 - * An arbitrary-precision Decimal type for JavaScript. - * https://github.com/MikeMcl/decimal.js - * Copyright (c) 2025 Michael Mclaughlin - * MIT Licence + /*! + * decimal.js v10.5.0 + * An arbitrary-precision Decimal type for JavaScript. + * https://github.com/MikeMcl/decimal.js + * Copyright (c) 2025 Michael Mclaughlin + * MIT Licence */ // ----------------------------------- EDITABLE DEFAULTS ------------------------------------ // @@ -59906,72 +59898,72 @@ // Decimal prototype methods - /* - * absoluteValue abs - * ceil - * clampedTo clamp - * comparedTo cmp - * cosine cos - * cubeRoot cbrt - * decimalPlaces dp - * dividedBy div - * dividedToIntegerBy divToInt - * equals eq - * floor - * greaterThan gt - * greaterThanOrEqualTo gte - * hyperbolicCosine cosh - * hyperbolicSine sinh - * hyperbolicTangent tanh - * inverseCosine acos - * inverseHyperbolicCosine acosh - * inverseHyperbolicSine asinh - * inverseHyperbolicTangent atanh - * inverseSine asin - * inverseTangent atan - * isFinite - * isInteger isInt - * isNaN - * isNegative isNeg - * isPositive isPos - * isZero - * lessThan lt - * lessThanOrEqualTo lte - * logarithm log - * [maximum] [max] - * [minimum] [min] - * minus sub - * modulo mod - * naturalExponential exp - * naturalLogarithm ln - * negated neg - * plus add - * precision sd - * round - * sine sin - * squareRoot sqrt - * tangent tan - * times mul - * toBinary - * toDecimalPlaces toDP - * toExponential - * toFixed - * toFraction - * toHexadecimal toHex - * toNearest - * toNumber - * toOctal - * toPower pow - * toPrecision - * toSignificantDigits toSD - * toString - * truncated trunc - * valueOf toJSON - */ - - /* - * Return a new Decimal whose value is the absolute value of this Decimal. - * + /* + * absoluteValue abs + * ceil + * clampedTo clamp + * comparedTo cmp + * cosine cos + * cubeRoot cbrt + * decimalPlaces dp + * dividedBy div + * dividedToIntegerBy divToInt + * equals eq + * floor + * greaterThan gt + * greaterThanOrEqualTo gte + * hyperbolicCosine cosh + * hyperbolicSine sinh + * hyperbolicTangent tanh + * inverseCosine acos + * inverseHyperbolicCosine acosh + * inverseHyperbolicSine asinh + * inverseHyperbolicTangent atanh + * inverseSine asin + * inverseTangent atan + * isFinite + * isInteger isInt + * isNaN + * isNegative isNeg + * isPositive isPos + * isZero + * lessThan lt + * lessThanOrEqualTo lte + * logarithm log + * [maximum] [max] + * [minimum] [min] + * minus sub + * modulo mod + * naturalExponential exp + * naturalLogarithm ln + * negated neg + * plus add + * precision sd + * round + * sine sin + * squareRoot sqrt + * tangent tan + * times mul + * toBinary + * toDecimalPlaces toDP + * toExponential + * toFixed + * toFraction + * toHexadecimal toHex + * toNearest + * toNumber + * toOctal + * toPower pow + * toPrecision + * toSignificantDigits toSD + * toString + * truncated trunc + * valueOf toJSON + */ + + /* + * Return a new Decimal whose value is the absolute value of this Decimal. + * */ P.absoluteValue = P.abs = function () { var x = new this.constructor(this); @@ -59979,22 +59971,22 @@ return finalise(x); }; - /* - * Return a new Decimal whose value is the value of this Decimal rounded to a whole number in the - * direction of positive Infinity. - * + /* + * Return a new Decimal whose value is the value of this Decimal rounded to a whole number in the + * direction of positive Infinity. + * */ P.ceil = function () { return finalise(new this.constructor(this), this.e + 1, 2); }; - /* - * Return a new Decimal whose value is the value of this Decimal clamped to the range - * delineated by `min` and `max`. - * - * min {number|string|bigint|Decimal} - * max {number|string|bigint|Decimal} - * + /* + * Return a new Decimal whose value is the value of this Decimal clamped to the range + * delineated by `min` and `max`. + * + * min {number|string|bigint|Decimal} + * max {number|string|bigint|Decimal} + * */ P.clampedTo = P.clamp = function (min, max) { var k, @@ -60008,13 +60000,13 @@ return k < 0 ? min : x.cmp(max) > 0 ? max : new Ctor(x); }; - /* - * Return - * 1 if the value of this Decimal is greater than the value of `y`, - * -1 if the value of this Decimal is less than the value of `y`, - * 0 if they have the same value, - * NaN if the value of either Decimal is NaN. - * + /* + * Return + * 1 if the value of this Decimal is greater than the value of `y`, + * -1 if the value of this Decimal is less than the value of `y`, + * 0 if they have the same value, + * NaN if the value of either Decimal is NaN. + * */ P.comparedTo = P.cmp = function (y) { var i, @@ -60052,18 +60044,18 @@ return xdL === ydL ? 0 : xdL > ydL ^ xs < 0 ? 1 : -1; }; - /* - * Return a new Decimal whose value is the cosine of the value in radians of this Decimal. - * - * Domain: [-Infinity, Infinity] - * Range: [-1, 1] - * - * cos(0) = 1 - * cos(-0) = 1 - * cos(Infinity) = NaN - * cos(-Infinity) = NaN - * cos(NaN) = NaN - * + /* + * Return a new Decimal whose value is the cosine of the value in radians of this Decimal. + * + * Domain: [-Infinity, Infinity] + * Range: [-1, 1] + * + * cos(0) = 1 + * cos(-0) = 1 + * cos(Infinity) = NaN + * cos(-Infinity) = NaN + * cos(NaN) = NaN + * */ P.cosine = P.cos = function () { var pr, @@ -60084,21 +60076,21 @@ return finalise(quadrant == 2 || quadrant == 3 ? x.neg() : x, pr, rm, true); }; - /* - * - * Return a new Decimal whose value is the cube root of the value of this Decimal, rounded to - * `precision` significant digits using rounding mode `rounding`. - * - * cbrt(0) = 0 - * cbrt(-0) = -0 - * cbrt(1) = 1 - * cbrt(-1) = -1 - * cbrt(N) = N - * cbrt(-I) = -I - * cbrt(I) = I - * - * Math.cbrt(x) = (x < 0 ? -Math.pow(-x, 1/3) : Math.pow(x, 1/3)) - * + /* + * + * Return a new Decimal whose value is the cube root of the value of this Decimal, rounded to + * `precision` significant digits using rounding mode `rounding`. + * + * cbrt(0) = 0 + * cbrt(-0) = -0 + * cbrt(1) = 1 + * cbrt(-1) = -1 + * cbrt(N) = N + * cbrt(-I) = -I + * cbrt(I) = I + * + * Math.cbrt(x) = (x < 0 ? -Math.pow(-x, 1/3) : Math.pow(x, 1/3)) + * */ P.cubeRoot = P.cbrt = function () { var e, @@ -60186,9 +60178,9 @@ return finalise(r, e, Ctor.rounding, m); }; - /* - * Return the number of decimal places of the value of this Decimal. - * + /* + * Return the number of decimal places of the value of this Decimal. + * */ P.decimalPlaces = P.dp = function () { var w, @@ -60206,35 +60198,35 @@ return n; }; - /* - * n / 0 = I - * n / N = N - * n / I = 0 - * 0 / n = 0 - * 0 / 0 = N - * 0 / N = N - * 0 / I = 0 - * N / n = N - * N / 0 = N - * N / N = N - * N / I = N - * I / n = I - * I / 0 = I - * I / N = N - * I / I = N - * - * Return a new Decimal whose value is the value of this Decimal divided by `y`, rounded to - * `precision` significant digits using rounding mode `rounding`. - * + /* + * n / 0 = I + * n / N = N + * n / I = 0 + * 0 / n = 0 + * 0 / 0 = N + * 0 / N = N + * 0 / I = 0 + * N / n = N + * N / 0 = N + * N / N = N + * N / I = N + * I / n = I + * I / 0 = I + * I / N = N + * I / I = N + * + * Return a new Decimal whose value is the value of this Decimal divided by `y`, rounded to + * `precision` significant digits using rounding mode `rounding`. + * */ P.dividedBy = P.div = function (y) { return divide(this, new this.constructor(y)); }; - /* - * Return a new Decimal whose value is the integer part of dividing the value of this Decimal - * by the value of `y`, rounded to `precision` significant digits using rounding mode `rounding`. - * + /* + * Return a new Decimal whose value is the integer part of dividing the value of this Decimal + * by the value of `y`, rounded to `precision` significant digits using rounding mode `rounding`. + * */ P.dividedToIntegerBy = P.divToInt = function (y) { var x = this, @@ -60242,66 +60234,66 @@ return finalise(divide(x, new Ctor(y), 0, 1, 1), Ctor.precision, Ctor.rounding); }; - /* - * Return true if the value of this Decimal is equal to the value of `y`, otherwise return false. - * + /* + * Return true if the value of this Decimal is equal to the value of `y`, otherwise return false. + * */ P.equals = P.eq = function (y) { return this.cmp(y) === 0; }; - /* - * Return a new Decimal whose value is the value of this Decimal rounded to a whole number in the - * direction of negative Infinity. - * + /* + * Return a new Decimal whose value is the value of this Decimal rounded to a whole number in the + * direction of negative Infinity. + * */ P.floor = function () { return finalise(new this.constructor(this), this.e + 1, 3); }; - /* - * Return true if the value of this Decimal is greater than the value of `y`, otherwise return - * false. - * + /* + * Return true if the value of this Decimal is greater than the value of `y`, otherwise return + * false. + * */ P.greaterThan = P.gt = function (y) { return this.cmp(y) > 0; }; - /* - * Return true if the value of this Decimal is greater than or equal to the value of `y`, - * otherwise return false. - * + /* + * Return true if the value of this Decimal is greater than or equal to the value of `y`, + * otherwise return false. + * */ P.greaterThanOrEqualTo = P.gte = function (y) { var k = this.cmp(y); return k == 1 || k === 0; }; - /* - * Return a new Decimal whose value is the hyperbolic cosine of the value in radians of this - * Decimal. - * - * Domain: [-Infinity, Infinity] - * Range: [1, Infinity] - * - * cosh(x) = 1 + x^2/2! + x^4/4! + x^6/6! + ... - * - * cosh(0) = 1 - * cosh(-0) = 1 - * cosh(Infinity) = Infinity - * cosh(-Infinity) = Infinity - * cosh(NaN) = NaN - * - * x time taken (ms) result - * 1000 9 9.8503555700852349694e+433 - * 10000 25 4.4034091128314607936e+4342 - * 100000 171 1.4033316802130615897e+43429 - * 1000000 3817 1.5166076984010437725e+434294 - * 10000000 abandoned after 2 minute wait - * - * TODO? Compare performance of cosh(x) = 0.5 * (exp(x) + exp(-x)) - * + /* + * Return a new Decimal whose value is the hyperbolic cosine of the value in radians of this + * Decimal. + * + * Domain: [-Infinity, Infinity] + * Range: [1, Infinity] + * + * cosh(x) = 1 + x^2/2! + x^4/4! + x^6/6! + ... + * + * cosh(0) = 1 + * cosh(-0) = 1 + * cosh(Infinity) = Infinity + * cosh(-Infinity) = Infinity + * cosh(NaN) = NaN + * + * x time taken (ms) result + * 1000 9 9.8503555700852349694e+433 + * 10000 25 4.4034091128314607936e+4342 + * 100000 171 1.4033316802130615897e+43429 + * 1000000 3817 1.5166076984010437725e+434294 + * 10000000 abandoned after 2 minute wait + * + * TODO? Compare performance of cosh(x) = 0.5 * (exp(x) + exp(-x)) + * */ P.hyperbolicCosine = P.cosh = function () { var k, @@ -60345,35 +60337,35 @@ return finalise(x, Ctor.precision = pr, Ctor.rounding = rm, true); }; - /* - * Return a new Decimal whose value is the hyperbolic sine of the value in radians of this - * Decimal. - * - * Domain: [-Infinity, Infinity] - * Range: [-Infinity, Infinity] - * - * sinh(x) = x + x^3/3! + x^5/5! + x^7/7! + ... - * - * sinh(0) = 0 - * sinh(-0) = -0 - * sinh(Infinity) = Infinity - * sinh(-Infinity) = -Infinity - * sinh(NaN) = NaN - * - * x time taken (ms) - * 10 2 ms - * 100 5 ms - * 1000 14 ms - * 10000 82 ms - * 100000 886 ms 1.4033316802130615897e+43429 - * 200000 2613 ms - * 300000 5407 ms - * 400000 8824 ms - * 500000 13026 ms 8.7080643612718084129e+217146 - * 1000000 48543 ms - * - * TODO? Compare performance of sinh(x) = 0.5 * (exp(x) - exp(-x)) - * + /* + * Return a new Decimal whose value is the hyperbolic sine of the value in radians of this + * Decimal. + * + * Domain: [-Infinity, Infinity] + * Range: [-Infinity, Infinity] + * + * sinh(x) = x + x^3/3! + x^5/5! + x^7/7! + ... + * + * sinh(0) = 0 + * sinh(-0) = -0 + * sinh(Infinity) = Infinity + * sinh(-Infinity) = -Infinity + * sinh(NaN) = NaN + * + * x time taken (ms) + * 10 2 ms + * 100 5 ms + * 1000 14 ms + * 10000 82 ms + * 100000 886 ms 1.4033316802130615897e+43429 + * 200000 2613 ms + * 300000 5407 ms + * 400000 8824 ms + * 500000 13026 ms 8.7080643612718084129e+217146 + * 1000000 48543 ms + * + * TODO? Compare performance of sinh(x) = 0.5 * (exp(x) - exp(-x)) + * */ P.hyperbolicSine = P.sinh = function () { var k, @@ -60420,21 +60412,21 @@ return finalise(x, pr, rm, true); }; - /* - * Return a new Decimal whose value is the hyperbolic tangent of the value in radians of this - * Decimal. - * - * Domain: [-Infinity, Infinity] - * Range: [-1, 1] - * - * tanh(x) = sinh(x) / cosh(x) - * - * tanh(0) = 0 - * tanh(-0) = -0 - * tanh(Infinity) = 1 - * tanh(-Infinity) = -1 - * tanh(NaN) = NaN - * + /* + * Return a new Decimal whose value is the hyperbolic tangent of the value in radians of this + * Decimal. + * + * Domain: [-Infinity, Infinity] + * Range: [-1, 1] + * + * tanh(x) = sinh(x) / cosh(x) + * + * tanh(0) = 0 + * tanh(-0) = -0 + * tanh(Infinity) = 1 + * tanh(-Infinity) = -1 + * tanh(NaN) = NaN + * */ P.hyperbolicTangent = P.tanh = function () { var pr, @@ -60450,24 +60442,24 @@ return divide(x.sinh(), x.cosh(), Ctor.precision = pr, Ctor.rounding = rm); }; - /* - * Return a new Decimal whose value is the arccosine (inverse cosine) in radians of the value of - * this Decimal. - * - * Domain: [-1, 1] - * Range: [0, pi] - * - * acos(x) = pi/2 - asin(x) - * - * acos(0) = pi/2 - * acos(-0) = pi/2 - * acos(1) = 0 - * acos(-1) = pi - * acos(1/2) = pi/3 - * acos(-1/2) = 2*pi/3 - * acos(|x| > 1) = NaN - * acos(NaN) = NaN - * + /* + * Return a new Decimal whose value is the arccosine (inverse cosine) in radians of the value of + * this Decimal. + * + * Domain: [-1, 1] + * Range: [0, pi] + * + * acos(x) = pi/2 - asin(x) + * + * acos(0) = pi/2 + * acos(-0) = pi/2 + * acos(1) = 0 + * acos(-1) = pi + * acos(1/2) = pi/3 + * acos(-1/2) = 2*pi/3 + * acos(|x| > 1) = NaN + * acos(NaN) = NaN + * */ P.inverseCosine = P.acos = function () { var x = this, @@ -60496,24 +60488,24 @@ return x.times(2); }; - /* - * Return a new Decimal whose value is the inverse of the hyperbolic cosine in radians of the - * value of this Decimal. - * - * Domain: [1, Infinity] - * Range: [0, Infinity] - * - * acosh(x) = ln(x + sqrt(x^2 - 1)) - * - * acosh(x < 1) = NaN - * acosh(NaN) = NaN - * acosh(Infinity) = Infinity - * acosh(-Infinity) = NaN - * acosh(0) = NaN - * acosh(-0) = NaN - * acosh(1) = 0 - * acosh(-1) = NaN - * + /* + * Return a new Decimal whose value is the inverse of the hyperbolic cosine in radians of the + * value of this Decimal. + * + * Domain: [1, Infinity] + * Range: [0, Infinity] + * + * acosh(x) = ln(x + sqrt(x^2 - 1)) + * + * acosh(x < 1) = NaN + * acosh(NaN) = NaN + * acosh(Infinity) = Infinity + * acosh(-Infinity) = NaN + * acosh(0) = NaN + * acosh(-0) = NaN + * acosh(1) = 0 + * acosh(-1) = NaN + * */ P.inverseHyperbolicCosine = P.acosh = function () { var pr, @@ -60534,21 +60526,21 @@ return x.ln(); }; - /* - * Return a new Decimal whose value is the inverse of the hyperbolic sine in radians of the value - * of this Decimal. - * - * Domain: [-Infinity, Infinity] - * Range: [-Infinity, Infinity] - * - * asinh(x) = ln(x + sqrt(x^2 + 1)) - * - * asinh(NaN) = NaN - * asinh(Infinity) = Infinity - * asinh(-Infinity) = -Infinity - * asinh(0) = 0 - * asinh(-0) = -0 - * + /* + * Return a new Decimal whose value is the inverse of the hyperbolic sine in radians of the value + * of this Decimal. + * + * Domain: [-Infinity, Infinity] + * Range: [-Infinity, Infinity] + * + * asinh(x) = ln(x + sqrt(x^2 + 1)) + * + * asinh(NaN) = NaN + * asinh(Infinity) = Infinity + * asinh(-Infinity) = -Infinity + * asinh(0) = 0 + * asinh(-0) = -0 + * */ P.inverseHyperbolicSine = P.asinh = function () { var pr, @@ -60568,24 +60560,24 @@ return x.ln(); }; - /* - * Return a new Decimal whose value is the inverse of the hyperbolic tangent in radians of the - * value of this Decimal. - * - * Domain: [-1, 1] - * Range: [-Infinity, Infinity] - * - * atanh(x) = 0.5 * ln((1 + x) / (1 - x)) - * - * atanh(|x| > 1) = NaN - * atanh(NaN) = NaN - * atanh(Infinity) = NaN - * atanh(-Infinity) = NaN - * atanh(0) = 0 - * atanh(-0) = -0 - * atanh(1) = Infinity - * atanh(-1) = -Infinity - * + /* + * Return a new Decimal whose value is the inverse of the hyperbolic tangent in radians of the + * value of this Decimal. + * + * Domain: [-1, 1] + * Range: [-Infinity, Infinity] + * + * atanh(x) = 0.5 * ln((1 + x) / (1 - x)) + * + * atanh(|x| > 1) = NaN + * atanh(NaN) = NaN + * atanh(Infinity) = NaN + * atanh(-Infinity) = NaN + * atanh(0) = 0 + * atanh(-0) = -0 + * atanh(1) = Infinity + * atanh(-1) = -Infinity + * */ P.inverseHyperbolicTangent = P.atanh = function () { var pr, @@ -60610,26 +60602,26 @@ return x.times(0.5); }; - /* - * Return a new Decimal whose value is the arcsine (inverse sine) in radians of the value of this - * Decimal. - * - * Domain: [-Infinity, Infinity] - * Range: [-pi/2, pi/2] - * - * asin(x) = 2*atan(x/(1 + sqrt(1 - x^2))) - * - * asin(0) = 0 - * asin(-0) = -0 - * asin(1/2) = pi/6 - * asin(-1/2) = -pi/6 - * asin(1) = pi/2 - * asin(-1) = -pi/2 - * asin(|x| > 1) = NaN - * asin(NaN) = NaN - * - * TODO? Compare performance of Taylor series. - * + /* + * Return a new Decimal whose value is the arcsine (inverse sine) in radians of the value of this + * Decimal. + * + * Domain: [-Infinity, Infinity] + * Range: [-pi/2, pi/2] + * + * asin(x) = 2*atan(x/(1 + sqrt(1 - x^2))) + * + * asin(0) = 0 + * asin(-0) = -0 + * asin(1/2) = pi/6 + * asin(-1/2) = -pi/6 + * asin(1) = pi/2 + * asin(-1) = -pi/2 + * asin(|x| > 1) = NaN + * asin(NaN) = NaN + * + * TODO? Compare performance of Taylor series. + * */ P.inverseSine = P.asin = function () { var halfPi, @@ -60664,23 +60656,23 @@ return x.times(2); }; - /* - * Return a new Decimal whose value is the arctangent (inverse tangent) in radians of the value - * of this Decimal. - * - * Domain: [-Infinity, Infinity] - * Range: [-pi/2, pi/2] - * - * atan(x) = x - x^3/3 + x^5/5 - x^7/7 + ... - * - * atan(0) = 0 - * atan(-0) = -0 - * atan(1) = pi/4 - * atan(-1) = -pi/4 - * atan(Infinity) = pi/2 - * atan(-Infinity) = -pi/2 - * atan(NaN) = NaN - * + /* + * Return a new Decimal whose value is the arctangent (inverse tangent) in radians of the value + * of this Decimal. + * + * Domain: [-Infinity, Infinity] + * Range: [-pi/2, pi/2] + * + * atan(x) = x - x^3/3 + x^5/5 - x^7/7 + ... + * + * atan(0) = 0 + * atan(-0) = -0 + * atan(1) = pi/4 + * atan(-1) = -pi/4 + * atan(Infinity) = pi/2 + * atan(-Infinity) = -pi/2 + * atan(NaN) = NaN + * */ P.inverseTangent = P.atan = function () { var i, @@ -60741,99 +60733,99 @@ return finalise(r, Ctor.precision = pr, Ctor.rounding = rm, true); }; - /* - * Return true if the value of this Decimal is a finite number, otherwise return false. - * + /* + * Return true if the value of this Decimal is a finite number, otherwise return false. + * */ P.isFinite = function () { return !!this.d; }; - /* - * Return true if the value of this Decimal is an integer, otherwise return false. - * + /* + * Return true if the value of this Decimal is an integer, otherwise return false. + * */ P.isInteger = P.isInt = function () { return !!this.d && mathfloor(this.e / LOG_BASE) > this.d.length - 2; }; - /* - * Return true if the value of this Decimal is NaN, otherwise return false. - * + /* + * Return true if the value of this Decimal is NaN, otherwise return false. + * */ P.isNaN = function () { return !this.s; }; - /* - * Return true if the value of this Decimal is negative, otherwise return false. - * + /* + * Return true if the value of this Decimal is negative, otherwise return false. + * */ P.isNegative = P.isNeg = function () { return this.s < 0; }; - /* - * Return true if the value of this Decimal is positive, otherwise return false. - * + /* + * Return true if the value of this Decimal is positive, otherwise return false. + * */ P.isPositive = P.isPos = function () { return this.s > 0; }; - /* - * Return true if the value of this Decimal is 0 or -0, otherwise return false. - * + /* + * Return true if the value of this Decimal is 0 or -0, otherwise return false. + * */ P.isZero = function () { return !!this.d && this.d[0] === 0; }; - /* - * Return true if the value of this Decimal is less than `y`, otherwise return false. - * + /* + * Return true if the value of this Decimal is less than `y`, otherwise return false. + * */ P.lessThan = P.lt = function (y) { return this.cmp(y) < 0; }; - /* - * Return true if the value of this Decimal is less than or equal to `y`, otherwise return false. - * + /* + * Return true if the value of this Decimal is less than or equal to `y`, otherwise return false. + * */ P.lessThanOrEqualTo = P.lte = function (y) { return this.cmp(y) < 1; }; - /* - * Return the logarithm of the value of this Decimal to the specified base, rounded to `precision` - * significant digits using rounding mode `rounding`. - * - * If no base is specified, return log[10](arg). - * - * log[base](arg) = ln(arg) / ln(base) - * - * The result will always be correctly rounded if the base of the log is 10, and 'almost always' - * otherwise: - * - * Depending on the rounding mode, the result may be incorrectly rounded if the first fifteen - * rounding digits are [49]99999999999999 or [50]00000000000000. In that case, the maximum error - * between the result and the correctly rounded result will be one ulp (unit in the last place). - * - * log[-b](a) = NaN - * log[0](a) = NaN - * log[1](a) = NaN - * log[NaN](a) = NaN - * log[Infinity](a) = NaN - * log[b](0) = -Infinity - * log[b](-0) = -Infinity - * log[b](-a) = NaN - * log[b](1) = 0 - * log[b](Infinity) = Infinity - * log[b](NaN) = NaN - * - * [base] {number|string|bigint|Decimal} The base of the logarithm. - * + /* + * Return the logarithm of the value of this Decimal to the specified base, rounded to `precision` + * significant digits using rounding mode `rounding`. + * + * If no base is specified, return log[10](arg). + * + * log[base](arg) = ln(arg) / ln(base) + * + * The result will always be correctly rounded if the base of the log is 10, and 'almost always' + * otherwise: + * + * Depending on the rounding mode, the result may be incorrectly rounded if the first fifteen + * rounding digits are [49]99999999999999 or [50]00000000000000. In that case, the maximum error + * between the result and the correctly rounded result will be one ulp (unit in the last place). + * + * log[-b](a) = NaN + * log[0](a) = NaN + * log[1](a) = NaN + * log[NaN](a) = NaN + * log[Infinity](a) = NaN + * log[b](0) = -Infinity + * log[b](-0) = -Infinity + * log[b](-a) = NaN + * log[b](1) = 0 + * log[b](Infinity) = Infinity + * log[b](NaN) = NaN + * + * [base] {number|string|bigint|Decimal} The base of the logarithm. + * */ P.logarithm = P.log = function (base) { var isBase10, @@ -60920,48 +60912,48 @@ return finalise(r, pr, rm); }; - /* - * Return a new Decimal whose value is the maximum of the arguments and the value of this Decimal. - * - * arguments {number|string|bigint|Decimal} - * - P.max = function () { - Array.prototype.push.call(arguments, this); - return maxOrMin(this.constructor, arguments, -1); - }; - */ - - /* - * Return a new Decimal whose value is the minimum of the arguments and the value of this Decimal. - * - * arguments {number|string|bigint|Decimal} - * - P.min = function () { - Array.prototype.push.call(arguments, this); - return maxOrMin(this.constructor, arguments, 1); - }; - */ - - /* - * n - 0 = n - * n - N = N - * n - I = -I - * 0 - n = -n - * 0 - 0 = 0 - * 0 - N = N - * 0 - I = -I - * N - n = N - * N - 0 = N - * N - N = N - * N - I = N - * I - n = I - * I - 0 = I - * I - N = N - * I - I = N - * - * Return a new Decimal whose value is the value of this Decimal minus `y`, rounded to `precision` - * significant digits using rounding mode `rounding`. - * + /* + * Return a new Decimal whose value is the maximum of the arguments and the value of this Decimal. + * + * arguments {number|string|bigint|Decimal} + * + P.max = function () { + Array.prototype.push.call(arguments, this); + return maxOrMin(this.constructor, arguments, -1); + }; + */ + + /* + * Return a new Decimal whose value is the minimum of the arguments and the value of this Decimal. + * + * arguments {number|string|bigint|Decimal} + * + P.min = function () { + Array.prototype.push.call(arguments, this); + return maxOrMin(this.constructor, arguments, 1); + }; + */ + + /* + * n - 0 = n + * n - N = N + * n - I = -I + * 0 - n = -n + * 0 - 0 = 0 + * 0 - N = N + * 0 - I = -I + * N - n = N + * N - 0 = N + * N - N = N + * N - I = N + * I - n = I + * I - 0 = I + * I - N = N + * I - I = N + * + * Return a new Decimal whose value is the value of this Decimal minus `y`, rounded to `precision` + * significant digits using rounding mode `rounding`. + * */ P.minus = P.sub = function (y) { var d, @@ -61105,29 +61097,29 @@ return external ? finalise(y, pr, rm) : y; }; - /* - * n % 0 = N - * n % N = N - * n % I = n - * 0 % n = 0 - * -0 % n = -0 - * 0 % 0 = N - * 0 % N = N - * 0 % I = 0 - * N % n = N - * N % 0 = N - * N % N = N - * N % I = N - * I % n = N - * I % 0 = N - * I % N = N - * I % I = N - * - * Return a new Decimal whose value is the value of this Decimal modulo `y`, rounded to - * `precision` significant digits using rounding mode `rounding`. - * - * The result depends on the modulo mode. - * + /* + * n % 0 = N + * n % N = N + * n % I = n + * 0 % n = 0 + * -0 % n = -0 + * 0 % 0 = N + * 0 % N = N + * 0 % I = 0 + * N % n = N + * N % 0 = N + * N % N = N + * N % I = N + * I % n = N + * I % 0 = N + * I % N = N + * I % I = N + * + * Return a new Decimal whose value is the value of this Decimal modulo `y`, rounded to + * `precision` significant digits using rounding mode `rounding`. + * + * The result depends on the modulo mode. + * */ P.modulo = P.mod = function (y) { var q, @@ -61158,29 +61150,29 @@ return x.minus(q); }; - /* - * Return a new Decimal whose value is the natural exponential of the value of this Decimal, - * i.e. the base e raised to the power the value of this Decimal, rounded to `precision` - * significant digits using rounding mode `rounding`. - * + /* + * Return a new Decimal whose value is the natural exponential of the value of this Decimal, + * i.e. the base e raised to the power the value of this Decimal, rounded to `precision` + * significant digits using rounding mode `rounding`. + * */ P.naturalExponential = P.exp = function () { return naturalExponential(this); }; - /* - * Return a new Decimal whose value is the natural logarithm of the value of this Decimal, - * rounded to `precision` significant digits using rounding mode `rounding`. - * + /* + * Return a new Decimal whose value is the natural logarithm of the value of this Decimal, + * rounded to `precision` significant digits using rounding mode `rounding`. + * */ P.naturalLogarithm = P.ln = function () { return naturalLogarithm(this); }; - /* - * Return a new Decimal whose value is the value of this Decimal negated, i.e. as if multiplied by - * -1. - * + /* + * Return a new Decimal whose value is the value of this Decimal negated, i.e. as if multiplied by + * -1. + * */ P.negated = P.neg = function () { var x = new this.constructor(this); @@ -61188,26 +61180,26 @@ return finalise(x); }; - /* - * n + 0 = n - * n + N = N - * n + I = I - * 0 + n = n - * 0 + 0 = 0 - * 0 + N = N - * 0 + I = I - * N + n = N - * N + 0 = N - * N + N = N - * N + I = N - * I + n = I - * I + 0 = I - * I + N = N - * I + I = I - * - * Return a new Decimal whose value is the value of this Decimal plus `y`, rounded to `precision` - * significant digits using rounding mode `rounding`. - * + /* + * n + 0 = n + * n + N = N + * n + I = I + * 0 + n = n + * 0 + 0 = 0 + * 0 + N = N + * 0 + I = I + * N + n = N + * N + 0 = N + * N + N = N + * N + I = N + * I + n = I + * I + 0 = I + * I + N = N + * I + I = I + * + * Return a new Decimal whose value is the value of this Decimal plus `y`, rounded to `precision` + * significant digits using rounding mode `rounding`. + * */ P.plus = P.add = function (y) { var carry, @@ -61317,11 +61309,11 @@ return external ? finalise(y, pr, rm) : y; }; - /* - * Return the number of significant digits of the value of this Decimal. - * - * [z] {boolean|number} Whether to count integer-part trailing zeros: true, false, 1 or 0. - * + /* + * Return the number of significant digits of the value of this Decimal. + * + * [z] {boolean|number} Whether to count integer-part trailing zeros: true, false, 1 or 0. + * */ P.precision = P.sd = function (z) { var k, @@ -61336,10 +61328,10 @@ return k; }; - /* - * Return a new Decimal whose value is the value of this Decimal rounded to a whole number using - * rounding mode `rounding`. - * + /* + * Return a new Decimal whose value is the value of this Decimal rounded to a whole number using + * rounding mode `rounding`. + * */ P.round = function () { var x = this, @@ -61347,20 +61339,20 @@ return finalise(new Ctor(x), x.e + 1, Ctor.rounding); }; - /* - * Return a new Decimal whose value is the sine of the value in radians of this Decimal. - * - * Domain: [-Infinity, Infinity] - * Range: [-1, 1] - * - * sin(x) = x - x^3/3! + x^5/5! - ... - * - * sin(0) = 0 - * sin(-0) = -0 - * sin(Infinity) = NaN - * sin(-Infinity) = NaN - * sin(NaN) = NaN - * + /* + * Return a new Decimal whose value is the sine of the value in radians of this Decimal. + * + * Domain: [-Infinity, Infinity] + * Range: [-1, 1] + * + * sin(x) = x - x^3/3! + x^5/5! - ... + * + * sin(0) = 0 + * sin(-0) = -0 + * sin(Infinity) = NaN + * sin(-Infinity) = NaN + * sin(NaN) = NaN + * */ P.sine = P.sin = function () { var pr, @@ -61379,17 +61371,17 @@ return finalise(quadrant > 2 ? x.neg() : x, pr, rm, true); }; - /* - * Return a new Decimal whose value is the square root of this Decimal, rounded to `precision` - * significant digits using rounding mode `rounding`. - * - * sqrt(-n) = N - * sqrt(N) = N - * sqrt(-I) = N - * sqrt(I) = I - * sqrt(0) = 0 - * sqrt(-0) = -0 - * + /* + * Return a new Decimal whose value is the square root of this Decimal, rounded to `precision` + * significant digits using rounding mode `rounding`. + * + * sqrt(-n) = N + * sqrt(N) = N + * sqrt(-I) = N + * sqrt(I) = I + * sqrt(0) = 0 + * sqrt(-0) = -0 + * */ P.squareRoot = P.sqrt = function () { var m, @@ -61471,18 +61463,18 @@ return finalise(r, e, Ctor.rounding, m); }; - /* - * Return a new Decimal whose value is the tangent of the value in radians of this Decimal. - * - * Domain: [-Infinity, Infinity] - * Range: [-Infinity, Infinity] - * - * tan(0) = 0 - * tan(-0) = -0 - * tan(Infinity) = NaN - * tan(-Infinity) = NaN - * tan(NaN) = NaN - * + /* + * Return a new Decimal whose value is the tangent of the value in radians of this Decimal. + * + * Domain: [-Infinity, Infinity] + * Range: [-Infinity, Infinity] + * + * tan(0) = 0 + * tan(-0) = -0 + * tan(Infinity) = NaN + * tan(-Infinity) = NaN + * tan(NaN) = NaN + * */ P.tangent = P.tan = function () { var pr, @@ -61503,26 +61495,26 @@ return finalise(quadrant == 2 || quadrant == 4 ? x.neg() : x, pr, rm, true); }; - /* - * n * 0 = 0 - * n * N = N - * n * I = I - * 0 * n = 0 - * 0 * 0 = 0 - * 0 * N = N - * 0 * I = N - * N * n = N - * N * 0 = N - * N * N = N - * N * I = N - * I * n = I - * I * 0 = N - * I * N = N - * I * I = I - * - * Return a new Decimal whose value is this Decimal times `y`, rounded to `precision` significant - * digits using rounding mode `rounding`. - * + /* + * n * 0 = 0 + * n * N = N + * n * I = I + * 0 * n = 0 + * 0 * 0 = 0 + * 0 * N = N + * 0 * I = N + * N * n = N + * N * 0 = N + * N * N = N + * N * I = N + * I * n = I + * I * 0 = N + * I * N = N + * I * I = I + * + * Return a new Decimal whose value is this Decimal times `y`, rounded to `precision` significant + * digits using rounding mode `rounding`. + * */ P.times = P.mul = function (y) { var carry, @@ -61590,29 +61582,29 @@ return external ? finalise(y, Ctor.precision, Ctor.rounding) : y; }; - /* - * Return a string representing the value of this Decimal in base 2, round to `sd` significant - * digits using rounding mode `rm`. - * - * If the optional `sd` argument is present then return binary exponential notation. - * - * [sd] {number} Significant digits. Integer, 1 to MAX_DIGITS inclusive. - * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. - * + /* + * Return a string representing the value of this Decimal in base 2, round to `sd` significant + * digits using rounding mode `rm`. + * + * If the optional `sd` argument is present then return binary exponential notation. + * + * [sd] {number} Significant digits. Integer, 1 to MAX_DIGITS inclusive. + * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. + * */ P.toBinary = function (sd, rm) { return toStringBinary(this, 2, sd, rm); }; - /* - * Return a new Decimal whose value is the value of this Decimal rounded to a maximum of `dp` - * decimal places using rounding mode `rm` or `rounding` if `rm` is omitted. - * - * If `dp` is omitted, return a new Decimal whose value is the value of this Decimal. - * - * [dp] {number} Decimal places. Integer, 0 to MAX_DIGITS inclusive. - * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. - * + /* + * Return a new Decimal whose value is the value of this Decimal rounded to a maximum of `dp` + * decimal places using rounding mode `rm` or `rounding` if `rm` is omitted. + * + * If `dp` is omitted, return a new Decimal whose value is the value of this Decimal. + * + * [dp] {number} Decimal places. Integer, 0 to MAX_DIGITS inclusive. + * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. + * */ P.toDecimalPlaces = P.toDP = function (dp, rm) { var x = this, @@ -61624,13 +61616,13 @@ return finalise(x, dp + x.e + 1, rm); }; - /* - * Return a string representing the value of this Decimal in exponential notation rounded to - * `dp` fixed decimal places using rounding mode `rounding`. - * - * [dp] {number} Decimal places. Integer, 0 to MAX_DIGITS inclusive. - * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. - * + /* + * Return a string representing the value of this Decimal in exponential notation rounded to + * `dp` fixed decimal places using rounding mode `rounding`. + * + * [dp] {number} Decimal places. Integer, 0 to MAX_DIGITS inclusive. + * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. + * */ P.toExponential = function (dp, rm) { var str, @@ -61647,21 +61639,21 @@ return x.isNeg() && !x.isZero() ? '-' + str : str; }; - /* - * Return a string representing the value of this Decimal in normal (fixed-point) notation to - * `dp` fixed decimal places and rounded using rounding mode `rm` or `rounding` if `rm` is - * omitted. - * - * As with JavaScript numbers, (-0).toFixed(0) is '0', but e.g. (-0.00001).toFixed(0) is '-0'. - * - * [dp] {number} Decimal places. Integer, 0 to MAX_DIGITS inclusive. - * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. - * - * (-0).toFixed(0) is '0', but (-0.1).toFixed(0) is '-0'. - * (-0).toFixed(1) is '0.0', but (-0.01).toFixed(1) is '-0.0'. - * (-0).toFixed(3) is '0.000'. - * (-0.5).toFixed(0) is '-0'. - * + /* + * Return a string representing the value of this Decimal in normal (fixed-point) notation to + * `dp` fixed decimal places and rounded using rounding mode `rm` or `rounding` if `rm` is + * omitted. + * + * As with JavaScript numbers, (-0).toFixed(0) is '0', but e.g. (-0.00001).toFixed(0) is '-0'. + * + * [dp] {number} Decimal places. Integer, 0 to MAX_DIGITS inclusive. + * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. + * + * (-0).toFixed(0) is '0', but (-0.1).toFixed(0) is '-0'. + * (-0).toFixed(1) is '0.0', but (-0.01).toFixed(1) is '-0.0'. + * (-0).toFixed(3) is '0.000'. + * (-0.5).toFixed(0) is '-0'. + * */ P.toFixed = function (dp, rm) { var str, @@ -61682,16 +61674,16 @@ return x.isNeg() && !x.isZero() ? '-' + str : str; }; - /* - * Return an array representing the value of this Decimal as a simple fraction with an integer - * numerator and an integer denominator. - * - * The denominator will be a positive non-zero value less than or equal to the specified maximum - * denominator. If a maximum denominator is not specified, the denominator will be the lowest - * value necessary to represent the number exactly. - * - * [maxD] {number|string|bigint|Decimal} Maximum denominator. Integer >= 1 and < Infinity. - * + /* + * Return an array representing the value of this Decimal as a simple fraction with an integer + * numerator and an integer denominator. + * + * The denominator will be a positive non-zero value less than or equal to the specified maximum + * denominator. If a maximum denominator is not specified, the denominator will be the lowest + * value necessary to represent the number exactly. + * + * [maxD] {number|string|bigint|Decimal} Maximum denominator. Integer >= 1 and < Infinity. + * */ P.toFraction = function (maxD) { var d, @@ -61753,35 +61745,35 @@ return r; }; - /* - * Return a string representing the value of this Decimal in base 16, round to `sd` significant - * digits using rounding mode `rm`. - * - * If the optional `sd` argument is present then return binary exponential notation. - * - * [sd] {number} Significant digits. Integer, 1 to MAX_DIGITS inclusive. - * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. - * + /* + * Return a string representing the value of this Decimal in base 16, round to `sd` significant + * digits using rounding mode `rm`. + * + * If the optional `sd` argument is present then return binary exponential notation. + * + * [sd] {number} Significant digits. Integer, 1 to MAX_DIGITS inclusive. + * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. + * */ P.toHexadecimal = P.toHex = function (sd, rm) { return toStringBinary(this, 16, sd, rm); }; - /* - * Returns a new Decimal whose value is the nearest multiple of `y` in the direction of rounding - * mode `rm`, or `Decimal.rounding` if `rm` is omitted, to the value of this Decimal. - * - * The return value will always have the same sign as this Decimal, unless either this Decimal - * or `y` is NaN, in which case the return value will be also be NaN. - * - * The return value is not affected by the value of `precision`. - * - * y {number|string|bigint|Decimal} The magnitude to round to a multiple of. - * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. - * - * 'toNearest() rounding mode not an integer: {rm}' - * 'toNearest() rounding mode out of range: {rm}' - * + /* + * Returns a new Decimal whose value is the nearest multiple of `y` in the direction of rounding + * mode `rm`, or `Decimal.rounding` if `rm` is omitted, to the value of this Decimal. + * + * The return value will always have the same sign as this Decimal, unless either this Decimal + * or `y` is NaN, in which case the return value will be also be NaN. + * + * The return value is not affected by the value of `precision`. + * + * y {number|string|bigint|Decimal} The magnitude to round to a multiple of. + * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. + * + * 'toNearest() rounding mode not an integer: {rm}' + * 'toNearest() rounding mode out of range: {rm}' + * */ P.toNearest = function (y, rm) { var x = this, @@ -61825,70 +61817,70 @@ return x; }; - /* - * Return the value of this Decimal converted to a number primitive. - * Zero keeps its sign. - * + /* + * Return the value of this Decimal converted to a number primitive. + * Zero keeps its sign. + * */ P.toNumber = function () { return +this; }; - /* - * Return a string representing the value of this Decimal in base 8, round to `sd` significant - * digits using rounding mode `rm`. - * - * If the optional `sd` argument is present then return binary exponential notation. - * - * [sd] {number} Significant digits. Integer, 1 to MAX_DIGITS inclusive. - * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. - * + /* + * Return a string representing the value of this Decimal in base 8, round to `sd` significant + * digits using rounding mode `rm`. + * + * If the optional `sd` argument is present then return binary exponential notation. + * + * [sd] {number} Significant digits. Integer, 1 to MAX_DIGITS inclusive. + * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. + * */ P.toOctal = function (sd, rm) { return toStringBinary(this, 8, sd, rm); }; - /* - * Return a new Decimal whose value is the value of this Decimal raised to the power `y`, rounded - * to `precision` significant digits using rounding mode `rounding`. - * - * ECMAScript compliant. - * - * pow(x, NaN) = NaN - * pow(x, ±0) = 1 - * pow(NaN, non-zero) = NaN - * pow(abs(x) > 1, +Infinity) = +Infinity - * pow(abs(x) > 1, -Infinity) = +0 - * pow(abs(x) == 1, ±Infinity) = NaN - * pow(abs(x) < 1, +Infinity) = +0 - * pow(abs(x) < 1, -Infinity) = +Infinity - * pow(+Infinity, y > 0) = +Infinity - * pow(+Infinity, y < 0) = +0 - * pow(-Infinity, odd integer > 0) = -Infinity - * pow(-Infinity, even integer > 0) = +Infinity - * pow(-Infinity, odd integer < 0) = -0 - * pow(-Infinity, even integer < 0) = +0 - * pow(+0, y > 0) = +0 - * pow(+0, y < 0) = +Infinity - * pow(-0, odd integer > 0) = -0 - * pow(-0, even integer > 0) = +0 - * pow(-0, odd integer < 0) = -Infinity - * pow(-0, even integer < 0) = +Infinity - * pow(finite x < 0, finite non-integer) = NaN - * - * For non-integer or very large exponents pow(x, y) is calculated using - * - * x^y = exp(y*ln(x)) - * - * Assuming the first 15 rounding digits are each equally likely to be any digit 0-9, the - * probability of an incorrectly rounded result - * P([49]9{14} | [50]0{14}) = 2 * 0.2 * 10^-14 = 4e-15 = 1/2.5e+14 - * i.e. 1 in 250,000,000,000,000 - * - * If a result is incorrectly rounded the maximum error will be 1 ulp (unit in last place). - * - * y {number|string|bigint|Decimal} The power to which to raise this Decimal. - * + /* + * Return a new Decimal whose value is the value of this Decimal raised to the power `y`, rounded + * to `precision` significant digits using rounding mode `rounding`. + * + * ECMAScript compliant. + * + * pow(x, NaN) = NaN + * pow(x, ±0) = 1 + * pow(NaN, non-zero) = NaN + * pow(abs(x) > 1, +Infinity) = +Infinity + * pow(abs(x) > 1, -Infinity) = +0 + * pow(abs(x) == 1, ±Infinity) = NaN + * pow(abs(x) < 1, +Infinity) = +0 + * pow(abs(x) < 1, -Infinity) = +Infinity + * pow(+Infinity, y > 0) = +Infinity + * pow(+Infinity, y < 0) = +0 + * pow(-Infinity, odd integer > 0) = -Infinity + * pow(-Infinity, even integer > 0) = +Infinity + * pow(-Infinity, odd integer < 0) = -0 + * pow(-Infinity, even integer < 0) = +0 + * pow(+0, y > 0) = +0 + * pow(+0, y < 0) = +Infinity + * pow(-0, odd integer > 0) = -0 + * pow(-0, even integer > 0) = +0 + * pow(-0, odd integer < 0) = -Infinity + * pow(-0, even integer < 0) = +Infinity + * pow(finite x < 0, finite non-integer) = NaN + * + * For non-integer or very large exponents pow(x, y) is calculated using + * + * x^y = exp(y*ln(x)) + * + * Assuming the first 15 rounding digits are each equally likely to be any digit 0-9, the + * probability of an incorrectly rounded result + * P([49]9{14} | [50]0{14}) = 2 * 0.2 * 10^-14 = 4e-15 = 1/2.5e+14 + * i.e. 1 in 250,000,000,000,000 + * + * If a result is incorrectly rounded the maximum error will be 1 ulp (unit in last place). + * + * y {number|string|bigint|Decimal} The power to which to raise this Decimal. + * */ P.toPower = P.pow = function (y) { var e, @@ -61982,16 +61974,16 @@ return finalise(r, pr, rm); }; - /* - * Return a string representing the value of this Decimal rounded to `sd` significant digits - * using rounding mode `rounding`. - * - * Return exponential notation if `sd` is less than the number of digits necessary to represent - * the integer part of the value in normal notation. - * - * [sd] {number} Significant digits. Integer, 1 to MAX_DIGITS inclusive. - * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. - * + /* + * Return a string representing the value of this Decimal rounded to `sd` significant digits + * using rounding mode `rounding`. + * + * Return exponential notation if `sd` is less than the number of digits necessary to represent + * the integer part of the value in normal notation. + * + * [sd] {number} Significant digits. Integer, 1 to MAX_DIGITS inclusive. + * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. + * */ P.toPrecision = function (sd, rm) { var str, @@ -62008,19 +62000,19 @@ return x.isNeg() && !x.isZero() ? '-' + str : str; }; - /* - * Return a new Decimal whose value is the value of this Decimal rounded to a maximum of `sd` - * significant digits using rounding mode `rm`, or to `precision` and `rounding` respectively if - * omitted. - * - * [sd] {number} Significant digits. Integer, 1 to MAX_DIGITS inclusive. - * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. - * - * 'toSD() digits out of range: {sd}' - * 'toSD() digits not an integer: {sd}' - * 'toSD() rounding mode not an integer: {rm}' - * 'toSD() rounding mode out of range: {rm}' - * + /* + * Return a new Decimal whose value is the value of this Decimal rounded to a maximum of `sd` + * significant digits using rounding mode `rm`, or to `precision` and `rounding` respectively if + * omitted. + * + * [sd] {number} Significant digits. Integer, 1 to MAX_DIGITS inclusive. + * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. + * + * 'toSD() digits out of range: {sd}' + * 'toSD() digits not an integer: {sd}' + * 'toSD() rounding mode not an integer: {rm}' + * 'toSD() rounding mode out of range: {rm}' + * */ P.toSignificantDigits = P.toSD = function (sd, rm) { var x = this, @@ -62035,12 +62027,12 @@ return finalise(new Ctor(x), sd, rm); }; - /* - * Return a string representing the value of this Decimal. - * - * Return exponential notation if this Decimal has a positive exponent equal to or greater than - * `toExpPos`, or a negative exponent equal to or less than `toExpNeg`. - * + /* + * Return a string representing the value of this Decimal. + * + * Return exponential notation if this Decimal has a positive exponent equal to or greater than + * `toExpPos`, or a negative exponent equal to or less than `toExpNeg`. + * */ P.toString = function () { var x = this, @@ -62049,18 +62041,18 @@ return x.isNeg() && !x.isZero() ? '-' + str : str; }; - /* - * Return a new Decimal whose value is the value of this Decimal truncated to a whole number. - * + /* + * Return a new Decimal whose value is the value of this Decimal truncated to a whole number. + * */ P.truncated = P.trunc = function () { return finalise(new this.constructor(this), this.e + 1, 1); }; - /* - * Return a string representing the value of this Decimal. - * Unlike `toString`, negative zero will include the minus sign. - * + /* + * Return a string representing the value of this Decimal. + * Unlike `toString`, negative zero will include the minus sign. + * */ P.valueOf = P.toJSON = function () { var x = this, @@ -62071,49 +62063,49 @@ // Helper functions for Decimal.prototype (P) and/or Decimal methods, and their callers. - /* - * digitsToString P.cubeRoot, P.logarithm, P.squareRoot, P.toFraction, P.toPower, - * finiteToString, naturalExponential, naturalLogarithm - * checkInt32 P.toDecimalPlaces, P.toExponential, P.toFixed, P.toNearest, - * P.toPrecision, P.toSignificantDigits, toStringBinary, random - * checkRoundingDigits P.logarithm, P.toPower, naturalExponential, naturalLogarithm - * convertBase toStringBinary, parseOther - * cos P.cos - * divide P.atanh, P.cubeRoot, P.dividedBy, P.dividedToIntegerBy, - * P.logarithm, P.modulo, P.squareRoot, P.tan, P.tanh, P.toFraction, - * P.toNearest, toStringBinary, naturalExponential, naturalLogarithm, - * taylorSeries, atan2, parseOther - * finalise P.absoluteValue, P.atan, P.atanh, P.ceil, P.cos, P.cosh, - * P.cubeRoot, P.dividedToIntegerBy, P.floor, P.logarithm, P.minus, - * P.modulo, P.negated, P.plus, P.round, P.sin, P.sinh, P.squareRoot, - * P.tan, P.times, P.toDecimalPlaces, P.toExponential, P.toFixed, - * P.toNearest, P.toPower, P.toPrecision, P.toSignificantDigits, - * P.truncated, divide, getLn10, getPi, naturalExponential, - * naturalLogarithm, ceil, floor, round, trunc - * finiteToString P.toExponential, P.toFixed, P.toPrecision, P.toString, P.valueOf, - * toStringBinary - * getBase10Exponent P.minus, P.plus, P.times, parseOther - * getLn10 P.logarithm, naturalLogarithm - * getPi P.acos, P.asin, P.atan, toLessThanHalfPi, atan2 - * getPrecision P.precision, P.toFraction - * getZeroString digitsToString, finiteToString - * intPow P.toPower, parseOther - * isOdd toLessThanHalfPi - * maxOrMin max, min - * naturalExponential P.naturalExponential, P.toPower - * naturalLogarithm P.acosh, P.asinh, P.atanh, P.logarithm, P.naturalLogarithm, - * P.toPower, naturalExponential - * nonFiniteToString finiteToString, toStringBinary - * parseDecimal Decimal - * parseOther Decimal - * sin P.sin - * taylorSeries P.cosh, P.sinh, cos, sin - * toLessThanHalfPi P.cos, P.sin - * toStringBinary P.toBinary, P.toHexadecimal, P.toOctal - * truncate intPow - * - * Throws: P.logarithm, P.precision, P.toFraction, checkInt32, getLn10, getPi, - * naturalLogarithm, config, parseOther, random, Decimal + /* + * digitsToString P.cubeRoot, P.logarithm, P.squareRoot, P.toFraction, P.toPower, + * finiteToString, naturalExponential, naturalLogarithm + * checkInt32 P.toDecimalPlaces, P.toExponential, P.toFixed, P.toNearest, + * P.toPrecision, P.toSignificantDigits, toStringBinary, random + * checkRoundingDigits P.logarithm, P.toPower, naturalExponential, naturalLogarithm + * convertBase toStringBinary, parseOther + * cos P.cos + * divide P.atanh, P.cubeRoot, P.dividedBy, P.dividedToIntegerBy, + * P.logarithm, P.modulo, P.squareRoot, P.tan, P.tanh, P.toFraction, + * P.toNearest, toStringBinary, naturalExponential, naturalLogarithm, + * taylorSeries, atan2, parseOther + * finalise P.absoluteValue, P.atan, P.atanh, P.ceil, P.cos, P.cosh, + * P.cubeRoot, P.dividedToIntegerBy, P.floor, P.logarithm, P.minus, + * P.modulo, P.negated, P.plus, P.round, P.sin, P.sinh, P.squareRoot, + * P.tan, P.times, P.toDecimalPlaces, P.toExponential, P.toFixed, + * P.toNearest, P.toPower, P.toPrecision, P.toSignificantDigits, + * P.truncated, divide, getLn10, getPi, naturalExponential, + * naturalLogarithm, ceil, floor, round, trunc + * finiteToString P.toExponential, P.toFixed, P.toPrecision, P.toString, P.valueOf, + * toStringBinary + * getBase10Exponent P.minus, P.plus, P.times, parseOther + * getLn10 P.logarithm, naturalLogarithm + * getPi P.acos, P.asin, P.atan, toLessThanHalfPi, atan2 + * getPrecision P.precision, P.toFraction + * getZeroString digitsToString, finiteToString + * intPow P.toPower, parseOther + * isOdd toLessThanHalfPi + * maxOrMin max, min + * naturalExponential P.naturalExponential, P.toPower + * naturalLogarithm P.acosh, P.asinh, P.atanh, P.logarithm, P.naturalLogarithm, + * P.toPower, naturalExponential + * nonFiniteToString finiteToString, toStringBinary + * parseDecimal Decimal + * parseOther Decimal + * sin P.sin + * taylorSeries P.cosh, P.sinh, cos, sin + * toLessThanHalfPi P.cos, P.sin + * toStringBinary P.toBinary, P.toHexadecimal, P.toOctal + * truncate intPow + * + * Throws: P.logarithm, P.precision, P.toFraction, checkInt32, getLn10, getPi, + * naturalLogarithm, config, parseOther, random, Decimal */ function digitsToString(d) { @@ -62149,10 +62141,10 @@ } } - /* - * Check 5 rounding digits if `repeating` is null, 4 otherwise. - * `repeating == null` if caller is `log` or `pow`, - * `repeating != null` if caller is `naturalLogarithm` or `naturalExponential`. + /* + * Check 5 rounding digits if `repeating` is null, 4 otherwise. + * `repeating == null` if caller is `log` or `pow`, + * `repeating != null` if caller is `naturalLogarithm` or `naturalExponential`. */ function checkRoundingDigits(d, i, rm, repeating) { var di, k, r, rd; @@ -62215,10 +62207,10 @@ return arr.reverse(); } - /* - * cos(x) = 1 - x^2/2! + x^4/4! - ... - * |x| < pi/2 - * + /* + * cos(x) = 1 - x^2/2! + x^4/4! - ... + * |x| < pi/2 + * */ function cosine(Ctor, x) { var k, len, y; @@ -62248,8 +62240,8 @@ return x; } - /* - * Perform division in the specified base. + /* + * Perform division in the specified base. */ var divide = function () { // Assumes non-zero x and k, and hence non-zero result. @@ -62500,9 +62492,9 @@ }; }(); - /* - * Round `x` to `sd` significant digits using rounding mode `rm`. - * Check for over/under-flow. + /* + * Round `x` to `sd` significant digits using rounding mode `rm`. + * Check for over/under-flow. */ function finalise(x, sd, rm, isTruncated) { var digits, @@ -62729,12 +62721,12 @@ return zs; } - /* - * Return a new Decimal whose value is the value of Decimal `x` to the power `n`, where `n` is an - * integer of type number. - * - * Implements 'exponentiation by squaring'. Called by `pow` and `parseOther`. - * + /* + * Return a new Decimal whose value is the value of Decimal `x` to the power `n`, where `n` is an + * integer of type number. + * + * Implements 'exponentiation by squaring'. Called by `pow` and `parseOther`. + * */ function intPow(Ctor, x, n, pr) { var isTruncated, @@ -62765,8 +62757,8 @@ return n.d[n.d.length - 1] & 1; } - /* - * Handle `max` (`n` is -1) and `min` (`n` is 1). + /* + * Handle `max` (`n` is -1) and `min` (`n` is 1). */ function maxOrMin(Ctor, args, n) { var k, @@ -62789,36 +62781,36 @@ return x; } - /* - * Return a new Decimal whose value is the natural exponential of `x` rounded to `sd` significant - * digits. - * - * Taylor/Maclaurin series. - * - * exp(x) = x^0/0! + x^1/1! + x^2/2! + x^3/3! + ... - * - * Argument reduction: - * Repeat x = x / 32, k += 5, until |x| < 0.1 - * exp(x) = exp(x / 2^k)^(2^k) - * - * Previously, the argument was initially reduced by - * exp(x) = exp(r) * 10^k where r = x - k * ln10, k = floor(x / ln10) - * to first put r in the range [0, ln10], before dividing by 32 until |x| < 0.1, but this was - * found to be slower than just dividing repeatedly by 32 as above. - * - * Max integer argument: exp('20723265836946413') = 6.3e+9000000000000000 - * Min integer argument: exp('-20723265836946411') = 1.2e-9000000000000000 - * (Math object integer min/max: Math.exp(709) = 8.2e+307, Math.exp(-745) = 5e-324) - * - * exp(Infinity) = Infinity - * exp(-Infinity) = 0 - * exp(NaN) = NaN - * exp(±0) = 1 - * - * exp(x) is non-terminating for any finite, non-zero x. - * - * The result will always be correctly rounded. - * + /* + * Return a new Decimal whose value is the natural exponential of `x` rounded to `sd` significant + * digits. + * + * Taylor/Maclaurin series. + * + * exp(x) = x^0/0! + x^1/1! + x^2/2! + x^3/3! + ... + * + * Argument reduction: + * Repeat x = x / 32, k += 5, until |x| < 0.1 + * exp(x) = exp(x / 2^k)^(2^k) + * + * Previously, the argument was initially reduced by + * exp(x) = exp(r) * 10^k where r = x - k * ln10, k = floor(x / ln10) + * to first put r in the range [0, ln10], before dividing by 32 until |x| < 0.1, but this was + * found to be slower than just dividing repeatedly by 32 as above. + * + * Max integer argument: exp('20723265836946413') = 6.3e+9000000000000000 + * Min integer argument: exp('-20723265836946411') = 1.2e-9000000000000000 + * (Math object integer min/max: Math.exp(709) = 8.2e+307, Math.exp(-745) = 5e-324) + * + * exp(Infinity) = Infinity + * exp(-Infinity) = 0 + * exp(NaN) = NaN + * exp(±0) = 1 + * + * exp(x) is non-terminating for any finite, non-zero x. + * + * The result will always be correctly rounded. + * */ function naturalExponential(x, sd) { var denominator, @@ -62891,20 +62883,20 @@ } } - /* - * Return a new Decimal whose value is the natural logarithm of `x` rounded to `sd` significant - * digits. - * - * ln(-n) = NaN - * ln(0) = -Infinity - * ln(-0) = -Infinity - * ln(1) = 0 - * ln(Infinity) = Infinity - * ln(-Infinity) = NaN - * ln(NaN) = NaN - * - * ln(n) (n != 1) is non-terminating. - * + /* + * Return a new Decimal whose value is the natural logarithm of `x` rounded to `sd` significant + * digits. + * + * ln(-n) = NaN + * ln(0) = -Infinity + * ln(-0) = -Infinity + * ln(1) = 0 + * ln(Infinity) = Infinity + * ln(-Infinity) = NaN + * ln(NaN) = NaN + * + * ln(n) (n != 1) is non-terminating. + * */ function naturalLogarithm(y, sd) { var c, @@ -63025,8 +63017,8 @@ return String(x.s * x.s / 0); } - /* - * Parse the value of a new Decimal `x` from string `str`. + /* + * Parse the value of a new Decimal `x` from string `str`. */ function parseDecimal(x, str) { var e, i, len; @@ -63097,8 +63089,8 @@ return x; } - /* - * Parse the value of a new Decimal `x` from a string `str`, which is not a decimal value. + /* + * Parse the value of a new Decimal `x` from a string `str`, which is not a decimal value. */ function parseOther(x, str) { var base, Ctor, divisor, i, isFloat, len, p, xd, xe; @@ -63168,10 +63160,10 @@ return x; } - /* - * sin(x) = x - x^3/3! + x^5/5! - ... - * |x| < pi/2 - * + /* + * sin(x) = x - x^3/3! + x^5/5! - ... + * |x| < pi/2 + * */ function sine(Ctor, x) { var k, @@ -63268,10 +63260,10 @@ return x.minus(pi).abs(); } - /* - * Return the value of Decimal `x` as a string in base `baseOut`. - * - * If the optional `sd` argument is present include a binary exponent suffix. + /* + * Return the value of Decimal `x` as a string in base `baseOut`. + * + * If the optional `sd` argument is present include a binary exponent suffix. */ function toStringBinary(x, baseOut, sd, rm) { var base, @@ -63406,161 +63398,161 @@ // Decimal methods - /* - * abs - * acos - * acosh - * add - * asin - * asinh - * atan - * atanh - * atan2 - * cbrt - * ceil - * clamp - * clone - * config - * cos - * cosh - * div - * exp - * floor - * hypot - * ln - * log - * log2 - * log10 - * max - * min - * mod - * mul - * pow - * random - * round - * set - * sign - * sin - * sinh - * sqrt - * sub - * sum - * tan - * tanh - * trunc - */ - - /* - * Return a new Decimal whose value is the absolute value of `x`. - * - * x {number|string|bigint|Decimal} - * + /* + * abs + * acos + * acosh + * add + * asin + * asinh + * atan + * atanh + * atan2 + * cbrt + * ceil + * clamp + * clone + * config + * cos + * cosh + * div + * exp + * floor + * hypot + * ln + * log + * log2 + * log10 + * max + * min + * mod + * mul + * pow + * random + * round + * set + * sign + * sin + * sinh + * sqrt + * sub + * sum + * tan + * tanh + * trunc + */ + + /* + * Return a new Decimal whose value is the absolute value of `x`. + * + * x {number|string|bigint|Decimal} + * */ function abs(x) { return new this(x).abs(); } - /* - * Return a new Decimal whose value is the arccosine in radians of `x`. - * - * x {number|string|bigint|Decimal} - * + /* + * Return a new Decimal whose value is the arccosine in radians of `x`. + * + * x {number|string|bigint|Decimal} + * */ function acos(x) { return new this(x).acos(); } - /* - * Return a new Decimal whose value is the inverse of the hyperbolic cosine of `x`, rounded to - * `precision` significant digits using rounding mode `rounding`. - * - * x {number|string|bigint|Decimal} A value in radians. - * + /* + * Return a new Decimal whose value is the inverse of the hyperbolic cosine of `x`, rounded to + * `precision` significant digits using rounding mode `rounding`. + * + * x {number|string|bigint|Decimal} A value in radians. + * */ function acosh(x) { return new this(x).acosh(); } - /* - * Return a new Decimal whose value is the sum of `x` and `y`, rounded to `precision` significant - * digits using rounding mode `rounding`. - * - * x {number|string|bigint|Decimal} - * y {number|string|bigint|Decimal} - * + /* + * Return a new Decimal whose value is the sum of `x` and `y`, rounded to `precision` significant + * digits using rounding mode `rounding`. + * + * x {number|string|bigint|Decimal} + * y {number|string|bigint|Decimal} + * */ function add(x, y) { return new this(x).plus(y); } - /* - * Return a new Decimal whose value is the arcsine in radians of `x`, rounded to `precision` - * significant digits using rounding mode `rounding`. - * - * x {number|string|bigint|Decimal} - * + /* + * Return a new Decimal whose value is the arcsine in radians of `x`, rounded to `precision` + * significant digits using rounding mode `rounding`. + * + * x {number|string|bigint|Decimal} + * */ function asin(x) { return new this(x).asin(); } - /* - * Return a new Decimal whose value is the inverse of the hyperbolic sine of `x`, rounded to - * `precision` significant digits using rounding mode `rounding`. - * - * x {number|string|bigint|Decimal} A value in radians. - * + /* + * Return a new Decimal whose value is the inverse of the hyperbolic sine of `x`, rounded to + * `precision` significant digits using rounding mode `rounding`. + * + * x {number|string|bigint|Decimal} A value in radians. + * */ function asinh(x) { return new this(x).asinh(); } - /* - * Return a new Decimal whose value is the arctangent in radians of `x`, rounded to `precision` - * significant digits using rounding mode `rounding`. - * - * x {number|string|bigint|Decimal} - * + /* + * Return a new Decimal whose value is the arctangent in radians of `x`, rounded to `precision` + * significant digits using rounding mode `rounding`. + * + * x {number|string|bigint|Decimal} + * */ function atan(x) { return new this(x).atan(); } - /* - * Return a new Decimal whose value is the inverse of the hyperbolic tangent of `x`, rounded to - * `precision` significant digits using rounding mode `rounding`. - * - * x {number|string|bigint|Decimal} A value in radians. - * + /* + * Return a new Decimal whose value is the inverse of the hyperbolic tangent of `x`, rounded to + * `precision` significant digits using rounding mode `rounding`. + * + * x {number|string|bigint|Decimal} A value in radians. + * */ function atanh(x) { return new this(x).atanh(); } - /* - * Return a new Decimal whose value is the arctangent in radians of `y/x` in the range -pi to pi - * (inclusive), rounded to `precision` significant digits using rounding mode `rounding`. - * - * Domain: [-Infinity, Infinity] - * Range: [-pi, pi] - * - * y {number|string|bigint|Decimal} The y-coordinate. - * x {number|string|bigint|Decimal} The x-coordinate. - * - * atan2(±0, -0) = ±pi - * atan2(±0, +0) = ±0 - * atan2(±0, -x) = ±pi for x > 0 - * atan2(±0, x) = ±0 for x > 0 - * atan2(-y, ±0) = -pi/2 for y > 0 - * atan2(y, ±0) = pi/2 for y > 0 - * atan2(±y, -Infinity) = ±pi for finite y > 0 - * atan2(±y, +Infinity) = ±0 for finite y > 0 - * atan2(±Infinity, x) = ±pi/2 for finite x - * atan2(±Infinity, -Infinity) = ±3*pi/4 - * atan2(±Infinity, +Infinity) = ±pi/4 - * atan2(NaN, x) = NaN - * atan2(y, NaN) = NaN - * + /* + * Return a new Decimal whose value is the arctangent in radians of `y/x` in the range -pi to pi + * (inclusive), rounded to `precision` significant digits using rounding mode `rounding`. + * + * Domain: [-Infinity, Infinity] + * Range: [-pi, pi] + * + * y {number|string|bigint|Decimal} The y-coordinate. + * x {number|string|bigint|Decimal} The x-coordinate. + * + * atan2(±0, -0) = ±pi + * atan2(±0, +0) = ±0 + * atan2(±0, -x) = ±pi for x > 0 + * atan2(±0, x) = ±0 for x > 0 + * atan2(-y, ±0) = -pi/2 for y > 0 + * atan2(y, ±0) = pi/2 for y > 0 + * atan2(±y, -Infinity) = ±pi for finite y > 0 + * atan2(±y, +Infinity) = ±0 for finite y > 0 + * atan2(±Infinity, x) = ±pi/2 for finite x + * atan2(±Infinity, -Infinity) = ±3*pi/4 + * atan2(±Infinity, +Infinity) = ±pi/4 + * atan2(NaN, x) = NaN + * atan2(y, NaN) = NaN + * */ function atan2(y, x) { y = new this(y); @@ -63604,56 +63596,56 @@ return r; } - /* - * Return a new Decimal whose value is the cube root of `x`, rounded to `precision` significant - * digits using rounding mode `rounding`. - * - * x {number|string|bigint|Decimal} - * + /* + * Return a new Decimal whose value is the cube root of `x`, rounded to `precision` significant + * digits using rounding mode `rounding`. + * + * x {number|string|bigint|Decimal} + * */ function cbrt(x) { return new this(x).cbrt(); } - /* - * Return a new Decimal whose value is `x` rounded to an integer using `ROUND_CEIL`. - * - * x {number|string|bigint|Decimal} - * + /* + * Return a new Decimal whose value is `x` rounded to an integer using `ROUND_CEIL`. + * + * x {number|string|bigint|Decimal} + * */ function ceil(x) { return finalise(x = new this(x), x.e + 1, 2); } - /* - * Return a new Decimal whose value is `x` clamped to the range delineated by `min` and `max`. - * - * x {number|string|bigint|Decimal} - * min {number|string|bigint|Decimal} - * max {number|string|bigint|Decimal} - * + /* + * Return a new Decimal whose value is `x` clamped to the range delineated by `min` and `max`. + * + * x {number|string|bigint|Decimal} + * min {number|string|bigint|Decimal} + * max {number|string|bigint|Decimal} + * */ function clamp(x, min, max) { return new this(x).clamp(min, max); } - /* - * Configure global settings for a Decimal constructor. - * - * `obj` is an object with one or more of the following properties, - * - * precision {number} - * rounding {number} - * toExpNeg {number} - * toExpPos {number} - * maxE {number} - * minE {number} - * modulo {number} - * crypto {boolean|number} - * defaults {true} - * - * E.g. Decimal.config({ precision: 20, rounding: 4 }) - * + /* + * Configure global settings for a Decimal constructor. + * + * `obj` is an object with one or more of the following properties, + * + * precision {number} + * rounding {number} + * toExpNeg {number} + * toExpPos {number} + * maxE {number} + * minE {number} + * modulo {number} + * crypto {boolean|number} + * defaults {true} + * + * E.g. Decimal.config({ precision: 20, rounding: 4 }) + * */ function config(obj) { if (!obj || _typeof(obj) !== 'object') throw Error(decimalError + 'Object expected'); @@ -63687,42 +63679,42 @@ return this; } - /* - * Return a new Decimal whose value is the cosine of `x`, rounded to `precision` significant - * digits using rounding mode `rounding`. - * - * x {number|string|bigint|Decimal} A value in radians. - * + /* + * Return a new Decimal whose value is the cosine of `x`, rounded to `precision` significant + * digits using rounding mode `rounding`. + * + * x {number|string|bigint|Decimal} A value in radians. + * */ function cos(x) { return new this(x).cos(); } - /* - * Return a new Decimal whose value is the hyperbolic cosine of `x`, rounded to precision - * significant digits using rounding mode `rounding`. - * - * x {number|string|bigint|Decimal} A value in radians. - * + /* + * Return a new Decimal whose value is the hyperbolic cosine of `x`, rounded to precision + * significant digits using rounding mode `rounding`. + * + * x {number|string|bigint|Decimal} A value in radians. + * */ function cosh(x) { return new this(x).cosh(); } - /* - * Create and return a Decimal constructor with the same configuration properties as this Decimal - * constructor. - * + /* + * Create and return a Decimal constructor with the same configuration properties as this Decimal + * constructor. + * */ function clone(obj) { var i, p, ps; - /* - * The Decimal constructor and exported function. - * Return a new Decimal instance. - * - * v {number|string|bigint|Decimal} A numeric value. - * + /* + * The Decimal constructor and exported function. + * Return a new Decimal instance. + * + * v {number|string|bigint|Decimal} A numeric value. + * */ function Decimal(v) { var e, @@ -63888,47 +63880,47 @@ return Decimal; } - /* - * Return a new Decimal whose value is `x` divided by `y`, rounded to `precision` significant - * digits using rounding mode `rounding`. - * - * x {number|string|bigint|Decimal} - * y {number|string|bigint|Decimal} - * + /* + * Return a new Decimal whose value is `x` divided by `y`, rounded to `precision` significant + * digits using rounding mode `rounding`. + * + * x {number|string|bigint|Decimal} + * y {number|string|bigint|Decimal} + * */ function div(x, y) { return new this(x).div(y); } - /* - * Return a new Decimal whose value is the natural exponential of `x`, rounded to `precision` - * significant digits using rounding mode `rounding`. - * - * x {number|string|bigint|Decimal} The power to which to raise the base of the natural log. - * + /* + * Return a new Decimal whose value is the natural exponential of `x`, rounded to `precision` + * significant digits using rounding mode `rounding`. + * + * x {number|string|bigint|Decimal} The power to which to raise the base of the natural log. + * */ function exp(x) { return new this(x).exp(); } - /* - * Return a new Decimal whose value is `x` round to an integer using `ROUND_FLOOR`. - * - * x {number|string|bigint|Decimal} - * + /* + * Return a new Decimal whose value is `x` round to an integer using `ROUND_FLOOR`. + * + * x {number|string|bigint|Decimal} + * */ function floor(x) { return finalise(x = new this(x), x.e + 1, 3); } - /* - * Return a new Decimal whose value is the square root of the sum of the squares of the arguments, - * rounded to `precision` significant digits using rounding mode `rounding`. - * - * hypot(a, b, ...) = sqrt(a^2 + b^2 + ...) - * - * arguments {number|string|bigint|Decimal} - * + /* + * Return a new Decimal whose value is the square root of the sum of the squares of the arguments, + * rounded to `precision` significant digits using rounding mode `rounding`. + * + * hypot(a, b, ...) = sqrt(a^2 + b^2 + ...) + * + * arguments {number|string|bigint|Decimal} + * */ function hypot() { var i, @@ -63951,125 +63943,125 @@ return t.sqrt(); } - /* - * Return true if object is a Decimal instance (where Decimal is any Decimal constructor), - * otherwise return false. - * + /* + * Return true if object is a Decimal instance (where Decimal is any Decimal constructor), + * otherwise return false. + * */ function isDecimalInstance(obj) { return obj instanceof Decimal || obj && obj.toStringTag === tag || false; } - /* - * Return a new Decimal whose value is the natural logarithm of `x`, rounded to `precision` - * significant digits using rounding mode `rounding`. - * - * x {number|string|bigint|Decimal} - * + /* + * Return a new Decimal whose value is the natural logarithm of `x`, rounded to `precision` + * significant digits using rounding mode `rounding`. + * + * x {number|string|bigint|Decimal} + * */ function ln(x) { return new this(x).ln(); } - /* - * Return a new Decimal whose value is the log of `x` to the base `y`, or to base 10 if no base - * is specified, rounded to `precision` significant digits using rounding mode `rounding`. - * - * log[y](x) - * - * x {number|string|bigint|Decimal} The argument of the logarithm. - * y {number|string|bigint|Decimal} The base of the logarithm. - * + /* + * Return a new Decimal whose value is the log of `x` to the base `y`, or to base 10 if no base + * is specified, rounded to `precision` significant digits using rounding mode `rounding`. + * + * log[y](x) + * + * x {number|string|bigint|Decimal} The argument of the logarithm. + * y {number|string|bigint|Decimal} The base of the logarithm. + * */ function log(x, y) { return new this(x).log(y); } - /* - * Return a new Decimal whose value is the base 2 logarithm of `x`, rounded to `precision` - * significant digits using rounding mode `rounding`. - * - * x {number|string|bigint|Decimal} - * + /* + * Return a new Decimal whose value is the base 2 logarithm of `x`, rounded to `precision` + * significant digits using rounding mode `rounding`. + * + * x {number|string|bigint|Decimal} + * */ function log2(x) { return new this(x).log(2); } - /* - * Return a new Decimal whose value is the base 10 logarithm of `x`, rounded to `precision` - * significant digits using rounding mode `rounding`. - * - * x {number|string|bigint|Decimal} - * + /* + * Return a new Decimal whose value is the base 10 logarithm of `x`, rounded to `precision` + * significant digits using rounding mode `rounding`. + * + * x {number|string|bigint|Decimal} + * */ function log10(x) { return new this(x).log(10); } - /* - * Return a new Decimal whose value is the maximum of the arguments. - * - * arguments {number|string|bigint|Decimal} - * + /* + * Return a new Decimal whose value is the maximum of the arguments. + * + * arguments {number|string|bigint|Decimal} + * */ function max() { return maxOrMin(this, arguments, -1); } - /* - * Return a new Decimal whose value is the minimum of the arguments. - * - * arguments {number|string|bigint|Decimal} - * + /* + * Return a new Decimal whose value is the minimum of the arguments. + * + * arguments {number|string|bigint|Decimal} + * */ function min() { return maxOrMin(this, arguments, 1); } - /* - * Return a new Decimal whose value is `x` modulo `y`, rounded to `precision` significant digits - * using rounding mode `rounding`. - * - * x {number|string|bigint|Decimal} - * y {number|string|bigint|Decimal} - * + /* + * Return a new Decimal whose value is `x` modulo `y`, rounded to `precision` significant digits + * using rounding mode `rounding`. + * + * x {number|string|bigint|Decimal} + * y {number|string|bigint|Decimal} + * */ function mod(x, y) { return new this(x).mod(y); } - /* - * Return a new Decimal whose value is `x` multiplied by `y`, rounded to `precision` significant - * digits using rounding mode `rounding`. - * - * x {number|string|bigint|Decimal} - * y {number|string|bigint|Decimal} - * + /* + * Return a new Decimal whose value is `x` multiplied by `y`, rounded to `precision` significant + * digits using rounding mode `rounding`. + * + * x {number|string|bigint|Decimal} + * y {number|string|bigint|Decimal} + * */ function mul(x, y) { return new this(x).mul(y); } - /* - * Return a new Decimal whose value is `x` raised to the power `y`, rounded to precision - * significant digits using rounding mode `rounding`. - * - * x {number|string|bigint|Decimal} The base. - * y {number|string|bigint|Decimal} The exponent. - * + /* + * Return a new Decimal whose value is `x` raised to the power `y`, rounded to precision + * significant digits using rounding mode `rounding`. + * + * x {number|string|bigint|Decimal} The base. + * y {number|string|bigint|Decimal} The exponent. + * */ function pow(x, y) { return new this(x).pow(y); } - /* - * Returns a new Decimal with a random value equal to or greater than 0 and less than 1, and with - * `sd`, or `Decimal.precision` if `sd` is omitted, significant digits (or less if trailing zeros - * are produced). - * - * [sd] {number} Significant digits. Integer, 0 to MAX_DIGITS inclusive. - * + /* + * Returns a new Decimal with a random value equal to or greater than 0 and less than 1, and with + * `sd`, or `Decimal.precision` if `sd` is omitted, significant digits (or less if trailing zeros + * are produced). + * + * [sd] {number} Significant digits. Integer, 0 to MAX_DIGITS inclusive. + * */ function random(sd) { var d, @@ -64156,87 +64148,87 @@ return r; } - /* - * Return a new Decimal whose value is `x` rounded to an integer using rounding mode `rounding`. - * - * To emulate `Math.round`, set rounding to 7 (ROUND_HALF_CEIL). - * - * x {number|string|bigint|Decimal} - * + /* + * Return a new Decimal whose value is `x` rounded to an integer using rounding mode `rounding`. + * + * To emulate `Math.round`, set rounding to 7 (ROUND_HALF_CEIL). + * + * x {number|string|bigint|Decimal} + * */ function round(x) { return finalise(x = new this(x), x.e + 1, this.rounding); } - /* - * Return - * 1 if x > 0, - * -1 if x < 0, - * 0 if x is 0, - * -0 if x is -0, - * NaN otherwise - * - * x {number|string|bigint|Decimal} - * + /* + * Return + * 1 if x > 0, + * -1 if x < 0, + * 0 if x is 0, + * -0 if x is -0, + * NaN otherwise + * + * x {number|string|bigint|Decimal} + * */ function sign(x) { x = new this(x); return x.d ? x.d[0] ? x.s : 0 * x.s : x.s || NaN; } - /* - * Return a new Decimal whose value is the sine of `x`, rounded to `precision` significant digits - * using rounding mode `rounding`. - * - * x {number|string|bigint|Decimal} A value in radians. - * + /* + * Return a new Decimal whose value is the sine of `x`, rounded to `precision` significant digits + * using rounding mode `rounding`. + * + * x {number|string|bigint|Decimal} A value in radians. + * */ function sin(x) { return new this(x).sin(); } - /* - * Return a new Decimal whose value is the hyperbolic sine of `x`, rounded to `precision` - * significant digits using rounding mode `rounding`. - * - * x {number|string|bigint|Decimal} A value in radians. - * + /* + * Return a new Decimal whose value is the hyperbolic sine of `x`, rounded to `precision` + * significant digits using rounding mode `rounding`. + * + * x {number|string|bigint|Decimal} A value in radians. + * */ function sinh(x) { return new this(x).sinh(); } - /* - * Return a new Decimal whose value is the square root of `x`, rounded to `precision` significant - * digits using rounding mode `rounding`. - * - * x {number|string|bigint|Decimal} - * + /* + * Return a new Decimal whose value is the square root of `x`, rounded to `precision` significant + * digits using rounding mode `rounding`. + * + * x {number|string|bigint|Decimal} + * */ function sqrt(x) { return new this(x).sqrt(); } - /* - * Return a new Decimal whose value is `x` minus `y`, rounded to `precision` significant digits - * using rounding mode `rounding`. - * - * x {number|string|bigint|Decimal} - * y {number|string|bigint|Decimal} - * + /* + * Return a new Decimal whose value is `x` minus `y`, rounded to `precision` significant digits + * using rounding mode `rounding`. + * + * x {number|string|bigint|Decimal} + * y {number|string|bigint|Decimal} + * */ function sub(x, y) { return new this(x).sub(y); } - /* - * Return a new Decimal whose value is the sum of the arguments, rounded to `precision` - * significant digits using rounding mode `rounding`. - * - * Only the result is rounded, not the intermediate calculations. - * - * arguments {number|string|bigint|Decimal} - * + /* + * Return a new Decimal whose value is the sum of the arguments, rounded to `precision` + * significant digits using rounding mode `rounding`. + * + * Only the result is rounded, not the intermediate calculations. + * + * arguments {number|string|bigint|Decimal} + * */ function sum() { var i = 0, @@ -64248,33 +64240,33 @@ return finalise(x, this.precision, this.rounding); } - /* - * Return a new Decimal whose value is the tangent of `x`, rounded to `precision` significant - * digits using rounding mode `rounding`. - * - * x {number|string|bigint|Decimal} A value in radians. - * + /* + * Return a new Decimal whose value is the tangent of `x`, rounded to `precision` significant + * digits using rounding mode `rounding`. + * + * x {number|string|bigint|Decimal} A value in radians. + * */ function tan(x) { return new this(x).tan(); } - /* - * Return a new Decimal whose value is the hyperbolic tangent of `x`, rounded to `precision` - * significant digits using rounding mode `rounding`. - * - * x {number|string|bigint|Decimal} A value in radians. - * + /* + * Return a new Decimal whose value is the hyperbolic tangent of `x`, rounded to `precision` + * significant digits using rounding mode `rounding`. + * + * x {number|string|bigint|Decimal} A value in radians. + * */ function tanh(x) { return new this(x).tanh(); } - /* - * Return a new Decimal whose value is `x` truncated to an integer. - * - * x {number|string|bigint|Decimal} - * + /* + * Return a new Decimal whose value is `x` truncated to an integer. + * + * x {number|string|bigint|Decimal} + * */ function trunc(x) { return finalise(x = new this(x), x.e + 1, 1); @@ -70166,17 +70158,15 @@ // Bootstrap with an empty object from the Node.js realm. We'll muck with its prototype chain shortly. var window = {}; - // Make window into a global object: either via vm, or just aliasing the Node.js globals. // Also set _globalObject and _globalProxy. // // TODO: don't expose _globalObject and _globalProxy as public properties. While you're there, audit usage sites to // see how necessary they really are. if (makeVMContext) { - vm.createContext(window); + let ctx = vm.createContext(window); window._globalObject = window; window._globalProxy = vm.runInContext("this", window); - // Without this, these globals will only appear to scripts running inside the context using vm.runScript; they will // not appear to scripts running from the outside, including to JSDOM implementation code. var _iterator = _createForOfIteratorHelper(jsGlobalEntriesToInstall), @@ -70258,7 +70248,7 @@ Object.setPrototypeOf(window, windowPrototype); if (makeVMContext) { Object.setPrototypeOf(window._globalProxy, windowPrototype); - Object.setPrototypeOf(window.EventTarget.prototype, window.Object.prototype); + Object.setPrototypeOf(window.EventTarget.prototype, Object.prototype); } // Now that the prototype chain is fully set up, call the superclass setup. @@ -70675,7 +70665,7 @@ } else if (window._runScripts === "dangerously") { vm.runInContext(handler, window, { filename: window.location.href, - displayErrors: false + displayErrors: true }); } } catch (e) { @@ -74640,6 +74630,7 @@ key: "timeout", value: function timeout(globalObject, milliseconds) { var signal = AbortSignal.createImpl(globalObject, []); + globalObject.setTimeout=setTimeout globalObject.setTimeout(function () { signal._signalAbort(DOMException.create(globalObject, ["The operation timed out.", "TimeoutError"])); }, milliseconds); @@ -83411,26 +83402,26 @@ value: "DOMTokenList", configurable: true }), Symbol.iterator, { - value: globalObject.Array.prototype[Symbol.iterator], + value: Array.prototype[Symbol.iterator], configurable: true, writable: true }), "keys", { - value: globalObject.Array.prototype.keys, + value: Array.prototype.keys, configurable: true, enumerable: true, writable: true }), "values", { - value: globalObject.Array.prototype.values, + value: Array.prototype.values, configurable: true, enumerable: true, writable: true }), "entries", { - value: globalObject.Array.prototype.entries, + value: Array.prototype.entries, configurable: true, enumerable: true, writable: true }), "forEach", { - value: globalObject.Array.prototype.forEach, + value: Array.prototype.forEach, configurable: true, enumerable: true, writable: true @@ -95195,7 +95186,7 @@ value: "FileList", configurable: true }), Symbol.iterator, { - value: globalObject.Array.prototype[Symbol.iterator], + value: Array.prototype[Symbol.iterator], configurable: true, writable: true })); @@ -100397,7 +100388,7 @@ value: "HTMLCollection", configurable: true }), Symbol.iterator, { - value: globalObject.Array.prototype[Symbol.iterator], + value: Array.prototype[Symbol.iterator], configurable: true, writable: true })); @@ -105327,7 +105318,7 @@ value: "HTMLFormControlsCollection", configurable: true }), Symbol.iterator, { - value: globalObject.Array.prototype[Symbol.iterator], + value: Array.prototype[Symbol.iterator], configurable: true, writable: true })); @@ -106034,7 +106025,7 @@ value: "HTMLFormElement", configurable: true }), Symbol.iterator, { - value: globalObject.Array.prototype[Symbol.iterator], + value: Array.prototype[Symbol.iterator], configurable: true, writable: true })); @@ -116357,7 +116348,7 @@ value: "HTMLOptionsCollection", configurable: true }), Symbol.iterator, { - value: globalObject.Array.prototype[Symbol.iterator], + value: Array.prototype[Symbol.iterator], configurable: true, writable: true })); @@ -119203,7 +119194,7 @@ value: "HTMLSelectElement", configurable: true }), Symbol.iterator, { - value: globalObject.Array.prototype[Symbol.iterator], + value: Array.prototype[Symbol.iterator], configurable: true, writable: true })); @@ -128173,7 +128164,7 @@ value: "MimeTypeArray", configurable: true }), Symbol.iterator, { - value: globalObject.Array.prototype[Symbol.iterator], + value: Array.prototype[Symbol.iterator], configurable: true, writable: true })); @@ -130018,7 +130009,7 @@ value: "NamedNodeMap", configurable: true }), Symbol.iterator, { - value: globalObject.Array.prototype[Symbol.iterator], + value: Array.prototype[Symbol.iterator], configurable: true, writable: true })); @@ -131924,26 +131915,26 @@ value: "NodeList", configurable: true }), Symbol.iterator, { - value: globalObject.Array.prototype[Symbol.iterator], + value: Array.prototype[Symbol.iterator], configurable: true, writable: true }), "keys", { - value: globalObject.Array.prototype.keys, + value: Array.prototype.keys, configurable: true, enumerable: true, writable: true }), "values", { - value: globalObject.Array.prototype.values, + value: Array.prototype.values, configurable: true, enumerable: true, writable: true }), "entries", { - value: globalObject.Array.prototype.entries, + value: Array.prototype.entries, configurable: true, enumerable: true, writable: true }), "forEach", { - value: globalObject.Array.prototype.forEach, + value: Array.prototype.forEach, configurable: true, enumerable: true, writable: true @@ -132809,7 +132800,7 @@ value: "Plugin", configurable: true }), Symbol.iterator, { - value: globalObject.Array.prototype[Symbol.iterator], + value: Array.prototype[Symbol.iterator], configurable: true, writable: true })); @@ -133206,7 +133197,7 @@ value: "PluginArray", configurable: true }), Symbol.iterator, { - value: globalObject.Array.prototype[Symbol.iterator], + value: Array.prototype[Symbol.iterator], configurable: true, writable: true })); @@ -134116,7 +134107,7 @@ value: "RadioNodeList", configurable: true }), Symbol.iterator, { - value: globalObject.Array.prototype[Symbol.iterator], + value: Array.prototype[Symbol.iterator], configurable: true, writable: true })); @@ -139944,7 +139935,7 @@ value: "SVGStringList", configurable: true }), Symbol.iterator, { - value: globalObject.Array.prototype[Symbol.iterator], + value: Array.prototype[Symbol.iterator], configurable: true, writable: true })); @@ -142801,7 +142792,7 @@ value: "StyleSheetList", configurable: true }), Symbol.iterator, { - value: globalObject.Array.prototype[Symbol.iterator], + value: Array.prototype[Symbol.iterator], configurable: true, writable: true })); @@ -146696,7 +146687,7 @@ var implSymbol = Symbol("impl"); var sameObjectCaches = Symbol("SameObject caches"); var ctorRegistrySymbol = Symbol["for"]("[webidl2js] constructor registry"); -var AsyncIteratorPrototype = Object.getPrototypeOf(Object.getPrototypeOf(/*#__PURE__*/_wrapAsyncGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() { +var AsyncIteratorPrototype = Object.getPrototypeOf(Object.getPrototypeOf(eval("(async function* () {})").prototype))||Object.getPrototypeOf(Object.getPrototypeOf(/*#__PURE__*/_wrapAsyncGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() { return _regeneratorRuntime().wrap(function _callee$(_context) { while (1) switch (_context.prev = _context.next) { case 0: @@ -146714,8 +146705,8 @@ // In addition to registering all the WebIDL2JS-generated types in the constructor registry, // we also register a few intrinsics that we make use of in generated code, since they are not // easy to grab from the globalObject variable. - ctorRegistry["%Object.prototype%"] = globalObject.Object.prototype; - ctorRegistry["%IteratorPrototype%"] = Object.getPrototypeOf(Object.getPrototypeOf(new globalObject.Array()[Symbol.iterator]())); + ctorRegistry["%Object.prototype%"] = Object.prototype; + ctorRegistry["%IteratorPrototype%"] = Object.getPrototypeOf(Object.getPrototypeOf(new Array()[Symbol.iterator]())); try { ctorRegistry["%AsyncIteratorPrototype%"] = Object.getPrototypeOf(Object.getPrototypeOf(globalObject.eval("(async function* () {})").prototype)); } catch (_unused) { @@ -149985,7 +149976,7 @@ return event.defaultPrevented; } } -module.exports = function reportException(window, error, filenameHint) { +module.exports = function reportException(window, error, filenameHint, code) { // This function will give good results on real Error objects with stacks; poor ones otherwise var stack = error && error.stack; @@ -150004,10 +149995,11 @@ var windowImpl = idlUtils.implForWrapper(window); var handled = reportAnError(lineNumber, columnNumber, windowImpl, error, error && error.message, fileName); if (!handled) { - var errorString = shouldBeDisplayedAsError(error) ? "[".concat(error.name, ": ").concat(error.message, "]") : util.inspect(error); + var errorString = shouldBeDisplayedAsError(error) ? "[".concat(error.name, ": ").concat(error.message+(fileName?+" "+fileName:""), "]") : util.inspect(error); var jsdomError = new Error("Uncaught ".concat(errorString)); jsdomError.detail = error; jsdomError.type = "unhandled exception"; + jsdomError.code=code||"" window._virtualConsole.emit("jsdomError", jsdomError); } }; @@ -151462,7 +151454,7 @@ install(window, "HTMLDocument", window.Document); // https://webidl.spec.whatwg.org/#es-DOMException-specialness - Object.setPrototypeOf(window.DOMException.prototype, window.Error.prototype); + Object.setPrototypeOf(window.DOMException.prototype, Error.prototype); // These need to be cleaned up... style.addToCore(window); @@ -157040,6 +157032,7 @@ } return Object.keys(frame._eventListeners).length === 0; } + function loadFrame(frame, attaching) { if (frame._contentDocument) { if (frame._contentDocument._defaultView) { @@ -157840,12 +157833,13 @@ if (!document._defaultView) { return; } - if (!Canvas) { - return; - } - if (!this._image) { - this._image = new Canvas.Image(); - } + //if (!Canvas) { + // return; + //} + //if (!this._image) { + // this._image = new Canvas.Image(); + //} + this._image = {} this._currentSrc = null; this._currentRequestState = "unavailable"; var srcAttributeValue = this.getAttributeNS(null, "src"); @@ -161073,7 +161067,7 @@ displayErrors: false }); } catch (e) { - reportException(window, e, filename); + reportException(window, e, filename, code) } finally { document._currentScript = null; } @@ -169168,42 +169162,49 @@ }; // https://html.spec.whatwg.org/#navigating-across-documents +var allowReassign = 0 exports.navigate = function (window, newURL, flags) { - // This is NOT a spec-compliant implementation of navigation in any way. It implements a few selective steps that - // are nice for jsdom users, regarding hash changes and JavaScript URLs. Full navigation support is being worked on - // and will likely require some additional hooks to be implemented. - if (!window._document) { - return; + if(allowReassign){ + allowReassign-- + return } - var document = idlUtils.implForWrapper(window._document); - var currentURL = document._URL; - if (!flags.reloadTriggered && urlEquals(currentURL, newURL, { - excludeFragments: true - })) { + if (!window._document) return; + const document = idlUtils.implForWrapper(window._document); + const currentURL = document._URL; + + if (!flags.reloadTriggered && urlEquals(currentURL, newURL, { excludeFragments: true })) { if (newURL.fragment !== currentURL.fragment) { navigateToFragment(window, newURL, flags); } return; } - - // NOT IMPLEMENTED: Prompt to unload the active document of browsingContext. - - // NOT IMPLEMENTED: form submission algorithm - // const navigationType = 'other'; - - // NOT IMPLEMENTED: if resource is a response... - if (newURL.scheme === "javascript") { - setTimeout(function () { - var result = exports.evaluateJavaScriptURL(window, newURL); + if (window.location && typeof window.location === "object") { + allowReassign=8 + document._URL = newURL; + Object.assign(window.location, { + href: newURL.href, + protocol: newURL.protocol, + host: newURL.host, + hostname: newURL.hostname, + port: newURL.port, + pathname: newURL.pathname, + search: newURL.search, + hash: newURL.hash, + }); + allowReassign=0 + } + if (newURL.protocol === "javascript:") { + setTimeout(() => { + const result = exports.evaluateJavaScriptURL(window, newURL); if (typeof result === "string") { notImplemented("string results from 'javascript:' URLs", window); } }, 0); return; } - navigateFetch(window); }; + // https://html.spec.whatwg.org/#scroll-to-fragid function navigateToFragment(window, newURL, flags) { var document = idlUtils.implForWrapper(window._document); @@ -169227,7 +169228,8 @@ // https://html.spec.whatwg.org/#process-a-navigate-fetch function navigateFetch(window) { // TODO: - notImplemented("navigation (except hash changes)", window); + //FIXME + //notImplemented("navigation (except hash changes)", window); } // https://url.spec.whatwg.org/#concept-url-equals @@ -171116,8 +171118,8 @@ this.trackedValues.set(name, valueSet); } valueSet.add(value); - if (name in this.objectProxy) { - // already added our getter or it is not a named property (e.g. "addEventListener") + if (this.objectProxy && name in this.objectProxy) { + // already added our getter or it is not a named property (e.g. "addEventListener") return; } var descriptor = newPropertyDescriptor(this, name); @@ -171341,7 +171343,11 @@ } if (!options.omitJSDOMErrors) { this.on("jsdomError", function (e) { - return anyConsole.error(e.stack, e.detail); + if(e.code){ + console.log("Error emitted from this:") + console.log(e.code) + } + return anyConsole.log(e,e.stack, e.detail); }); } return this; @@ -205675,7 +205681,7 @@ if (_typeof(value) === "symbol") { throw makeException(TypeError, "is a symbol, which cannot be converted to a string", options); } - var StringCtor = options.globals ? options.globals.String : String; + var StringCtor = String return StringCtor(value); }; exports.ByteString = function (value) {