superjs-core 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/async/index.js.map +1 -1
- package/dist/collection/index.js.map +1 -1
- package/dist/core/index.js.map +1 -1
- package/dist/crypto/index.js.map +1 -1
- package/dist/date/index.js.map +1 -1
- package/dist/dep-exray/analyzer/index.d.ts +7 -0
- package/dist/dep-exray/analyzer/index.js +68 -0
- package/dist/dep-exray/analyzer/index.js.map +1 -0
- package/dist/dep-exray/cli.d.ts +1 -0
- package/dist/dep-exray/cli.js +389 -0
- package/dist/dep-exray/cli.js.map +1 -0
- package/dist/dep-exray/index.d.ts +5 -0
- package/dist/dep-exray/index.js +440 -0
- package/dist/dep-exray/index.js.map +1 -0
- package/dist/dep-exray/known-mappings.d.ts +17 -0
- package/dist/dep-exray/known-mappings.js +122 -0
- package/dist/dep-exray/known-mappings.js.map +1 -0
- package/dist/dep-exray/reporter/index.d.ts +5 -0
- package/dist/dep-exray/reporter/index.js +75 -0
- package/dist/dep-exray/reporter/index.js.map +1 -0
- package/dist/dep-exray/scanner/index.d.ts +5 -0
- package/dist/dep-exray/scanner/index.js +299 -0
- package/dist/dep-exray/scanner/index.js.map +1 -0
- package/dist/dep-exray/types.d.ts +38 -0
- package/dist/dep-exray/types.js +1 -0
- package/dist/dep-exray/types.js.map +1 -0
- package/dist/index.d.ts +6 -1
- package/dist/index.js +439 -814
- package/dist/index.js.map +1 -1
- package/dist/io/index.js.map +1 -1
- package/dist/math/index.d.ts +1 -664
- package/dist/math/index.js +1 -822
- package/dist/math/index.js.map +1 -1
- package/dist/path/index.js.map +1 -1
- package/dist/string/index.js.map +1 -1
- package/dist/type/index.js.map +1 -1
- package/package.json +44 -4
package/dist/index.js
CHANGED
|
@@ -346,753 +346,6 @@ function randomInt(min, max) {
|
|
|
346
346
|
function inRange(value, min, max) {
|
|
347
347
|
return value >= min && value <= max;
|
|
348
348
|
}
|
|
349
|
-
function toDegrees(radians) {
|
|
350
|
-
return radians * (180 / Math.PI);
|
|
351
|
-
}
|
|
352
|
-
function toRadians(degrees) {
|
|
353
|
-
return degrees * (Math.PI / 180);
|
|
354
|
-
}
|
|
355
|
-
function sin(angle, unit = "rad") {
|
|
356
|
-
const rad = unit === "deg" ? toRadians(angle) : angle;
|
|
357
|
-
return Math.sin(rad);
|
|
358
|
-
}
|
|
359
|
-
function cos(angle, unit = "rad") {
|
|
360
|
-
const rad = unit === "deg" ? toRadians(angle) : angle;
|
|
361
|
-
return Math.cos(rad);
|
|
362
|
-
}
|
|
363
|
-
function tan(angle, unit = "rad") {
|
|
364
|
-
const rad = unit === "deg" ? toRadians(angle) : angle;
|
|
365
|
-
return Math.tan(rad);
|
|
366
|
-
}
|
|
367
|
-
function asin(value) {
|
|
368
|
-
if (value < -1 || value > 1) {
|
|
369
|
-
throw new RangeError("Input to asin must be between -1 and 1");
|
|
370
|
-
}
|
|
371
|
-
return Math.asin(value);
|
|
372
|
-
}
|
|
373
|
-
function acos(value) {
|
|
374
|
-
if (value < -1 || value > 1) {
|
|
375
|
-
throw new RangeError("Input to acos must be between -1 and 1");
|
|
376
|
-
}
|
|
377
|
-
return Math.acos(value);
|
|
378
|
-
}
|
|
379
|
-
function atan(value) {
|
|
380
|
-
return Math.atan(value);
|
|
381
|
-
}
|
|
382
|
-
function atan2(y, x) {
|
|
383
|
-
return Math.atan2(y, x);
|
|
384
|
-
}
|
|
385
|
-
function hypot(...values) {
|
|
386
|
-
return Math.hypot(...values);
|
|
387
|
-
}
|
|
388
|
-
function median(values) {
|
|
389
|
-
if (values.length === 0) {
|
|
390
|
-
throw new RangeError("Cannot compute median of an empty array");
|
|
391
|
-
}
|
|
392
|
-
const sorted = [...values].sort((a, b) => a - b);
|
|
393
|
-
const mid = Math.floor(sorted.length / 2);
|
|
394
|
-
if (sorted.length % 2 === 0) {
|
|
395
|
-
return (sorted[mid - 1] + sorted[mid]) / 2;
|
|
396
|
-
}
|
|
397
|
-
return sorted[mid];
|
|
398
|
-
}
|
|
399
|
-
function mode(values) {
|
|
400
|
-
if (values.length === 0) {
|
|
401
|
-
throw new RangeError("Cannot compute mode of an empty array");
|
|
402
|
-
}
|
|
403
|
-
const freq = /* @__PURE__ */ new Map();
|
|
404
|
-
let maxFreq = 0;
|
|
405
|
-
for (const v of values) {
|
|
406
|
-
const f = (freq.get(v) ?? 0) + 1;
|
|
407
|
-
freq.set(v, f);
|
|
408
|
-
if (f > maxFreq) maxFreq = f;
|
|
409
|
-
}
|
|
410
|
-
if (maxFreq === 1) return [];
|
|
411
|
-
return Array.from(freq.entries()).filter(([, f]) => f === maxFreq).map(([v]) => v).sort((a, b) => a - b);
|
|
412
|
-
}
|
|
413
|
-
function percentile(values, p) {
|
|
414
|
-
if (values.length === 0) {
|
|
415
|
-
throw new RangeError("Cannot compute percentile of an empty array");
|
|
416
|
-
}
|
|
417
|
-
if (p < 0 || p > 100) {
|
|
418
|
-
throw new RangeError("Percentile must be between 0 and 100");
|
|
419
|
-
}
|
|
420
|
-
const sorted = [...values].sort((a, b) => a - b);
|
|
421
|
-
const index = p / 100 * (sorted.length - 1);
|
|
422
|
-
const lower = Math.floor(index);
|
|
423
|
-
const upper = Math.ceil(index);
|
|
424
|
-
if (lower === upper) return sorted[lower];
|
|
425
|
-
return sorted[lower] + (sorted[upper] - sorted[lower]) * (index - lower);
|
|
426
|
-
}
|
|
427
|
-
function quartiles(values) {
|
|
428
|
-
if (values.length === 0) {
|
|
429
|
-
throw new RangeError("Cannot compute quartiles of an empty array");
|
|
430
|
-
}
|
|
431
|
-
const sorted = [...values].sort((a, b) => a - b);
|
|
432
|
-
if (sorted.length === 1) {
|
|
433
|
-
return { q1: sorted[0], q2: sorted[0], q3: sorted[0] };
|
|
434
|
-
}
|
|
435
|
-
const q2 = median(sorted);
|
|
436
|
-
const mid = Math.floor(sorted.length / 2);
|
|
437
|
-
const lowerHalf = sorted.slice(0, mid);
|
|
438
|
-
const upperHalf = sorted.length % 2 === 0 ? sorted.slice(mid) : sorted.slice(mid + 1);
|
|
439
|
-
return {
|
|
440
|
-
q1: median(lowerHalf),
|
|
441
|
-
q2,
|
|
442
|
-
q3: median(upperHalf)
|
|
443
|
-
};
|
|
444
|
-
}
|
|
445
|
-
function variance(values, sample2 = false) {
|
|
446
|
-
if (values.length === 0) {
|
|
447
|
-
throw new RangeError("Cannot compute variance of an empty array");
|
|
448
|
-
}
|
|
449
|
-
if (sample2 && values.length < 2) {
|
|
450
|
-
throw new RangeError("Sample variance requires at least 2 values");
|
|
451
|
-
}
|
|
452
|
-
const mean = average(values);
|
|
453
|
-
const sqDiffs = values.map((v) => (v - mean) ** 2);
|
|
454
|
-
const divisor = sample2 ? values.length - 1 : values.length;
|
|
455
|
-
return sum(sqDiffs) / divisor;
|
|
456
|
-
}
|
|
457
|
-
function stddev(values, sample2 = false) {
|
|
458
|
-
return Math.sqrt(variance(values, sample2));
|
|
459
|
-
}
|
|
460
|
-
function covariance(x, y) {
|
|
461
|
-
if (x.length !== y.length) {
|
|
462
|
-
throw new RangeError("Arrays must have the same length");
|
|
463
|
-
}
|
|
464
|
-
if (x.length < 2) {
|
|
465
|
-
throw new RangeError("Covariance requires at least 2 values");
|
|
466
|
-
}
|
|
467
|
-
const meanX = average(x);
|
|
468
|
-
const meanY = average(y);
|
|
469
|
-
let total = 0;
|
|
470
|
-
for (let i = 0; i < x.length; i++) {
|
|
471
|
-
total += (x[i] - meanX) * (y[i] - meanY);
|
|
472
|
-
}
|
|
473
|
-
return total / (x.length - 1);
|
|
474
|
-
}
|
|
475
|
-
function correlation(x, y) {
|
|
476
|
-
const cov = covariance(x, y);
|
|
477
|
-
const stdX = stddev(x, true);
|
|
478
|
-
const stdY = stddev(y, true);
|
|
479
|
-
if (stdX === 0 || stdY === 0) return 0;
|
|
480
|
-
return cov / (stdX * stdY);
|
|
481
|
-
}
|
|
482
|
-
function skewness(values) {
|
|
483
|
-
if (values.length < 3) {
|
|
484
|
-
throw new RangeError("Skewness requires at least 3 values");
|
|
485
|
-
}
|
|
486
|
-
const mean = average(values);
|
|
487
|
-
const n = values.length;
|
|
488
|
-
const m2 = sum(values.map((v) => (v - mean) ** 2)) / n;
|
|
489
|
-
const m3 = sum(values.map((v) => (v - mean) ** 3)) / n;
|
|
490
|
-
if (m2 === 0) return 0;
|
|
491
|
-
return m3 / Math.pow(m2, 1.5) * Math.sqrt(n * (n - 1)) / (n - 2);
|
|
492
|
-
}
|
|
493
|
-
function kurtosis(values) {
|
|
494
|
-
if (values.length < 4) {
|
|
495
|
-
throw new RangeError("Kurtosis requires at least 4 values");
|
|
496
|
-
}
|
|
497
|
-
const mean = average(values);
|
|
498
|
-
const n = values.length;
|
|
499
|
-
const m2 = sum(values.map((v) => (v - mean) ** 2)) / n;
|
|
500
|
-
const m4 = sum(values.map((v) => (v - mean) ** 4)) / n;
|
|
501
|
-
if (m2 === 0) return 0;
|
|
502
|
-
const kurt = m4 / (m2 * m2);
|
|
503
|
-
const adjustment = (n - 1) * (n + 1) / ((n - 2) * (n - 3));
|
|
504
|
-
return adjustment * (kurt - 3 * (n - 1) / (n + 1));
|
|
505
|
-
}
|
|
506
|
-
function weightedMean(values, weights) {
|
|
507
|
-
if (values.length !== weights.length) {
|
|
508
|
-
throw new RangeError("Values and weights must have the same length");
|
|
509
|
-
}
|
|
510
|
-
if (values.length === 0) {
|
|
511
|
-
throw new RangeError("Cannot compute weighted mean of empty arrays");
|
|
512
|
-
}
|
|
513
|
-
const totalWeight = sum(weights);
|
|
514
|
-
if (totalWeight === 0) {
|
|
515
|
-
throw new RangeError("Sum of weights cannot be zero");
|
|
516
|
-
}
|
|
517
|
-
let total = 0;
|
|
518
|
-
for (let i = 0; i < values.length; i++) {
|
|
519
|
-
total += values[i] * weights[i];
|
|
520
|
-
}
|
|
521
|
-
return total / totalWeight;
|
|
522
|
-
}
|
|
523
|
-
function geometricMean(values) {
|
|
524
|
-
if (values.length === 0) {
|
|
525
|
-
throw new RangeError("Cannot compute geometric mean of an empty array");
|
|
526
|
-
}
|
|
527
|
-
if (values.some((v) => v <= 0)) {
|
|
528
|
-
throw new RangeError("Geometric mean requires positive values only");
|
|
529
|
-
}
|
|
530
|
-
const logSum = sum(values.map((v) => Math.log(v)));
|
|
531
|
-
return Math.exp(logSum / values.length);
|
|
532
|
-
}
|
|
533
|
-
function harmonicMean(values) {
|
|
534
|
-
if (values.length === 0) {
|
|
535
|
-
throw new RangeError("Cannot compute harmonic mean of an empty array");
|
|
536
|
-
}
|
|
537
|
-
if (values.some((v) => v <= 0)) {
|
|
538
|
-
throw new RangeError("Harmonic mean requires positive values only");
|
|
539
|
-
}
|
|
540
|
-
const reciprocalSum = sum(values.map((v) => 1 / v));
|
|
541
|
-
return values.length / reciprocalSum;
|
|
542
|
-
}
|
|
543
|
-
function zScore(value, mean, stddev2) {
|
|
544
|
-
if (stddev2 === 0) return 0;
|
|
545
|
-
return (value - mean) / stddev2;
|
|
546
|
-
}
|
|
547
|
-
function standardize(values) {
|
|
548
|
-
if (values.length === 0) return [];
|
|
549
|
-
const mean = average(values);
|
|
550
|
-
const sd = stddev(values, true);
|
|
551
|
-
if (sd === 0) return values.map(() => 0);
|
|
552
|
-
return values.map((v) => (v - mean) / sd);
|
|
553
|
-
}
|
|
554
|
-
function factorial(n) {
|
|
555
|
-
if (!Number.isInteger(n) || n < 0) {
|
|
556
|
-
throw new RangeError("Factorial requires a non-negative integer");
|
|
557
|
-
}
|
|
558
|
-
if (n === 0 || n === 1) return 1;
|
|
559
|
-
let result = 1;
|
|
560
|
-
for (let i = 2; i <= n; i++) {
|
|
561
|
-
result *= i;
|
|
562
|
-
}
|
|
563
|
-
return result;
|
|
564
|
-
}
|
|
565
|
-
function binomial(n, k) {
|
|
566
|
-
if (!Number.isInteger(n) || !Number.isInteger(k) || n < 0 || k < 0) {
|
|
567
|
-
throw new RangeError("Binomial requires non-negative integers");
|
|
568
|
-
}
|
|
569
|
-
if (k > n) {
|
|
570
|
-
throw new RangeError("k cannot be greater than n");
|
|
571
|
-
}
|
|
572
|
-
if (k === 0 || k === n) return 1;
|
|
573
|
-
if (k > n - k) return binomial(n, n - k);
|
|
574
|
-
let result = 1;
|
|
575
|
-
for (let i = 1; i <= k; i++) {
|
|
576
|
-
result = result * (n - k + i) / i;
|
|
577
|
-
}
|
|
578
|
-
return result;
|
|
579
|
-
}
|
|
580
|
-
function permutation(n, k) {
|
|
581
|
-
if (!Number.isInteger(n) || !Number.isInteger(k) || n < 0 || k < 0) {
|
|
582
|
-
throw new RangeError("Permutation requires non-negative integers");
|
|
583
|
-
}
|
|
584
|
-
if (k > n) {
|
|
585
|
-
throw new RangeError("k cannot be greater than n");
|
|
586
|
-
}
|
|
587
|
-
let result = 1;
|
|
588
|
-
for (let i = n; i > n - k; i--) {
|
|
589
|
-
result *= i;
|
|
590
|
-
}
|
|
591
|
-
return result;
|
|
592
|
-
}
|
|
593
|
-
function gcd(...values) {
|
|
594
|
-
if (values.length < 2) {
|
|
595
|
-
throw new RangeError("GCD requires at least 2 values");
|
|
596
|
-
}
|
|
597
|
-
const gcd2 = (a, b) => {
|
|
598
|
-
a = Math.abs(a);
|
|
599
|
-
b = Math.abs(b);
|
|
600
|
-
while (b !== 0) {
|
|
601
|
-
const t = b;
|
|
602
|
-
b = a % b;
|
|
603
|
-
a = t;
|
|
604
|
-
}
|
|
605
|
-
return a;
|
|
606
|
-
};
|
|
607
|
-
return values.reduce((a, b) => gcd2(a, b));
|
|
608
|
-
}
|
|
609
|
-
function lcm(...values) {
|
|
610
|
-
if (values.length < 2) {
|
|
611
|
-
throw new RangeError("LCM requires at least 2 values");
|
|
612
|
-
}
|
|
613
|
-
const lcm2 = (a, b) => {
|
|
614
|
-
if (a === 0 || b === 0) return 0;
|
|
615
|
-
return Math.abs(a * b) / gcd(a, b);
|
|
616
|
-
};
|
|
617
|
-
return values.reduce((a, b) => lcm2(a, b));
|
|
618
|
-
}
|
|
619
|
-
function isPrime(n) {
|
|
620
|
-
if (!Number.isInteger(n) || n < 2) return false;
|
|
621
|
-
if (n === 2) return true;
|
|
622
|
-
if (n % 2 === 0) return false;
|
|
623
|
-
const sqrt = Math.sqrt(n);
|
|
624
|
-
for (let i = 3; i <= sqrt; i += 2) {
|
|
625
|
-
if (n % i === 0) return false;
|
|
626
|
-
}
|
|
627
|
-
return true;
|
|
628
|
-
}
|
|
629
|
-
function primeFactors(n) {
|
|
630
|
-
if (!Number.isInteger(n) || n < 2) {
|
|
631
|
-
throw new RangeError("Prime factors require an integer greater than 1");
|
|
632
|
-
}
|
|
633
|
-
const factors = [];
|
|
634
|
-
let num = n;
|
|
635
|
-
while (num % 2 === 0) {
|
|
636
|
-
factors.push(2);
|
|
637
|
-
num /= 2;
|
|
638
|
-
}
|
|
639
|
-
for (let i = 3; i <= Math.sqrt(num); i += 2) {
|
|
640
|
-
while (num % i === 0) {
|
|
641
|
-
factors.push(i);
|
|
642
|
-
num /= i;
|
|
643
|
-
}
|
|
644
|
-
}
|
|
645
|
-
if (num > 1) factors.push(num);
|
|
646
|
-
return factors;
|
|
647
|
-
}
|
|
648
|
-
function fibonacci(n) {
|
|
649
|
-
if (!Number.isInteger(n) || n < 0) {
|
|
650
|
-
throw new RangeError("Fibonacci requires a non-negative integer");
|
|
651
|
-
}
|
|
652
|
-
if (n === 0) return 0;
|
|
653
|
-
if (n === 1) return 1;
|
|
654
|
-
let a = 0;
|
|
655
|
-
let b = 1;
|
|
656
|
-
for (let i = 2; i <= n; i++) {
|
|
657
|
-
const temp = a + b;
|
|
658
|
-
a = b;
|
|
659
|
-
b = temp;
|
|
660
|
-
}
|
|
661
|
-
return b;
|
|
662
|
-
}
|
|
663
|
-
function isEven(n) {
|
|
664
|
-
return n % 2 === 0;
|
|
665
|
-
}
|
|
666
|
-
function isOdd(n) {
|
|
667
|
-
return n % 2 !== 0;
|
|
668
|
-
}
|
|
669
|
-
function sign(n) {
|
|
670
|
-
if (n > 0) return 1;
|
|
671
|
-
if (n < 0) return -1;
|
|
672
|
-
return 0;
|
|
673
|
-
}
|
|
674
|
-
function validateMatrix(a) {
|
|
675
|
-
if (a.length === 0) throw new RangeError("Matrix cannot be empty");
|
|
676
|
-
const cols = a[0].length;
|
|
677
|
-
if (cols === 0) throw new RangeError("Matrix rows cannot be empty");
|
|
678
|
-
if (a.some((row) => row.length !== cols)) {
|
|
679
|
-
throw new RangeError("All rows must have the same length");
|
|
680
|
-
}
|
|
681
|
-
}
|
|
682
|
-
function matrixAdd(a, b) {
|
|
683
|
-
if (a.length !== b.length || a[0].length !== b[0].length) {
|
|
684
|
-
throw new RangeError("Matrices must have same dimensions for addition");
|
|
685
|
-
}
|
|
686
|
-
validateMatrix(a);
|
|
687
|
-
return a.map((row, i) => row.map((val, j) => val + b[i][j]));
|
|
688
|
-
}
|
|
689
|
-
function matrixSub(a, b) {
|
|
690
|
-
if (a.length !== b.length || a[0].length !== b[0].length) {
|
|
691
|
-
throw new RangeError("Matrices must have same dimensions for subtraction");
|
|
692
|
-
}
|
|
693
|
-
validateMatrix(a);
|
|
694
|
-
return a.map((row, i) => row.map((val, j) => val - b[i][j]));
|
|
695
|
-
}
|
|
696
|
-
function matrixMul(a, b) {
|
|
697
|
-
if (a.length !== b.length || a[0].length !== b[0].length) {
|
|
698
|
-
throw new RangeError("Matrices must have same dimensions for element-wise multiplication");
|
|
699
|
-
}
|
|
700
|
-
validateMatrix(a);
|
|
701
|
-
return a.map((row, i) => row.map((val, j) => val * b[i][j]));
|
|
702
|
-
}
|
|
703
|
-
function matrixScale(a, scalar) {
|
|
704
|
-
validateMatrix(a);
|
|
705
|
-
return a.map((row) => row.map((val) => val * scalar));
|
|
706
|
-
}
|
|
707
|
-
function matrixTranspose(a) {
|
|
708
|
-
if (a.length === 0) return [];
|
|
709
|
-
validateMatrix(a);
|
|
710
|
-
return a[0].map((_, j) => a.map((row) => row[j]));
|
|
711
|
-
}
|
|
712
|
-
function matrixDeterminant(a) {
|
|
713
|
-
validateMatrix(a);
|
|
714
|
-
const n = a.length;
|
|
715
|
-
if (a.some((row) => row.length !== n)) {
|
|
716
|
-
throw new RangeError("Matrix must be square for determinant");
|
|
717
|
-
}
|
|
718
|
-
if (n > 3) {
|
|
719
|
-
throw new RangeError("Determinant only supported for max 3x3 matrices");
|
|
720
|
-
}
|
|
721
|
-
if (n === 1) return a[0][0];
|
|
722
|
-
if (n === 2) return a[0][0] * a[1][1] - a[0][1] * a[1][0];
|
|
723
|
-
const [a00, a01, a02] = a[0];
|
|
724
|
-
const [a10, a11, a12] = a[1];
|
|
725
|
-
const [a20, a21, a22] = a[2];
|
|
726
|
-
return a00 * (a11 * a22 - a12 * a21) - a01 * (a10 * a22 - a12 * a20) + a02 * (a10 * a21 - a11 * a20);
|
|
727
|
-
}
|
|
728
|
-
function matrixInverse(a) {
|
|
729
|
-
const det = matrixDeterminant(a);
|
|
730
|
-
if (det === 0) throw new RangeError("Matrix is singular and cannot be inverted");
|
|
731
|
-
const n = a.length;
|
|
732
|
-
if (n === 1) return [[1 / a[0][0]]];
|
|
733
|
-
if (n === 2) {
|
|
734
|
-
return [
|
|
735
|
-
[a[1][1] / det, -a[0][1] / det],
|
|
736
|
-
[-a[1][0] / det, a[0][0] / det]
|
|
737
|
-
];
|
|
738
|
-
}
|
|
739
|
-
const [a00, a01, a02] = a[0];
|
|
740
|
-
const [a10, a11, a12] = a[1];
|
|
741
|
-
const [a20, a21, a22] = a[2];
|
|
742
|
-
return [
|
|
743
|
-
[(a11 * a22 - a12 * a21) / det, -(a01 * a22 - a02 * a21) / det, (a01 * a12 - a02 * a11) / det],
|
|
744
|
-
[-(a10 * a22 - a12 * a20) / det, (a00 * a22 - a02 * a20) / det, -(a00 * a12 - a02 * a10) / det],
|
|
745
|
-
[(a10 * a21 - a11 * a20) / det, -(a00 * a21 - a01 * a20) / det, (a00 * a11 - a01 * a10) / det]
|
|
746
|
-
];
|
|
747
|
-
}
|
|
748
|
-
function matrixIdentity(n) {
|
|
749
|
-
if (!Number.isInteger(n) || n < 1) {
|
|
750
|
-
throw new RangeError("Matrix size must be a positive integer");
|
|
751
|
-
}
|
|
752
|
-
return Array.from(
|
|
753
|
-
{ length: n },
|
|
754
|
-
(_, i) => Array.from({ length: n }, (_2, j) => i === j ? 1 : 0)
|
|
755
|
-
);
|
|
756
|
-
}
|
|
757
|
-
function matrixMultiply(a, b) {
|
|
758
|
-
validateMatrix(a);
|
|
759
|
-
validateMatrix(b);
|
|
760
|
-
if (a[0].length !== b.length) {
|
|
761
|
-
throw new RangeError("Matrix dimensions incompatible for multiplication");
|
|
762
|
-
}
|
|
763
|
-
const result = Array.from(
|
|
764
|
-
{ length: a.length },
|
|
765
|
-
() => Array(b[0].length).fill(0)
|
|
766
|
-
);
|
|
767
|
-
for (let i = 0; i < a.length; i++) {
|
|
768
|
-
for (let j = 0; j < b[0].length; j++) {
|
|
769
|
-
for (let k = 0; k < b.length; k++) {
|
|
770
|
-
result[i][j] = (result[i][j] ?? 0) + (a[i][k] ?? 0) * (b[k][j] ?? 0);
|
|
771
|
-
}
|
|
772
|
-
}
|
|
773
|
-
}
|
|
774
|
-
return result;
|
|
775
|
-
}
|
|
776
|
-
function matrixTrace(a) {
|
|
777
|
-
validateMatrix(a);
|
|
778
|
-
const n = a.length;
|
|
779
|
-
if (a.some((row) => row.length !== n)) {
|
|
780
|
-
throw new RangeError("Matrix must be square for trace");
|
|
781
|
-
}
|
|
782
|
-
let trace = 0;
|
|
783
|
-
for (let i = 0; i < n; i++) {
|
|
784
|
-
trace += a[i][i];
|
|
785
|
-
}
|
|
786
|
-
return trace;
|
|
787
|
-
}
|
|
788
|
-
var Complex = class _Complex {
|
|
789
|
-
constructor(re, im = 0) {
|
|
790
|
-
this.re = re;
|
|
791
|
-
this.im = im;
|
|
792
|
-
}
|
|
793
|
-
re;
|
|
794
|
-
im;
|
|
795
|
-
/**
|
|
796
|
-
* Adds another complex number.
|
|
797
|
-
*
|
|
798
|
-
* @param other - The complex number to add.
|
|
799
|
-
* @returns A new Complex instance.
|
|
800
|
-
*/
|
|
801
|
-
add(other) {
|
|
802
|
-
return new _Complex(this.re + other.re, this.im + other.im);
|
|
803
|
-
}
|
|
804
|
-
/**
|
|
805
|
-
* Subtracts another complex number.
|
|
806
|
-
*
|
|
807
|
-
* @param other - The complex number to subtract.
|
|
808
|
-
* @returns A new Complex instance.
|
|
809
|
-
*/
|
|
810
|
-
sub(other) {
|
|
811
|
-
return new _Complex(this.re - other.re, this.im - other.im);
|
|
812
|
-
}
|
|
813
|
-
/**
|
|
814
|
-
* Multiplies by another complex number.
|
|
815
|
-
*
|
|
816
|
-
* @param other - The complex number to multiply by.
|
|
817
|
-
* @returns A new Complex instance.
|
|
818
|
-
*/
|
|
819
|
-
mul(other) {
|
|
820
|
-
return new _Complex(
|
|
821
|
-
this.re * other.re - this.im * other.im,
|
|
822
|
-
this.re * other.im + this.im * other.re
|
|
823
|
-
);
|
|
824
|
-
}
|
|
825
|
-
/**
|
|
826
|
-
* Divides by another complex number.
|
|
827
|
-
*
|
|
828
|
-
* @param other - The complex number to divide by.
|
|
829
|
-
* @returns A new Complex instance.
|
|
830
|
-
* @throws {DivisionByZeroError} If the divisor is zero.
|
|
831
|
-
*/
|
|
832
|
-
div(other) {
|
|
833
|
-
const denom = other.re * other.re + other.im * other.im;
|
|
834
|
-
if (denom === 0) throw new DivisionByZeroError();
|
|
835
|
-
return new _Complex(
|
|
836
|
-
(this.re * other.re + this.im * other.im) / denom,
|
|
837
|
-
(this.im * other.re - this.re * other.im) / denom
|
|
838
|
-
);
|
|
839
|
-
}
|
|
840
|
-
/**
|
|
841
|
-
* Computes the magnitude (absolute value) of the complex number.
|
|
842
|
-
*
|
|
843
|
-
* @returns The magnitude.
|
|
844
|
-
*/
|
|
845
|
-
abs() {
|
|
846
|
-
return Math.sqrt(this.re * this.re + this.im * this.im);
|
|
847
|
-
}
|
|
848
|
-
/**
|
|
849
|
-
* Computes the complex conjugate.
|
|
850
|
-
*
|
|
851
|
-
* @returns A new Complex instance with negated imaginary part.
|
|
852
|
-
*/
|
|
853
|
-
conj() {
|
|
854
|
-
return new _Complex(this.re, this.im === 0 ? 0 : -this.im);
|
|
855
|
-
}
|
|
856
|
-
/**
|
|
857
|
-
* Computes the argument (phase angle) in radians.
|
|
858
|
-
*
|
|
859
|
-
* @returns The phase angle.
|
|
860
|
-
*/
|
|
861
|
-
arg() {
|
|
862
|
-
return Math.atan2(this.im, this.re);
|
|
863
|
-
}
|
|
864
|
-
/**
|
|
865
|
-
* Raises the complex number to a real power.
|
|
866
|
-
*
|
|
867
|
-
* @param n - The exponent.
|
|
868
|
-
* @returns A new Complex instance.
|
|
869
|
-
*/
|
|
870
|
-
pow(n) {
|
|
871
|
-
const r = this.abs();
|
|
872
|
-
const theta = this.arg();
|
|
873
|
-
return _Complex.fromPolar(Math.pow(r, n), theta * n);
|
|
874
|
-
}
|
|
875
|
-
/**
|
|
876
|
-
* Computes the square root of the complex number.
|
|
877
|
-
*
|
|
878
|
-
* @returns A new Complex instance.
|
|
879
|
-
*/
|
|
880
|
-
sqrt() {
|
|
881
|
-
const r = this.abs();
|
|
882
|
-
const theta = this.arg();
|
|
883
|
-
return _Complex.fromPolar(Math.sqrt(r), theta / 2);
|
|
884
|
-
}
|
|
885
|
-
/**
|
|
886
|
-
* Computes e raised to this complex number.
|
|
887
|
-
*
|
|
888
|
-
* @returns A new Complex instance.
|
|
889
|
-
*/
|
|
890
|
-
exp() {
|
|
891
|
-
return new _Complex(
|
|
892
|
-
Math.exp(this.re) * Math.cos(this.im),
|
|
893
|
-
Math.exp(this.re) * Math.sin(this.im)
|
|
894
|
-
);
|
|
895
|
-
}
|
|
896
|
-
/**
|
|
897
|
-
* Computes the natural logarithm of the complex number.
|
|
898
|
-
*
|
|
899
|
-
* @returns A new Complex instance.
|
|
900
|
-
*/
|
|
901
|
-
log() {
|
|
902
|
-
return new _Complex(Math.log(this.abs()), this.arg());
|
|
903
|
-
}
|
|
904
|
-
/**
|
|
905
|
-
* Computes the sine of the complex number.
|
|
906
|
-
*
|
|
907
|
-
* @returns A new Complex instance.
|
|
908
|
-
*/
|
|
909
|
-
sin() {
|
|
910
|
-
return new _Complex(
|
|
911
|
-
Math.sin(this.re) * Math.cosh(this.im),
|
|
912
|
-
Math.cos(this.re) * Math.sinh(this.im)
|
|
913
|
-
);
|
|
914
|
-
}
|
|
915
|
-
/**
|
|
916
|
-
* Computes the cosine of the complex number.
|
|
917
|
-
*
|
|
918
|
-
* @returns A new Complex instance.
|
|
919
|
-
*/
|
|
920
|
-
cos() {
|
|
921
|
-
return new _Complex(
|
|
922
|
-
Math.cos(this.re) * Math.cosh(this.im),
|
|
923
|
-
-Math.sin(this.re) * Math.sinh(this.im)
|
|
924
|
-
);
|
|
925
|
-
}
|
|
926
|
-
/**
|
|
927
|
-
* Returns a string representation of the complex number.
|
|
928
|
-
*
|
|
929
|
-
* @returns String like "a + bi".
|
|
930
|
-
*/
|
|
931
|
-
toString() {
|
|
932
|
-
if (this.im === 0) return `${this.re}`;
|
|
933
|
-
if (this.re === 0) return `${this.im}i`;
|
|
934
|
-
if (this.im < 0) return `${this.re} - ${Math.abs(this.im)}i`;
|
|
935
|
-
return `${this.re} + ${this.im}i`;
|
|
936
|
-
}
|
|
937
|
-
/**
|
|
938
|
-
* Creates a complex number from polar coordinates.
|
|
939
|
-
*
|
|
940
|
-
* @param r - The magnitude.
|
|
941
|
-
* @param theta - The angle in radians.
|
|
942
|
-
* @returns A new Complex instance.
|
|
943
|
-
*/
|
|
944
|
-
static fromPolar(r, theta) {
|
|
945
|
-
return new _Complex(r * Math.cos(theta), r * Math.sin(theta));
|
|
946
|
-
}
|
|
947
|
-
/** The real part. */
|
|
948
|
-
get real() {
|
|
949
|
-
return this.re;
|
|
950
|
-
}
|
|
951
|
-
/** The imaginary part. */
|
|
952
|
-
get imag() {
|
|
953
|
-
return this.im;
|
|
954
|
-
}
|
|
955
|
-
};
|
|
956
|
-
function compoundInterest(principal, rate, time, n = 12) {
|
|
957
|
-
return principal * Math.pow(1 + rate / n, n * time);
|
|
958
|
-
}
|
|
959
|
-
function futureValue(pv, rate, nper) {
|
|
960
|
-
return pv * Math.pow(1 + rate, nper);
|
|
961
|
-
}
|
|
962
|
-
function presentValue(fv, rate, nper) {
|
|
963
|
-
return fv / Math.pow(1 + rate, nper);
|
|
964
|
-
}
|
|
965
|
-
function pmt(rate, nper, pv, fv = 0) {
|
|
966
|
-
if (rate === 0) return -(pv + fv) / nper;
|
|
967
|
-
const pvif = Math.pow(1 + rate, nper);
|
|
968
|
-
return -(pv * pvif + fv) / ((pvif - 1) / rate);
|
|
969
|
-
}
|
|
970
|
-
function npv(rate, cashflows) {
|
|
971
|
-
if (cashflows.length === 0) return 0;
|
|
972
|
-
let result = 0;
|
|
973
|
-
for (let i = 0; i < cashflows.length; i++) {
|
|
974
|
-
result += cashflows[i] / Math.pow(1 + rate, i);
|
|
975
|
-
}
|
|
976
|
-
return result;
|
|
977
|
-
}
|
|
978
|
-
function irr(cashflows) {
|
|
979
|
-
if (cashflows.length < 2) {
|
|
980
|
-
throw new RangeError("IRR requires at least 2 cashflows");
|
|
981
|
-
}
|
|
982
|
-
let guess = 0.1;
|
|
983
|
-
const tolerance = 1e-7;
|
|
984
|
-
const maxIter = 1e3;
|
|
985
|
-
for (let i = 0; i < maxIter; i++) {
|
|
986
|
-
let npvVal = 0;
|
|
987
|
-
let dnpv = 0;
|
|
988
|
-
for (let j = 0; j < cashflows.length; j++) {
|
|
989
|
-
npvVal += cashflows[j] / Math.pow(1 + guess, j);
|
|
990
|
-
dnpv -= j * cashflows[j] / Math.pow(1 + guess, j + 1);
|
|
991
|
-
}
|
|
992
|
-
if (Math.abs(npvVal) < tolerance) return guess;
|
|
993
|
-
if (dnpv === 0) return NaN;
|
|
994
|
-
guess -= npvVal / dnpv;
|
|
995
|
-
}
|
|
996
|
-
return NaN;
|
|
997
|
-
}
|
|
998
|
-
function roi(gain, cost) {
|
|
999
|
-
if (cost === 0) throw new RangeError("Cost cannot be zero");
|
|
1000
|
-
return (gain - cost) / cost;
|
|
1001
|
-
}
|
|
1002
|
-
function amortizationSchedule(principal, rate, nper) {
|
|
1003
|
-
const payment = -pmt(rate, nper, principal);
|
|
1004
|
-
let balance = principal;
|
|
1005
|
-
const schedule = [];
|
|
1006
|
-
for (let period = 1; period <= nper; period++) {
|
|
1007
|
-
const interest = balance * rate;
|
|
1008
|
-
const principalPart = payment - interest;
|
|
1009
|
-
balance -= principalPart;
|
|
1010
|
-
schedule.push({
|
|
1011
|
-
period,
|
|
1012
|
-
payment: Math.round(payment * 100) / 100,
|
|
1013
|
-
interest: Math.round(interest * 100) / 100,
|
|
1014
|
-
principal: Math.round(principalPart * 100) / 100,
|
|
1015
|
-
balance: Math.round(Math.max(balance, 0) * 100) / 100
|
|
1016
|
-
});
|
|
1017
|
-
}
|
|
1018
|
-
return schedule;
|
|
1019
|
-
}
|
|
1020
|
-
function randomNormal(mean = 0, stddev2 = 1) {
|
|
1021
|
-
let u = 0;
|
|
1022
|
-
let v = 0;
|
|
1023
|
-
while (u === 0) u = Math.random();
|
|
1024
|
-
while (v === 0) v = Math.random();
|
|
1025
|
-
const z = Math.sqrt(-2 * Math.log(u)) * Math.cos(2 * Math.PI * v);
|
|
1026
|
-
return mean + z * stddev2;
|
|
1027
|
-
}
|
|
1028
|
-
function randomPoisson(lambda) {
|
|
1029
|
-
if (lambda <= 0) throw new RangeError("Lambda must be positive");
|
|
1030
|
-
const L = Math.exp(-lambda);
|
|
1031
|
-
let k = 0;
|
|
1032
|
-
let p = 1;
|
|
1033
|
-
do {
|
|
1034
|
-
k++;
|
|
1035
|
-
p *= Math.random();
|
|
1036
|
-
} while (p > L);
|
|
1037
|
-
return k - 1;
|
|
1038
|
-
}
|
|
1039
|
-
function randomBinomial(n, p) {
|
|
1040
|
-
if (!Number.isInteger(n) || n < 0) throw new RangeError("n must be a non-negative integer");
|
|
1041
|
-
if (p < 0 || p > 1) throw new RangeError("p must be between 0 and 1");
|
|
1042
|
-
let successes = 0;
|
|
1043
|
-
for (let i = 0; i < n; i++) {
|
|
1044
|
-
if (Math.random() < p) successes++;
|
|
1045
|
-
}
|
|
1046
|
-
return successes;
|
|
1047
|
-
}
|
|
1048
|
-
function randomExponential(lambda) {
|
|
1049
|
-
if (lambda <= 0) throw new RangeError("Lambda must be positive");
|
|
1050
|
-
return -Math.log(1 - Math.random()) / lambda;
|
|
1051
|
-
}
|
|
1052
|
-
function randomUniform(min = 0, max = 1) {
|
|
1053
|
-
return Math.random() * (max - min) + min;
|
|
1054
|
-
}
|
|
1055
|
-
function derivative(f, x, h = 1e-10) {
|
|
1056
|
-
return (f(x + h) - f(x - h)) / (2 * h);
|
|
1057
|
-
}
|
|
1058
|
-
function integral(f, a, b, n = 100) {
|
|
1059
|
-
if (n % 2 !== 0) {
|
|
1060
|
-
throw new RangeError("Number of subintervals must be even for Simpson's rule");
|
|
1061
|
-
}
|
|
1062
|
-
const h = (b - a) / n;
|
|
1063
|
-
let sum2 = f(a) + f(b);
|
|
1064
|
-
for (let i = 1; i < n; i++) {
|
|
1065
|
-
const x = a + i * h;
|
|
1066
|
-
sum2 += i % 2 === 0 ? 2 * f(x) : 4 * f(x);
|
|
1067
|
-
}
|
|
1068
|
-
return h / 3 * sum2;
|
|
1069
|
-
}
|
|
1070
|
-
function trapezoidal(f, a, b, n = 100) {
|
|
1071
|
-
const h = (b - a) / n;
|
|
1072
|
-
let sum2 = (f(a) + f(b)) / 2;
|
|
1073
|
-
for (let i = 1; i < n; i++) {
|
|
1074
|
-
sum2 += f(a + i * h);
|
|
1075
|
-
}
|
|
1076
|
-
return h * sum2;
|
|
1077
|
-
}
|
|
1078
|
-
function newtonRoot(f, guess, tolerance = 1e-7, maxIter = 100) {
|
|
1079
|
-
let x = guess;
|
|
1080
|
-
for (let i = 0; i < maxIter; i++) {
|
|
1081
|
-
const fx = f(x);
|
|
1082
|
-
if (Math.abs(fx) < tolerance) return x;
|
|
1083
|
-
const df = derivative(f, x);
|
|
1084
|
-
if (df === 0) return NaN;
|
|
1085
|
-
x -= fx / df;
|
|
1086
|
-
}
|
|
1087
|
-
return NaN;
|
|
1088
|
-
}
|
|
1089
|
-
function lerp(a, b, t) {
|
|
1090
|
-
return a + (b - a) * t;
|
|
1091
|
-
}
|
|
1092
|
-
function mapRange(value, inMin, inMax, outMin, outMax) {
|
|
1093
|
-
if (inMax === inMin) throw new RangeError("Input range cannot be zero");
|
|
1094
|
-
return (value - inMin) / (inMax - inMin) * (outMax - outMin) + outMin;
|
|
1095
|
-
}
|
|
1096
349
|
|
|
1097
350
|
// src/date/index.ts
|
|
1098
351
|
var InvalidDateError = class extends Error {
|
|
@@ -2112,29 +1365,458 @@ function getType2(value) {
|
|
|
2112
1365
|
if (value instanceof Promise) return "promise";
|
|
2113
1366
|
return "object";
|
|
2114
1367
|
}
|
|
1368
|
+
|
|
1369
|
+
// src/dep-exray/scanner/index.ts
|
|
1370
|
+
import { readFileSync, readdirSync, existsSync } from "fs";
|
|
1371
|
+
import { join as join2, basename as basename2 } from "path";
|
|
1372
|
+
|
|
1373
|
+
// src/dep-exray/known-mappings.ts
|
|
1374
|
+
var KNOWN_MAPPINGS = [
|
|
1375
|
+
{
|
|
1376
|
+
name: "lodash",
|
|
1377
|
+
size: "4.2 MB",
|
|
1378
|
+
replacement: "jscore-core",
|
|
1379
|
+
confidence: "high",
|
|
1380
|
+
autoPrReady: true,
|
|
1381
|
+
reason: "Most lodash functions have direct replacements in jscore-core with 99% API compatibility",
|
|
1382
|
+
detectionPattern: `from ['"]lodash['"]|require\\(['"]lodash['"]\\)`
|
|
1383
|
+
},
|
|
1384
|
+
{
|
|
1385
|
+
name: "moment",
|
|
1386
|
+
size: "2.5 MB",
|
|
1387
|
+
replacement: "jscore-core/date",
|
|
1388
|
+
confidence: "high",
|
|
1389
|
+
autoPrReady: true,
|
|
1390
|
+
reason: "date utilities in jscore-core cover 95% of common moment use cases",
|
|
1391
|
+
detectionPattern: `from ['"]moment['"]|require\\(['"]moment['"]\\)`
|
|
1392
|
+
},
|
|
1393
|
+
{
|
|
1394
|
+
name: "date-fns",
|
|
1395
|
+
size: "1.2 MB (tree-shaked ~50KB)",
|
|
1396
|
+
replacement: "jscore-core/date",
|
|
1397
|
+
confidence: "medium",
|
|
1398
|
+
autoPrReady: false,
|
|
1399
|
+
reason: "Partially overlapping \u2014 jscore-core covers basic date ops but not all locale support",
|
|
1400
|
+
detectionPattern: `from ['"]date-fns['"]|require\\(['"]date-fns['"]\\)`
|
|
1401
|
+
},
|
|
1402
|
+
{
|
|
1403
|
+
name: "axios",
|
|
1404
|
+
size: "1.6 MB",
|
|
1405
|
+
replacement: "native fetch + jscore-core/async/retry",
|
|
1406
|
+
confidence: "medium",
|
|
1407
|
+
autoPrReady: false,
|
|
1408
|
+
reason: "Native fetch covers most use cases; needs manual review for interceptors",
|
|
1409
|
+
detectionPattern: `from ['"]axios['"]|require\\(['"]axios['"]\\)`
|
|
1410
|
+
},
|
|
1411
|
+
{
|
|
1412
|
+
name: "uuid",
|
|
1413
|
+
size: "30 KB",
|
|
1414
|
+
replacement: "crypto.randomUUID() (native)",
|
|
1415
|
+
confidence: "high",
|
|
1416
|
+
autoPrReady: true,
|
|
1417
|
+
reason: "crypto.randomUUID() is available in all modern Node.js and browsers",
|
|
1418
|
+
detectionPattern: `from ['"]uuid['"]|require\\(['"]uuid['"]\\)`
|
|
1419
|
+
},
|
|
1420
|
+
{
|
|
1421
|
+
name: "deepmerge",
|
|
1422
|
+
size: "15 KB",
|
|
1423
|
+
replacement: "jscore-core",
|
|
1424
|
+
confidence: "high",
|
|
1425
|
+
autoPrReady: true,
|
|
1426
|
+
reason: "jscore-core provides deepMerge out of the box",
|
|
1427
|
+
detectionPattern: `from ['"]deepmerge['"]|require\\(['"]deepmerge['"]\\)`
|
|
1428
|
+
},
|
|
1429
|
+
{
|
|
1430
|
+
name: "lodash.merge",
|
|
1431
|
+
size: "25 KB",
|
|
1432
|
+
replacement: "jscore-core",
|
|
1433
|
+
confidence: "high",
|
|
1434
|
+
autoPrReady: true,
|
|
1435
|
+
reason: "jscore-core provides deepMerge out of the box",
|
|
1436
|
+
detectionPattern: `from ['"]lodash\\.(merge|clone|pick|omit|get|set)['"]`
|
|
1437
|
+
},
|
|
1438
|
+
{
|
|
1439
|
+
name: "chalk",
|
|
1440
|
+
size: "45 KB",
|
|
1441
|
+
replacement: "picocolors",
|
|
1442
|
+
confidence: "medium",
|
|
1443
|
+
autoPrReady: false,
|
|
1444
|
+
reason: "picocolors is 3KB vs chalk's 45KB with same API",
|
|
1445
|
+
detectionPattern: `from ['"]chalk['"]|require\\(['"]chalk['"]\\)`
|
|
1446
|
+
},
|
|
1447
|
+
{
|
|
1448
|
+
name: "nanoid",
|
|
1449
|
+
size: "8 KB",
|
|
1450
|
+
replacement: "jscore-core/string (nanoid)",
|
|
1451
|
+
confidence: "high",
|
|
1452
|
+
autoPrReady: true,
|
|
1453
|
+
reason: "jscore-core provides nanoid with same API",
|
|
1454
|
+
detectionPattern: `from ['"]nanoid['"]|require\\(['"]nanoid['"]\\)`
|
|
1455
|
+
},
|
|
1456
|
+
{
|
|
1457
|
+
name: "dayjs",
|
|
1458
|
+
size: "50 KB",
|
|
1459
|
+
replacement: "jscore-core/date",
|
|
1460
|
+
confidence: "medium",
|
|
1461
|
+
autoPrReady: false,
|
|
1462
|
+
reason: "Partially overlapping \u2014 covers basics but not all plugins",
|
|
1463
|
+
detectionPattern: `from ['"]dayjs['"]|require\\(['"]dayjs['"]\\)`
|
|
1464
|
+
},
|
|
1465
|
+
{
|
|
1466
|
+
name: "clsx",
|
|
1467
|
+
size: "5 KB",
|
|
1468
|
+
replacement: "native template literals",
|
|
1469
|
+
confidence: "high",
|
|
1470
|
+
autoPrReady: true,
|
|
1471
|
+
reason: "Can be replaced with simple template literal conditional pattern",
|
|
1472
|
+
detectionPattern: `from ['"]clsx['"]|require\\(['"]clsx['"]\\)`
|
|
1473
|
+
}
|
|
1474
|
+
];
|
|
1475
|
+
var KNOWN_CVES = {
|
|
1476
|
+
"ansi-regex": [
|
|
1477
|
+
{ cve: "CVE-2021-3807", severity: "high", fix: "Update to ansi-regex@6.0.1 or later" }
|
|
1478
|
+
],
|
|
1479
|
+
"semver": [
|
|
1480
|
+
{ cve: "CVE-2022-25883", severity: "medium", fix: "Update to semver@7.5.2 or later" }
|
|
1481
|
+
],
|
|
1482
|
+
"json5": [
|
|
1483
|
+
{ cve: "CVE-2022-46175", severity: "high", fix: "Update to json5@2.2.3 or later" }
|
|
1484
|
+
],
|
|
1485
|
+
"lodash": [
|
|
1486
|
+
{ cve: "CVE-2020-28502", severity: "high", fix: "Update to lodash@4.17.21 or later" },
|
|
1487
|
+
{ cve: "CVE-2020-8203", severity: "medium", fix: "Update to lodash@4.17.21 or later" }
|
|
1488
|
+
]
|
|
1489
|
+
};
|
|
1490
|
+
|
|
1491
|
+
// src/dep-exray/scanner/index.ts
|
|
1492
|
+
function parsePackageJson(path) {
|
|
1493
|
+
const raw = readFileSync(path, "utf-8");
|
|
1494
|
+
const json = JSON.parse(raw);
|
|
1495
|
+
return {
|
|
1496
|
+
name: json.name ?? basename2(join2(path, "..")),
|
|
1497
|
+
dependencies: json.dependencies ?? {},
|
|
1498
|
+
devDependencies: json.devDependencies ?? {}
|
|
1499
|
+
};
|
|
1500
|
+
}
|
|
1501
|
+
function parseLockfile(projectPath) {
|
|
1502
|
+
const lockPath = join2(projectPath, "package-lock.json");
|
|
1503
|
+
if (!existsSync(lockPath)) return null;
|
|
1504
|
+
try {
|
|
1505
|
+
const raw = readFileSync(lockPath, "utf-8");
|
|
1506
|
+
const json = JSON.parse(raw);
|
|
1507
|
+
const packages = {};
|
|
1508
|
+
if (json.packages) {
|
|
1509
|
+
for (const [key, val] of Object.entries(json.packages)) {
|
|
1510
|
+
if (key) {
|
|
1511
|
+
packages[key] = val;
|
|
1512
|
+
}
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1515
|
+
if (json.dependencies && Object.keys(packages).length === 0) {
|
|
1516
|
+
for (const [key, val] of Object.entries(json.dependencies)) {
|
|
1517
|
+
packages[key] = { version: val.version, dependencies: val.requires };
|
|
1518
|
+
}
|
|
1519
|
+
}
|
|
1520
|
+
return { packages };
|
|
1521
|
+
} catch {
|
|
1522
|
+
return null;
|
|
1523
|
+
}
|
|
1524
|
+
}
|
|
1525
|
+
function detectImportInFile(filePath, regex) {
|
|
1526
|
+
try {
|
|
1527
|
+
const content = readFileSync(filePath, "utf-8");
|
|
1528
|
+
return regex.test(content);
|
|
1529
|
+
} catch {
|
|
1530
|
+
return false;
|
|
1531
|
+
}
|
|
1532
|
+
}
|
|
1533
|
+
function detectImportsInSrc(projectPath, mapping) {
|
|
1534
|
+
const regex = new RegExp(mapping.detectionPattern);
|
|
1535
|
+
const srcDir = join2(projectPath, "src");
|
|
1536
|
+
if (!existsSync(srcDir)) return false;
|
|
1537
|
+
try {
|
|
1538
|
+
const files = collectSourceFiles(srcDir);
|
|
1539
|
+
for (const file of files) {
|
|
1540
|
+
if (detectImportInFile(file, regex)) return true;
|
|
1541
|
+
}
|
|
1542
|
+
} catch {
|
|
1543
|
+
return false;
|
|
1544
|
+
}
|
|
1545
|
+
return false;
|
|
1546
|
+
}
|
|
1547
|
+
function collectSourceFiles(dir) {
|
|
1548
|
+
const results = [];
|
|
1549
|
+
try {
|
|
1550
|
+
const entries = readdirSync(dir, { withFileTypes: true });
|
|
1551
|
+
for (const entry of entries) {
|
|
1552
|
+
if (entry.name === "node_modules" || entry.name === "dist" || entry.name === ".git" || entry.name === "coverage" || entry.name === ".tsup") {
|
|
1553
|
+
continue;
|
|
1554
|
+
}
|
|
1555
|
+
const full = join2(dir, entry.name);
|
|
1556
|
+
if (entry.isDirectory()) {
|
|
1557
|
+
results.push(...collectSourceFiles(full));
|
|
1558
|
+
} else if (entry.isFile()) {
|
|
1559
|
+
const ext = entry.name.split(".").pop();
|
|
1560
|
+
if (ext === "ts" || ext === "tsx" || ext === "js" || ext === "jsx" || ext === "mjs" || ext === "cjs") {
|
|
1561
|
+
results.push(full);
|
|
1562
|
+
}
|
|
1563
|
+
}
|
|
1564
|
+
}
|
|
1565
|
+
} catch {
|
|
1566
|
+
}
|
|
1567
|
+
return results;
|
|
1568
|
+
}
|
|
1569
|
+
function estimateTransitiveCount(lockfile, directNames) {
|
|
1570
|
+
if (!lockfile) return 0;
|
|
1571
|
+
let count = 0;
|
|
1572
|
+
for (const key of Object.keys(lockfile.packages)) {
|
|
1573
|
+
if (!key || key === "") continue;
|
|
1574
|
+
const name = key.startsWith("node_modules/") ? key.slice("node_modules/".length) : key;
|
|
1575
|
+
const rootName = name.startsWith("@") ? `${name.split("/")[0]}/${name.split("/")[1]}` : name.split("/")[0];
|
|
1576
|
+
if (rootName && !directNames.has(rootName)) {
|
|
1577
|
+
count++;
|
|
1578
|
+
}
|
|
1579
|
+
}
|
|
1580
|
+
return count;
|
|
1581
|
+
}
|
|
1582
|
+
function parseSize(value) {
|
|
1583
|
+
const cleaned = value.replace(/\(.*?\)/g, "").trim();
|
|
1584
|
+
const match = cleaned.match(/^([\d.]+)\s*(KB|MB)/i);
|
|
1585
|
+
if (!match) return 0;
|
|
1586
|
+
const num = Number.parseFloat(match[1]);
|
|
1587
|
+
if (!match[2]) return 0;
|
|
1588
|
+
if (match[2].toUpperCase() === "MB") return num * 1024;
|
|
1589
|
+
return num;
|
|
1590
|
+
}
|
|
1591
|
+
async function scanProject(config) {
|
|
1592
|
+
const projectPath = config.path ?? ".";
|
|
1593
|
+
const pkgPath = join2(projectPath, "package.json");
|
|
1594
|
+
if (!existsSync(pkgPath)) {
|
|
1595
|
+
throw new Error(`No package.json found at ${projectPath}. Run dep-exray in a JavaScript/TypeScript project directory.`);
|
|
1596
|
+
}
|
|
1597
|
+
const pkg = parsePackageJson(pkgPath);
|
|
1598
|
+
const lockfile = parseLockfile(projectPath);
|
|
1599
|
+
const allDeps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
1600
|
+
const directNames = new Set(Object.keys(allDeps));
|
|
1601
|
+
const transitiveCount = estimateTransitiveCount(lockfile, directNames);
|
|
1602
|
+
const highImpactReplacements = [];
|
|
1603
|
+
const mediumImpactReplacements = [];
|
|
1604
|
+
const securityIssues = [];
|
|
1605
|
+
const sizeMap = {};
|
|
1606
|
+
for (const m of KNOWN_MAPPINGS) {
|
|
1607
|
+
sizeMap[m.name] = m.size;
|
|
1608
|
+
}
|
|
1609
|
+
for (const mapping of KNOWN_MAPPINGS) {
|
|
1610
|
+
const isDirect = directNames.has(mapping.name);
|
|
1611
|
+
if (!isDirect) continue;
|
|
1612
|
+
const isUsed = detectImportsInSrc(projectPath, mapping);
|
|
1613
|
+
if (!isUsed && !config.verbose) continue;
|
|
1614
|
+
const mappingSize = parseSize(sizeMap[mapping.name] ?? "0 KB");
|
|
1615
|
+
const replacementSize = mapping.replacement.startsWith("native") ? 0 : 5;
|
|
1616
|
+
const reductionStr = mappingSize > 1024 ? `${(mappingSize / 1024).toFixed(1)} MB \u2192 ${replacementSize} KB` : `${mappingSize.toFixed(0)} KB \u2192 ${replacementSize} KB`;
|
|
1617
|
+
const suggestion = {
|
|
1618
|
+
packageName: mapping.name,
|
|
1619
|
+
reason: mapping.reason,
|
|
1620
|
+
replacement: mapping.replacement,
|
|
1621
|
+
estimatedSizeReduction: reductionStr,
|
|
1622
|
+
confidence: mapping.confidence,
|
|
1623
|
+
autoPrReady: mapping.autoPrReady
|
|
1624
|
+
};
|
|
1625
|
+
if (mapping.confidence === "high") {
|
|
1626
|
+
highImpactReplacements.push(suggestion);
|
|
1627
|
+
} else {
|
|
1628
|
+
mediumImpactReplacements.push(suggestion);
|
|
1629
|
+
}
|
|
1630
|
+
}
|
|
1631
|
+
for (const [name, cves] of Object.entries(KNOWN_CVES)) {
|
|
1632
|
+
if (directNames.has(name)) {
|
|
1633
|
+
for (const cveItem of cves) {
|
|
1634
|
+
securityIssues.push({
|
|
1635
|
+
packageName: name,
|
|
1636
|
+
cveId: cveItem.cve,
|
|
1637
|
+
severity: cveItem.severity,
|
|
1638
|
+
fix: cveItem.fix
|
|
1639
|
+
});
|
|
1640
|
+
}
|
|
1641
|
+
}
|
|
1642
|
+
}
|
|
1643
|
+
let totalSizeKB = 0;
|
|
1644
|
+
for (const depName of directNames) {
|
|
1645
|
+
const sizeStr = sizeMap[depName];
|
|
1646
|
+
if (sizeStr) {
|
|
1647
|
+
totalSizeKB += parseSize(sizeStr);
|
|
1648
|
+
} else {
|
|
1649
|
+
totalSizeKB += 50;
|
|
1650
|
+
}
|
|
1651
|
+
}
|
|
1652
|
+
totalSizeKB += transitiveCount * 30;
|
|
1653
|
+
const totalSizeStr = totalSizeKB > 1024 ? `${(totalSizeKB / 1024).toFixed(1)} MB` : `${totalSizeKB.toFixed(0)} KB`;
|
|
1654
|
+
return {
|
|
1655
|
+
projectName: pkg.name,
|
|
1656
|
+
directDeps: directNames.size,
|
|
1657
|
+
transitiveDeps: transitiveCount,
|
|
1658
|
+
totalEstimatedSize: totalSizeStr,
|
|
1659
|
+
highImpactReplacements,
|
|
1660
|
+
mediumImpactReplacements,
|
|
1661
|
+
securityIssues
|
|
1662
|
+
};
|
|
1663
|
+
}
|
|
1664
|
+
|
|
1665
|
+
// src/dep-exray/reporter/index.ts
|
|
1666
|
+
import pc from "picocolors";
|
|
1667
|
+
function severityColor(severity) {
|
|
1668
|
+
switch (severity) {
|
|
1669
|
+
case "critical":
|
|
1670
|
+
return pc.bold(pc.red(severity.toUpperCase()));
|
|
1671
|
+
case "high":
|
|
1672
|
+
return pc.red(severity.toUpperCase());
|
|
1673
|
+
case "medium":
|
|
1674
|
+
return pc.yellow(severity.toUpperCase());
|
|
1675
|
+
case "low":
|
|
1676
|
+
return pc.dim(severity.toUpperCase());
|
|
1677
|
+
}
|
|
1678
|
+
}
|
|
1679
|
+
function confidenceIcon(confidence) {
|
|
1680
|
+
switch (confidence) {
|
|
1681
|
+
case "high":
|
|
1682
|
+
return pc.green("\u25CF");
|
|
1683
|
+
case "medium":
|
|
1684
|
+
return pc.yellow("\u25CF");
|
|
1685
|
+
case "low":
|
|
1686
|
+
return pc.red("\u25CF");
|
|
1687
|
+
}
|
|
1688
|
+
}
|
|
1689
|
+
function generateReport(result, jsonOutput) {
|
|
1690
|
+
if (jsonOutput) {
|
|
1691
|
+
return JSON.stringify(result, null, 2);
|
|
1692
|
+
}
|
|
1693
|
+
const lines = [];
|
|
1694
|
+
lines.push(pc.bold(pc.cyan(`\u250C${"\u2500".repeat(58)}\u2510`)));
|
|
1695
|
+
lines.push(pc.bold(pc.cyan(`\u2502${" ".repeat(18)}dep-exray Report${" ".repeat(21)}\u2502`)));
|
|
1696
|
+
lines.push(pc.bold(pc.cyan(`\u251C${"\u2500".repeat(58)}\u2524`)));
|
|
1697
|
+
lines.push(pc.bold(pc.cyan(`\u2502 ${pc.white("\u{1F4E6} PROJECT:")} ${pc.bold(result.projectName)}${" ".repeat(Math.max(1, 47 - result.projectName.length))}\u2502`)));
|
|
1698
|
+
lines.push(pc.bold(pc.cyan(`\u2502 ${pc.white("\u{1F4CA} DEPENDENCIES:")} ${pc.bold(String(result.directDeps))} direct + ${pc.bold(String(result.transitiveDeps))} transitive${" ".repeat(Math.max(1, 27 - String(result.transitiveDeps).length))}\u2502`)));
|
|
1699
|
+
lines.push(pc.bold(pc.cyan(`\u2502 ${pc.white("\u{1F4BE} TOTAL SIZE:")} ${pc.bold(result.totalEstimatedSize)}${" ".repeat(Math.max(1, 42 - result.totalEstimatedSize.length))}\u2502`)));
|
|
1700
|
+
lines.push(pc.bold(pc.cyan(`\u251C${"\u2500".repeat(58)}\u2524`)));
|
|
1701
|
+
if (result.highImpactReplacements.length > 0) {
|
|
1702
|
+
lines.push(pc.bold(pc.cyan(`\u2502 ${pc.green("\u{1F7E2}")} ${pc.bold(pc.green("HIGH IMPACT REPLACEMENTS"))}${" ".repeat(23)}\u2502`)));
|
|
1703
|
+
for (const item of result.highImpactReplacements) {
|
|
1704
|
+
const autoPr = item.autoPrReady ? pc.green("\u2713 Auto-PR ready") : pc.dim("Manual review needed");
|
|
1705
|
+
const confIcon = confidenceIcon(item.confidence);
|
|
1706
|
+
lines.push(pc.bold(pc.cyan(`\u251C${"\u2500".repeat(58)}\u2524`)));
|
|
1707
|
+
lines.push(pc.bold(pc.cyan(`\u2502 ${pc.red("\u2717")} ${pc.bold(item.packageName)} (${item.estimatedSizeReduction})${" ".repeat(Math.max(1, 38 - item.estimatedSizeReduction.length))}\u2502`)));
|
|
1708
|
+
lines.push(pc.bold(pc.cyan(`\u2502 ${pc.dim("\u2192")} ${pc.cyan(item.replacement)}${" ".repeat(Math.max(1, 51 - item.replacement.length))}\u2502`)));
|
|
1709
|
+
lines.push(pc.bold(pc.cyan(`\u2502 ${pc.dim("\u2514\u2500")} ${autoPr} ${confIcon} ${item.confidence}${" ".repeat(Math.max(1, 35))}\u2502`)));
|
|
1710
|
+
}
|
|
1711
|
+
}
|
|
1712
|
+
if (result.mediumImpactReplacements.length > 0) {
|
|
1713
|
+
lines.push(pc.bold(pc.cyan(`\u251C${"\u2500".repeat(58)}\u2524`)));
|
|
1714
|
+
lines.push(pc.bold(pc.cyan(`\u2502 ${pc.yellow("\u{1F7E1}")} ${pc.bold(pc.yellow("MEDIUM IMPACT REPLACEMENTS"))}${" ".repeat(20)}\u2502`)));
|
|
1715
|
+
for (const item of result.mediumImpactReplacements) {
|
|
1716
|
+
const autoPr = item.autoPrReady ? pc.green("\u2713 Auto-PR ready") : pc.dim("Manual review needed");
|
|
1717
|
+
const confIcon = confidenceIcon(item.confidence);
|
|
1718
|
+
lines.push(pc.bold(pc.cyan(`\u251C${"\u2500".repeat(58)}\u2524`)));
|
|
1719
|
+
lines.push(pc.bold(pc.cyan(`\u2502 ${pc.red("\u2717")} ${pc.bold(item.packageName)} (${item.estimatedSizeReduction})${" ".repeat(Math.max(1, 38 - item.estimatedSizeReduction.length))}\u2502`)));
|
|
1720
|
+
lines.push(pc.bold(pc.cyan(`\u2502 ${pc.dim("\u2192")} ${pc.cyan(item.replacement)}${" ".repeat(Math.max(1, 51 - item.replacement.length))}\u2502`)));
|
|
1721
|
+
lines.push(pc.bold(pc.cyan(`\u2502 ${pc.dim("\u2514\u2500")} ${autoPr} ${confIcon} ${item.confidence}${" ".repeat(Math.max(1, 35))}\u2502`)));
|
|
1722
|
+
}
|
|
1723
|
+
}
|
|
1724
|
+
if (result.securityIssues.length > 0) {
|
|
1725
|
+
lines.push(pc.bold(pc.cyan(`\u251C${"\u2500".repeat(58)}\u2524`)));
|
|
1726
|
+
lines.push(pc.bold(pc.cyan(`\u2502 ${pc.red("\u{1F534}")} ${pc.bold(pc.red("SECURITY ISSUES"))}${" ".repeat(33)}\u2502`)));
|
|
1727
|
+
for (const issue of result.securityIssues) {
|
|
1728
|
+
lines.push(pc.bold(pc.cyan(`\u251C${"\u2500".repeat(58)}\u2524`)));
|
|
1729
|
+
lines.push(pc.bold(pc.cyan(`\u2502 ${severityColor(issue.severity)} ${pc.bold(issue.cveId)} in ${issue.packageName}${" ".repeat(Math.max(1, 40 - issue.packageName.length))}\u2502`)));
|
|
1730
|
+
lines.push(pc.bold(pc.cyan(`\u2502 ${pc.dim("\u2192")} ${issue.fix}${" ".repeat(Math.max(1, 52 - issue.fix.length))}\u2502`)));
|
|
1731
|
+
}
|
|
1732
|
+
}
|
|
1733
|
+
lines.push(pc.bold(pc.cyan(`\u2514${"\u2500".repeat(58)}\u2518`)));
|
|
1734
|
+
return lines.join("\n");
|
|
1735
|
+
}
|
|
1736
|
+
|
|
1737
|
+
// src/dep-exray/analyzer/index.ts
|
|
1738
|
+
import { readFileSync as readFileSync2 } from "fs";
|
|
1739
|
+
import { readdirSync as readdirSync2, statSync } from "fs";
|
|
1740
|
+
import { join as join3, extname as extname2 } from "path";
|
|
1741
|
+
var SOURCE_EXTENSIONS = /* @__PURE__ */ new Set([".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"]);
|
|
1742
|
+
function isSourceFile(file) {
|
|
1743
|
+
return SOURCE_EXTENSIONS.has(extname2(file));
|
|
1744
|
+
}
|
|
1745
|
+
function collectSourceFiles2(dir) {
|
|
1746
|
+
const results = [];
|
|
1747
|
+
try {
|
|
1748
|
+
const entries = readdirSync2(dir, { withFileTypes: true });
|
|
1749
|
+
for (const entry of entries) {
|
|
1750
|
+
const fullPath = join3(dir, entry.name);
|
|
1751
|
+
if (entry.name === "node_modules" || entry.name === "dist" || entry.name === ".git" || entry.name === "coverage" || entry.name === ".tsup") {
|
|
1752
|
+
continue;
|
|
1753
|
+
}
|
|
1754
|
+
if (entry.isDirectory()) {
|
|
1755
|
+
results.push(...collectSourceFiles2(fullPath));
|
|
1756
|
+
} else if (entry.isFile() && isSourceFile(entry.name)) {
|
|
1757
|
+
results.push(fullPath);
|
|
1758
|
+
}
|
|
1759
|
+
}
|
|
1760
|
+
} catch {
|
|
1761
|
+
}
|
|
1762
|
+
return results;
|
|
1763
|
+
}
|
|
1764
|
+
function escapeRegex(str) {
|
|
1765
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1766
|
+
}
|
|
1767
|
+
async function analyzeUsage(projectPath, packageName) {
|
|
1768
|
+
const importLocations = [];
|
|
1769
|
+
const escaped = escapeRegex(packageName);
|
|
1770
|
+
const importRegex = new RegExp(
|
|
1771
|
+
`(?:from\\s+['"]${escaped}(?:/['"]|['"])|require\\(\\s*['"]${escaped}(?:/|['"]))`,
|
|
1772
|
+
"g"
|
|
1773
|
+
);
|
|
1774
|
+
const srcDir = join3(projectPath, "src");
|
|
1775
|
+
let files;
|
|
1776
|
+
try {
|
|
1777
|
+
if (statSync(srcDir).isDirectory()) {
|
|
1778
|
+
files = collectSourceFiles2(srcDir);
|
|
1779
|
+
} else {
|
|
1780
|
+
files = collectSourceFiles2(projectPath);
|
|
1781
|
+
}
|
|
1782
|
+
} catch {
|
|
1783
|
+
files = collectSourceFiles2(projectPath);
|
|
1784
|
+
}
|
|
1785
|
+
for (const file of files) {
|
|
1786
|
+
try {
|
|
1787
|
+
const content = readFileSync2(file, "utf-8");
|
|
1788
|
+
importRegex.lastIndex = 0;
|
|
1789
|
+
if (importRegex.test(content)) {
|
|
1790
|
+
importLocations.push(file);
|
|
1791
|
+
}
|
|
1792
|
+
} catch {
|
|
1793
|
+
}
|
|
1794
|
+
}
|
|
1795
|
+
return {
|
|
1796
|
+
isUsed: importLocations.length > 0,
|
|
1797
|
+
importCount: importLocations.length,
|
|
1798
|
+
importLocations
|
|
1799
|
+
};
|
|
1800
|
+
}
|
|
2115
1801
|
export {
|
|
2116
|
-
Complex,
|
|
2117
1802
|
DivisionByZeroError,
|
|
2118
1803
|
InvalidDateError,
|
|
2119
|
-
|
|
1804
|
+
KNOWN_CVES,
|
|
1805
|
+
KNOWN_MAPPINGS,
|
|
2120
1806
|
add,
|
|
2121
1807
|
addBusinessDays,
|
|
2122
1808
|
addDays,
|
|
2123
1809
|
addMonths,
|
|
2124
1810
|
addYears,
|
|
2125
1811
|
allSettledMap,
|
|
2126
|
-
|
|
1812
|
+
analyzeUsage,
|
|
2127
1813
|
approxEqual,
|
|
2128
|
-
asin,
|
|
2129
1814
|
assertDefined,
|
|
2130
1815
|
assertType,
|
|
2131
|
-
atan,
|
|
2132
|
-
atan2,
|
|
2133
1816
|
average,
|
|
2134
1817
|
base64Decode,
|
|
2135
1818
|
base64Encode,
|
|
2136
1819
|
basename,
|
|
2137
|
-
binomial,
|
|
2138
1820
|
calculateAge,
|
|
2139
1821
|
camelCase,
|
|
2140
1822
|
capitalize,
|
|
@@ -2143,18 +1825,13 @@ export {
|
|
|
2143
1825
|
checksum,
|
|
2144
1826
|
chunk,
|
|
2145
1827
|
clamp,
|
|
2146
|
-
compoundInterest,
|
|
2147
1828
|
constantTimeEqual,
|
|
2148
|
-
correlation,
|
|
2149
|
-
cos,
|
|
2150
1829
|
countOccurrences,
|
|
2151
|
-
covariance,
|
|
2152
1830
|
dateDiff,
|
|
2153
1831
|
debounce,
|
|
2154
1832
|
deepClone,
|
|
2155
1833
|
deepMerge,
|
|
2156
1834
|
deferred,
|
|
2157
|
-
derivative,
|
|
2158
1835
|
dirname,
|
|
2159
1836
|
div,
|
|
2160
1837
|
endOfDay,
|
|
@@ -2166,27 +1843,19 @@ export {
|
|
|
2166
1843
|
envInt,
|
|
2167
1844
|
escapeHtml,
|
|
2168
1845
|
extname,
|
|
2169
|
-
factorial,
|
|
2170
|
-
fibonacci,
|
|
2171
1846
|
first,
|
|
2172
1847
|
flatten,
|
|
2173
1848
|
floor,
|
|
2174
1849
|
format,
|
|
2175
1850
|
formatDate,
|
|
2176
|
-
futureValue,
|
|
2177
|
-
gcd,
|
|
2178
1851
|
generateOTP,
|
|
1852
|
+
generateReport,
|
|
2179
1853
|
generateToken,
|
|
2180
|
-
geometricMean,
|
|
2181
1854
|
getType2 as getType,
|
|
2182
1855
|
groupBy,
|
|
2183
|
-
harmonicMean,
|
|
2184
1856
|
hash,
|
|
2185
|
-
hypot,
|
|
2186
1857
|
identity,
|
|
2187
1858
|
inRange,
|
|
2188
|
-
integral,
|
|
2189
|
-
irr,
|
|
2190
1859
|
isAbsolute,
|
|
2191
1860
|
isAfter,
|
|
2192
1861
|
isArray,
|
|
@@ -2196,7 +1865,6 @@ export {
|
|
|
2196
1865
|
isBusinessDay,
|
|
2197
1866
|
isDate,
|
|
2198
1867
|
isEmpty,
|
|
2199
|
-
isEven,
|
|
2200
1868
|
isFunction,
|
|
2201
1869
|
isLeapYear,
|
|
2202
1870
|
isMap,
|
|
@@ -2204,8 +1872,6 @@ export {
|
|
|
2204
1872
|
isNull,
|
|
2205
1873
|
isNumber,
|
|
2206
1874
|
isObject,
|
|
2207
|
-
isOdd,
|
|
2208
|
-
isPrime,
|
|
2209
1875
|
isPromise,
|
|
2210
1876
|
isRegExp,
|
|
2211
1877
|
isSet,
|
|
@@ -2215,30 +1881,12 @@ export {
|
|
|
2215
1881
|
join,
|
|
2216
1882
|
kebabCase,
|
|
2217
1883
|
keyBy,
|
|
2218
|
-
kurtosis,
|
|
2219
1884
|
last,
|
|
2220
|
-
lcm,
|
|
2221
|
-
lerp,
|
|
2222
|
-
mapRange,
|
|
2223
|
-
matrixAdd,
|
|
2224
|
-
matrixDeterminant,
|
|
2225
|
-
matrixIdentity,
|
|
2226
|
-
matrixInverse,
|
|
2227
|
-
matrixMul,
|
|
2228
|
-
matrixMultiply,
|
|
2229
|
-
matrixScale,
|
|
2230
|
-
matrixSub,
|
|
2231
|
-
matrixTrace,
|
|
2232
|
-
matrixTranspose,
|
|
2233
|
-
median,
|
|
2234
1885
|
memoize,
|
|
2235
|
-
mode,
|
|
2236
1886
|
mul,
|
|
2237
1887
|
nanoid,
|
|
2238
|
-
newtonRoot,
|
|
2239
1888
|
noop,
|
|
2240
1889
|
normalize,
|
|
2241
|
-
npv,
|
|
2242
1890
|
omit,
|
|
2243
1891
|
once,
|
|
2244
1892
|
orderBy,
|
|
@@ -2250,57 +1898,37 @@ export {
|
|
|
2250
1898
|
parseCsv,
|
|
2251
1899
|
parseDate,
|
|
2252
1900
|
pascalCase,
|
|
2253
|
-
percentile,
|
|
2254
|
-
permutation,
|
|
2255
1901
|
pick,
|
|
2256
1902
|
pipeline,
|
|
2257
1903
|
pluck,
|
|
2258
|
-
pmt,
|
|
2259
|
-
presentValue,
|
|
2260
|
-
primeFactors,
|
|
2261
|
-
quartiles,
|
|
2262
1904
|
raceWithTimeout,
|
|
2263
|
-
randomBinomial,
|
|
2264
|
-
randomExponential,
|
|
2265
1905
|
randomHex,
|
|
2266
1906
|
randomInt,
|
|
2267
|
-
randomNormal,
|
|
2268
|
-
randomPoisson,
|
|
2269
|
-
randomUniform,
|
|
2270
1907
|
relative,
|
|
2271
1908
|
resolve,
|
|
2272
1909
|
retry,
|
|
2273
1910
|
retryAsync,
|
|
2274
1911
|
reverse,
|
|
2275
|
-
roi,
|
|
2276
1912
|
round,
|
|
2277
1913
|
safeJsonParse,
|
|
2278
1914
|
sample,
|
|
2279
1915
|
sampleSize,
|
|
1916
|
+
scanProject,
|
|
2280
1917
|
shuffle,
|
|
2281
|
-
sign,
|
|
2282
1918
|
simpleHash,
|
|
2283
|
-
sin,
|
|
2284
|
-
skewness,
|
|
2285
1919
|
sleep,
|
|
2286
1920
|
slugify,
|
|
2287
1921
|
snakeCase,
|
|
2288
1922
|
sortBy,
|
|
2289
|
-
standardize,
|
|
2290
1923
|
startOfDay,
|
|
2291
1924
|
startOfMonth,
|
|
2292
1925
|
startOfYear,
|
|
2293
|
-
stddev,
|
|
2294
1926
|
stringifyCsv,
|
|
2295
1927
|
sub,
|
|
2296
1928
|
sum,
|
|
2297
|
-
tan,
|
|
2298
1929
|
template,
|
|
2299
1930
|
throttle,
|
|
2300
1931
|
timeout,
|
|
2301
|
-
toDegrees,
|
|
2302
|
-
toRadians,
|
|
2303
|
-
trapezoidal,
|
|
2304
1932
|
trim,
|
|
2305
1933
|
trimEnd,
|
|
2306
1934
|
trimStart,
|
|
@@ -2309,10 +1937,7 @@ export {
|
|
|
2309
1937
|
uniq,
|
|
2310
1938
|
uniqueBy,
|
|
2311
1939
|
uuid,
|
|
2312
|
-
variance,
|
|
2313
|
-
weightedMean,
|
|
2314
1940
|
words,
|
|
2315
|
-
xorCipher
|
|
2316
|
-
zScore
|
|
1941
|
+
xorCipher
|
|
2317
1942
|
};
|
|
2318
1943
|
//# sourceMappingURL=index.js.map
|