source: imaps-frontend/node_modules/es-abstract/2023/Number/exponentiate.js@ 79a0317

main
Last change on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 1.7 KB
RevLine 
[d565449]1'use strict';
2
[79a0317]3// var isNegativeZero = require('math-intrinsics/isNegativeZero');
4var $pow = require('math-intrinsics/pow');
[d565449]5
6var $TypeError = require('es-errors/type');
7
8/*
[79a0317]9var abs = require('math-intrinsics/abs');
10var isFinite = require('math-intrinsics/isFinite');
11var isNaN = require('math-intrinsics/isNaN');
[d565449]12
[79a0317]13var IsInteger = require('math-intrinsics/isInteger');
[d565449]14*/
15
16// https://262.ecma-international.org/11.0/#sec-numeric-types-number-exponentiate
17
18/* eslint max-lines-per-function: 0, max-statements: 0 */
19
20module.exports = function NumberExponentiate(base, exponent) {
21 if (typeof base !== 'number' || typeof exponent !== 'number') {
22 throw new $TypeError('Assertion failed: `base` and `exponent` arguments must be Numbers');
23 }
24 return $pow(base, exponent);
25 /*
26 if (isNaN(exponent)) {
27 return NaN;
28 }
29 if (exponent === 0) {
30 return 1;
31 }
32 if (isNaN(base)) {
33 return NaN;
34 }
35 var aB = abs(base);
36 if (aB > 1 && exponent === Infinity) {
37 return Infinity;
38 }
39 if (aB > 1 && exponent === -Infinity) {
40 return 0;
41 }
42 if (aB === 1 && (exponent === Infinity || exponent === -Infinity)) {
43 return NaN;
44 }
45 if (aB < 1 && exponent === Infinity) {
46 return +0;
47 }
48 if (aB < 1 && exponent === -Infinity) {
49 return Infinity;
50 }
51 if (base === Infinity) {
52 return exponent > 0 ? Infinity : 0;
53 }
54 if (base === -Infinity) {
55 var isOdd = true;
56 if (exponent > 0) {
57 return isOdd ? -Infinity : Infinity;
58 }
59 return isOdd ? -0 : 0;
60 }
61 if (exponent > 0) {
62 return isNegativeZero(base) ? Infinity : 0;
63 }
64 if (isNegativeZero(base)) {
65 if (exponent > 0) {
66 return isOdd ? -0 : 0;
67 }
68 return isOdd ? -Infinity : Infinity;
69 }
70 if (base < 0 && isFinite(base) && isFinite(exponent) && !IsInteger(exponent)) {
71 return NaN;
72 }
73 */
74};
Note: See TracBrowser for help on using the repository browser.