ngx-transforms 0.2.0 → 0.3.1
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/README.md +33 -78
- package/fesm2022/ngx-transforms.mjs +1961 -2
- package/fesm2022/ngx-transforms.mjs.map +1 -1
- package/package.json +3 -3
- package/types/ngx-transforms.d.ts +1099 -1
|
@@ -473,6 +473,1397 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImpor
|
|
|
473
473
|
}]
|
|
474
474
|
}] });
|
|
475
475
|
|
|
476
|
+
/**
|
|
477
|
+
* TrimPipe: Removes whitespace (or specified characters) from both ends of a string.
|
|
478
|
+
*
|
|
479
|
+
* By default, trims whitespace. Pass a string of characters to trim those instead.
|
|
480
|
+
*
|
|
481
|
+
* @param {string} value - The string to trim.
|
|
482
|
+
* @param {string} [chars] - Optional set of characters to trim from both ends.
|
|
483
|
+
*
|
|
484
|
+
* @returns {string} - The trimmed string, or an empty string if input is invalid.
|
|
485
|
+
*
|
|
486
|
+
* @example
|
|
487
|
+
* {{ ' hello ' | trim }} // 'hello'
|
|
488
|
+
* {{ '--hello--' | trim:'-' }} // 'hello'
|
|
489
|
+
* {{ '***title***' | trim:'*' }} // 'title'
|
|
490
|
+
*/
|
|
491
|
+
class TrimPipe {
|
|
492
|
+
transform(value, chars) {
|
|
493
|
+
if (typeof value !== 'string')
|
|
494
|
+
return '';
|
|
495
|
+
if (!chars)
|
|
496
|
+
return value.trim();
|
|
497
|
+
const escaped = chars
|
|
498
|
+
.split('')
|
|
499
|
+
.map(c => c.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'))
|
|
500
|
+
.join('');
|
|
501
|
+
const regex = new RegExp(`^[${escaped}]+|[${escaped}]+$`, 'g');
|
|
502
|
+
return value.replace(regex, '');
|
|
503
|
+
}
|
|
504
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: TrimPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
505
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: TrimPipe, isStandalone: true, name: "trim" });
|
|
506
|
+
}
|
|
507
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: TrimPipe, decorators: [{
|
|
508
|
+
type: Pipe,
|
|
509
|
+
args: [{
|
|
510
|
+
name: 'trim',
|
|
511
|
+
standalone: true,
|
|
512
|
+
}]
|
|
513
|
+
}] });
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* CapitalizePipe: Uppercases the first character and lowercases the rest.
|
|
517
|
+
*
|
|
518
|
+
* Useful for normalizing headings, labels, and proper nouns.
|
|
519
|
+
* Differs from `upperFirst` which only uppercases the first character without
|
|
520
|
+
* altering the remaining characters.
|
|
521
|
+
*
|
|
522
|
+
* @param {string} value - The string to capitalize.
|
|
523
|
+
*
|
|
524
|
+
* @returns {string} - The capitalized string, or an empty string if input is invalid.
|
|
525
|
+
*
|
|
526
|
+
* @example
|
|
527
|
+
* {{ 'hello world' | capitalize }} // 'Hello world'
|
|
528
|
+
* {{ 'HELLO WORLD' | capitalize }} // 'Hello world'
|
|
529
|
+
* {{ 'hELLo' | capitalize }} // 'Hello'
|
|
530
|
+
*/
|
|
531
|
+
class CapitalizePipe {
|
|
532
|
+
transform(value) {
|
|
533
|
+
if (typeof value !== 'string' || value.length === 0)
|
|
534
|
+
return '';
|
|
535
|
+
return value.charAt(0).toUpperCase() + value.slice(1).toLowerCase();
|
|
536
|
+
}
|
|
537
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: CapitalizePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
538
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: CapitalizePipe, isStandalone: true, name: "capitalize" });
|
|
539
|
+
}
|
|
540
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: CapitalizePipe, decorators: [{
|
|
541
|
+
type: Pipe,
|
|
542
|
+
args: [{
|
|
543
|
+
name: 'capitalize',
|
|
544
|
+
standalone: true,
|
|
545
|
+
}]
|
|
546
|
+
}] });
|
|
547
|
+
|
|
548
|
+
/**
|
|
549
|
+
* UpperFirstPipe: Uppercases the first character of a string without altering the rest.
|
|
550
|
+
*
|
|
551
|
+
* Differs from `capitalize` which also lowercases the remaining characters.
|
|
552
|
+
* Useful when you want to preserve acronyms, camelCase, or existing casing.
|
|
553
|
+
*
|
|
554
|
+
* @param {string} value - The string to transform.
|
|
555
|
+
*
|
|
556
|
+
* @returns {string} - The transformed string, or an empty string if input is invalid.
|
|
557
|
+
*
|
|
558
|
+
* @example
|
|
559
|
+
* {{ 'hello WORLD' | upperFirst }} // 'Hello WORLD'
|
|
560
|
+
* {{ 'javaScript' | upperFirst }} // 'JavaScript'
|
|
561
|
+
* {{ 'apiKey' | upperFirst }} // 'ApiKey'
|
|
562
|
+
*/
|
|
563
|
+
class UpperFirstPipe {
|
|
564
|
+
transform(value) {
|
|
565
|
+
if (typeof value !== 'string' || value.length === 0)
|
|
566
|
+
return '';
|
|
567
|
+
return value.charAt(0).toUpperCase() + value.slice(1);
|
|
568
|
+
}
|
|
569
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: UpperFirstPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
570
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: UpperFirstPipe, isStandalone: true, name: "upperFirst" });
|
|
571
|
+
}
|
|
572
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: UpperFirstPipe, decorators: [{
|
|
573
|
+
type: Pipe,
|
|
574
|
+
args: [{
|
|
575
|
+
name: 'upperFirst',
|
|
576
|
+
standalone: true,
|
|
577
|
+
}]
|
|
578
|
+
}] });
|
|
579
|
+
|
|
580
|
+
/**
|
|
581
|
+
* LeftPadPipe: Pads a string on the left until it reaches the target length.
|
|
582
|
+
*
|
|
583
|
+
* Wraps JavaScript's native `padStart`. If the input is already at or above
|
|
584
|
+
* the target length, returns it unchanged. Defaults to padding with spaces.
|
|
585
|
+
*
|
|
586
|
+
* @param {string | number} value - The string or number to pad.
|
|
587
|
+
* @param {number} length - The target length of the resulting string.
|
|
588
|
+
* @param {string} [char=' '] - The character (or string) to pad with.
|
|
589
|
+
*
|
|
590
|
+
* @returns {string} - The padded string, or empty string if input is invalid.
|
|
591
|
+
*
|
|
592
|
+
* @example
|
|
593
|
+
* {{ '5' | leftPad:3:'0' }} // '005'
|
|
594
|
+
* {{ 42 | leftPad:5 }} // ' 42'
|
|
595
|
+
* {{ 'hi' | leftPad:6:'-' }} // '----hi'
|
|
596
|
+
*/
|
|
597
|
+
class LeftPadPipe {
|
|
598
|
+
transform(value, length, char = ' ') {
|
|
599
|
+
if (value === null || value === undefined)
|
|
600
|
+
return '';
|
|
601
|
+
const str = typeof value === 'number' ? String(value) : value;
|
|
602
|
+
if (typeof str !== 'string')
|
|
603
|
+
return '';
|
|
604
|
+
if (typeof length !== 'number' || isNaN(length) || length < 0)
|
|
605
|
+
return str;
|
|
606
|
+
const padChar = char === '' ? ' ' : char;
|
|
607
|
+
return str.padStart(length, padChar);
|
|
608
|
+
}
|
|
609
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: LeftPadPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
610
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: LeftPadPipe, isStandalone: true, name: "leftPad" });
|
|
611
|
+
}
|
|
612
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: LeftPadPipe, decorators: [{
|
|
613
|
+
type: Pipe,
|
|
614
|
+
args: [{
|
|
615
|
+
name: 'leftPad',
|
|
616
|
+
standalone: true,
|
|
617
|
+
}]
|
|
618
|
+
}] });
|
|
619
|
+
|
|
620
|
+
/**
|
|
621
|
+
* RightPadPipe: Pads a string on the right until it reaches the target length.
|
|
622
|
+
*
|
|
623
|
+
* Wraps JavaScript's native `padEnd`. If the input is already at or above
|
|
624
|
+
* the target length, returns it unchanged. Defaults to padding with spaces.
|
|
625
|
+
*
|
|
626
|
+
* @param {string | number} value - The string or number to pad.
|
|
627
|
+
* @param {number} length - The target length of the resulting string.
|
|
628
|
+
* @param {string} [char=' '] - The character (or string) to pad with.
|
|
629
|
+
*
|
|
630
|
+
* @returns {string} - The padded string, or empty string if input is invalid.
|
|
631
|
+
*
|
|
632
|
+
* @example
|
|
633
|
+
* {{ 'hi' | rightPad:5:'.' }} // 'hi...'
|
|
634
|
+
* {{ 'name' | rightPad:10 }} // 'name '
|
|
635
|
+
* {{ 42 | rightPad:5:'0' }} // '42000'
|
|
636
|
+
*/
|
|
637
|
+
class RightPadPipe {
|
|
638
|
+
transform(value, length, char = ' ') {
|
|
639
|
+
if (value === null || value === undefined)
|
|
640
|
+
return '';
|
|
641
|
+
const str = typeof value === 'number' ? String(value) : value;
|
|
642
|
+
if (typeof str !== 'string')
|
|
643
|
+
return '';
|
|
644
|
+
if (typeof length !== 'number' || isNaN(length) || length < 0)
|
|
645
|
+
return str;
|
|
646
|
+
const padChar = char === '' ? ' ' : char;
|
|
647
|
+
return str.padEnd(length, padChar);
|
|
648
|
+
}
|
|
649
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: RightPadPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
650
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: RightPadPipe, isStandalone: true, name: "rightPad" });
|
|
651
|
+
}
|
|
652
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: RightPadPipe, decorators: [{
|
|
653
|
+
type: Pipe,
|
|
654
|
+
args: [{
|
|
655
|
+
name: 'rightPad',
|
|
656
|
+
standalone: true,
|
|
657
|
+
}]
|
|
658
|
+
}] });
|
|
659
|
+
|
|
660
|
+
/**
|
|
661
|
+
* PadPipe: Pads a string on both sides to reach the target length (centers it).
|
|
662
|
+
*
|
|
663
|
+
* When the padding is uneven, the extra character goes to the right.
|
|
664
|
+
* Defaults to padding with spaces.
|
|
665
|
+
*
|
|
666
|
+
* @param {string | number} value - The string or number to pad.
|
|
667
|
+
* @param {number} length - The target length of the resulting string.
|
|
668
|
+
* @param {string} [char=' '] - The character (or string) to pad with.
|
|
669
|
+
*
|
|
670
|
+
* @returns {string} - The padded string, or empty string if input is invalid.
|
|
671
|
+
*
|
|
672
|
+
* @example
|
|
673
|
+
* {{ 'x' | pad:5:'-' }} // '--x--'
|
|
674
|
+
* {{ 'hi' | pad:6:'*' }} // '**hi**'
|
|
675
|
+
* {{ 'hi' | pad:7:'*' }} // '**hi***' (extra right)
|
|
676
|
+
*/
|
|
677
|
+
class PadPipe {
|
|
678
|
+
transform(value, length, char = ' ') {
|
|
679
|
+
if (value === null || value === undefined)
|
|
680
|
+
return '';
|
|
681
|
+
const str = typeof value === 'number' ? String(value) : value;
|
|
682
|
+
if (typeof str !== 'string')
|
|
683
|
+
return '';
|
|
684
|
+
if (typeof length !== 'number' || isNaN(length) || length < 0)
|
|
685
|
+
return str;
|
|
686
|
+
if (str.length >= length)
|
|
687
|
+
return str;
|
|
688
|
+
const padChar = char === '' ? ' ' : char;
|
|
689
|
+
const diff = length - str.length;
|
|
690
|
+
const leftCount = Math.floor(diff / 2);
|
|
691
|
+
const leftTarget = str.length + leftCount;
|
|
692
|
+
return str.padStart(leftTarget, padChar).padEnd(length, padChar);
|
|
693
|
+
}
|
|
694
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: PadPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
695
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: PadPipe, isStandalone: true, name: "pad" });
|
|
696
|
+
}
|
|
697
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: PadPipe, decorators: [{
|
|
698
|
+
type: Pipe,
|
|
699
|
+
args: [{
|
|
700
|
+
name: 'pad',
|
|
701
|
+
standalone: true,
|
|
702
|
+
}]
|
|
703
|
+
}] });
|
|
704
|
+
|
|
705
|
+
/**
|
|
706
|
+
* RepeatPipe: Repeats a string a given number of times.
|
|
707
|
+
*
|
|
708
|
+
* Wraps `String.prototype.repeat`. Optional separator is inserted between repetitions.
|
|
709
|
+
*
|
|
710
|
+
* @param {string} value - The string to repeat.
|
|
711
|
+
* @param {number} count - Number of times to repeat (must be >= 0).
|
|
712
|
+
* @param {string} [separator=''] - Optional separator placed between repetitions.
|
|
713
|
+
*
|
|
714
|
+
* @returns {string} - The repeated string, or an empty string if input is invalid.
|
|
715
|
+
*
|
|
716
|
+
* @example
|
|
717
|
+
* {{ '-' | repeat:10 }} // '----------'
|
|
718
|
+
* {{ 'ha' | repeat:3 }} // 'hahaha'
|
|
719
|
+
* {{ 'item' | repeat:3:', ' }} // 'item, item, item'
|
|
720
|
+
*/
|
|
721
|
+
class RepeatPipe {
|
|
722
|
+
transform(value, count, separator = '') {
|
|
723
|
+
if (typeof value !== 'string')
|
|
724
|
+
return '';
|
|
725
|
+
if (typeof count !== 'number' || isNaN(count) || count < 0 || !isFinite(count)) {
|
|
726
|
+
return '';
|
|
727
|
+
}
|
|
728
|
+
const repetitions = Math.floor(count);
|
|
729
|
+
if (repetitions === 0)
|
|
730
|
+
return '';
|
|
731
|
+
if (!separator)
|
|
732
|
+
return value.repeat(repetitions);
|
|
733
|
+
return Array(repetitions).fill(value).join(separator);
|
|
734
|
+
}
|
|
735
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: RepeatPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
736
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: RepeatPipe, isStandalone: true, name: "repeat" });
|
|
737
|
+
}
|
|
738
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: RepeatPipe, decorators: [{
|
|
739
|
+
type: Pipe,
|
|
740
|
+
args: [{
|
|
741
|
+
name: 'repeat',
|
|
742
|
+
standalone: true,
|
|
743
|
+
}]
|
|
744
|
+
}] });
|
|
745
|
+
|
|
746
|
+
/**
|
|
747
|
+
* SlugifyPipe: Converts a string into a URL-friendly slug.
|
|
748
|
+
*
|
|
749
|
+
* Removes diacritics, lowercases, replaces non-alphanumerics with the separator,
|
|
750
|
+
* collapses consecutive separators, and trims them from the ends.
|
|
751
|
+
*
|
|
752
|
+
* @param {string} value - The string to slugify.
|
|
753
|
+
* @param {string} [separator='-'] - Character used to join words.
|
|
754
|
+
*
|
|
755
|
+
* @returns {string} - The slugified string, or an empty string if input is invalid.
|
|
756
|
+
*
|
|
757
|
+
* @example
|
|
758
|
+
* {{ 'Hello World!' | slugify }} // 'hello-world'
|
|
759
|
+
* {{ 'Café & Tea' | slugify }} // 'cafe-tea'
|
|
760
|
+
* {{ 'My Blog Post' | slugify:'_' }} // 'my_blog_post'
|
|
761
|
+
*/
|
|
762
|
+
class SlugifyPipe {
|
|
763
|
+
transform(value, separator = '-') {
|
|
764
|
+
if (typeof value !== 'string')
|
|
765
|
+
return '';
|
|
766
|
+
const sep = separator || '-';
|
|
767
|
+
const escaped = sep.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
768
|
+
return value
|
|
769
|
+
.normalize('NFD')
|
|
770
|
+
.replace(/[\u0300-\u036f]/g, '')
|
|
771
|
+
.toLowerCase()
|
|
772
|
+
.replace(/[^a-z0-9]+/g, sep)
|
|
773
|
+
.replace(new RegExp(`${escaped}+`, 'g'), sep)
|
|
774
|
+
.replace(new RegExp(`^${escaped}|${escaped}$`, 'g'), '');
|
|
775
|
+
}
|
|
776
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: SlugifyPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
777
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: SlugifyPipe, isStandalone: true, name: "slugify" });
|
|
778
|
+
}
|
|
779
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: SlugifyPipe, decorators: [{
|
|
780
|
+
type: Pipe,
|
|
781
|
+
args: [{
|
|
782
|
+
name: 'slugify',
|
|
783
|
+
standalone: true,
|
|
784
|
+
}]
|
|
785
|
+
}] });
|
|
786
|
+
|
|
787
|
+
/**
|
|
788
|
+
* StripTagsPipe: Removes HTML tags from a string.
|
|
789
|
+
*
|
|
790
|
+
* By default strips every tag. Pass an array of allowed tag names to keep
|
|
791
|
+
* those specific tags while stripping the rest. HTML comments and DOCTYPEs
|
|
792
|
+
* are always removed.
|
|
793
|
+
*
|
|
794
|
+
* Note: this pipe returns a plain string — the caller is responsible for
|
|
795
|
+
* binding the output safely (e.g. via `[textContent]`). For sanitization
|
|
796
|
+
* that also neutralizes dangerous attributes/scripts, use HtmlSanitizePipe.
|
|
797
|
+
*
|
|
798
|
+
* @param {string} value - The HTML string to strip.
|
|
799
|
+
* @param {string[]} [allowedTags] - Optional list of tag names to preserve.
|
|
800
|
+
*
|
|
801
|
+
* @returns {string} - The stripped string, or empty string if input is invalid.
|
|
802
|
+
*
|
|
803
|
+
* @example
|
|
804
|
+
* {{ '<p>Hi <b>there</b></p>' | stripTags }} // 'Hi there'
|
|
805
|
+
* {{ '<p>Hi <b>bold</b></p>' | stripTags:['b'] }} // 'Hi <b>bold</b>'
|
|
806
|
+
* {{ '<script>alert(1)</script>Safe' | stripTags }} // 'Safe'
|
|
807
|
+
*/
|
|
808
|
+
class StripTagsPipe {
|
|
809
|
+
transform(value, allowedTags) {
|
|
810
|
+
if (typeof value !== 'string')
|
|
811
|
+
return '';
|
|
812
|
+
let result = value
|
|
813
|
+
.replace(/<!--[\s\S]*?-->/g, '')
|
|
814
|
+
.replace(/<!DOCTYPE[^>]*>/gi, '')
|
|
815
|
+
.replace(/<script\b[\s\S]*?<\/script>/gi, '')
|
|
816
|
+
.replace(/<style\b[\s\S]*?<\/style>/gi, '');
|
|
817
|
+
if (!Array.isArray(allowedTags) || allowedTags.length === 0) {
|
|
818
|
+
return result.replace(/<\/?[a-zA-Z][^>]*>/g, '');
|
|
819
|
+
}
|
|
820
|
+
const allowed = allowedTags
|
|
821
|
+
.filter(t => typeof t === 'string' && t.length > 0)
|
|
822
|
+
.map(t => t.toLowerCase().replace(/[^a-z0-9]/g, ''));
|
|
823
|
+
if (allowed.length === 0) {
|
|
824
|
+
return result.replace(/<\/?[a-zA-Z][^>]*>/g, '');
|
|
825
|
+
}
|
|
826
|
+
const pattern = new RegExp(`</?(?!(?:${allowed.join('|')})\\b)[a-zA-Z][^>]*>`, 'gi');
|
|
827
|
+
result = result.replace(pattern, '');
|
|
828
|
+
return result;
|
|
829
|
+
}
|
|
830
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: StripTagsPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
831
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: StripTagsPipe, isStandalone: true, name: "stripTags" });
|
|
832
|
+
}
|
|
833
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: StripTagsPipe, decorators: [{
|
|
834
|
+
type: Pipe,
|
|
835
|
+
args: [{
|
|
836
|
+
name: 'stripTags',
|
|
837
|
+
standalone: true,
|
|
838
|
+
}]
|
|
839
|
+
}] });
|
|
840
|
+
|
|
841
|
+
/**
|
|
842
|
+
* EncodeUriPipe: Encodes a full URI by escaping characters that would be invalid.
|
|
843
|
+
*
|
|
844
|
+
* Wraps the native `encodeURI`. Preserves URI structural characters
|
|
845
|
+
* (`: / ? # [ ] @ ! $ & ' ( ) * + , ; =`) so this is suitable for entire URLs,
|
|
846
|
+
* not for individual query string values (use `encodeURIComponent` for those).
|
|
847
|
+
*
|
|
848
|
+
* @param {string} value - The URI to encode.
|
|
849
|
+
*
|
|
850
|
+
* @returns {string} - The encoded URI, or empty string if input is invalid.
|
|
851
|
+
*
|
|
852
|
+
* @example
|
|
853
|
+
* {{ 'https://example.com/?q=hi world' | encodeURI }} // 'https://example.com/?q=hi%20world'
|
|
854
|
+
* {{ '/path with space.html' | encodeURI }} // '/path%20with%20space.html'
|
|
855
|
+
*/
|
|
856
|
+
class EncodeUriPipe {
|
|
857
|
+
transform(value) {
|
|
858
|
+
if (typeof value !== 'string')
|
|
859
|
+
return '';
|
|
860
|
+
try {
|
|
861
|
+
return encodeURI(value);
|
|
862
|
+
}
|
|
863
|
+
catch {
|
|
864
|
+
return value;
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: EncodeUriPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
868
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: EncodeUriPipe, isStandalone: true, name: "encodeURI" });
|
|
869
|
+
}
|
|
870
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: EncodeUriPipe, decorators: [{
|
|
871
|
+
type: Pipe,
|
|
872
|
+
args: [{
|
|
873
|
+
name: 'encodeURI',
|
|
874
|
+
standalone: true,
|
|
875
|
+
}]
|
|
876
|
+
}] });
|
|
877
|
+
|
|
878
|
+
/**
|
|
879
|
+
* EncodeUriComponentPipe: Encodes a single URI component, escaping reserved characters.
|
|
880
|
+
*
|
|
881
|
+
* Wraps the native `encodeURIComponent`. Encodes everything except
|
|
882
|
+
* `A-Z a-z 0-9 - _ . ! ~ * ' ( )`. Use this for query parameter values,
|
|
883
|
+
* path segments, or anywhere a value must not collide with URL syntax.
|
|
884
|
+
*
|
|
885
|
+
* @param {string} value - The URI component to encode.
|
|
886
|
+
*
|
|
887
|
+
* @returns {string} - The encoded component, or empty string if input is invalid.
|
|
888
|
+
*
|
|
889
|
+
* @example
|
|
890
|
+
* {{ 'hi world&you' | encodeURIComponent }} // 'hi%20world%26you'
|
|
891
|
+
* {{ 'foo/bar?baz=1' | encodeURIComponent }} // 'foo%2Fbar%3Fbaz%3D1'
|
|
892
|
+
*/
|
|
893
|
+
class EncodeUriComponentPipe {
|
|
894
|
+
transform(value) {
|
|
895
|
+
if (typeof value !== 'string')
|
|
896
|
+
return '';
|
|
897
|
+
try {
|
|
898
|
+
return encodeURIComponent(value);
|
|
899
|
+
}
|
|
900
|
+
catch {
|
|
901
|
+
return value;
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: EncodeUriComponentPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
905
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: EncodeUriComponentPipe, isStandalone: true, name: "encodeURIComponent" });
|
|
906
|
+
}
|
|
907
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: EncodeUriComponentPipe, decorators: [{
|
|
908
|
+
type: Pipe,
|
|
909
|
+
args: [{
|
|
910
|
+
name: 'encodeURIComponent',
|
|
911
|
+
standalone: true,
|
|
912
|
+
}]
|
|
913
|
+
}] });
|
|
914
|
+
|
|
915
|
+
/**
|
|
916
|
+
* DecodeUriPipe: Decodes a URI previously encoded with `encodeURI`.
|
|
917
|
+
*
|
|
918
|
+
* Wraps the native `decodeURI`. Returns the input unchanged if the string
|
|
919
|
+
* contains a malformed escape sequence.
|
|
920
|
+
*
|
|
921
|
+
* @param {string} value - The encoded URI to decode.
|
|
922
|
+
*
|
|
923
|
+
* @returns {string} - The decoded URI, or empty string if input is invalid.
|
|
924
|
+
*
|
|
925
|
+
* @example
|
|
926
|
+
* {{ 'https://example.com/?q=hi%20world' | decodeURI }} // 'https://example.com/?q=hi world'
|
|
927
|
+
* {{ '/path%20with%20space.html' | decodeURI }} // '/path with space.html'
|
|
928
|
+
*/
|
|
929
|
+
class DecodeUriPipe {
|
|
930
|
+
transform(value) {
|
|
931
|
+
if (typeof value !== 'string')
|
|
932
|
+
return '';
|
|
933
|
+
try {
|
|
934
|
+
return decodeURI(value);
|
|
935
|
+
}
|
|
936
|
+
catch {
|
|
937
|
+
return value;
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: DecodeUriPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
941
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: DecodeUriPipe, isStandalone: true, name: "decodeURI" });
|
|
942
|
+
}
|
|
943
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: DecodeUriPipe, decorators: [{
|
|
944
|
+
type: Pipe,
|
|
945
|
+
args: [{
|
|
946
|
+
name: 'decodeURI',
|
|
947
|
+
standalone: true,
|
|
948
|
+
}]
|
|
949
|
+
}] });
|
|
950
|
+
|
|
951
|
+
/**
|
|
952
|
+
* DecodeUriComponentPipe: Decodes a URI component encoded with `encodeURIComponent`.
|
|
953
|
+
*
|
|
954
|
+
* Wraps the native `decodeURIComponent`. Returns the input unchanged if the
|
|
955
|
+
* string contains a malformed escape sequence.
|
|
956
|
+
*
|
|
957
|
+
* @param {string} value - The encoded URI component to decode.
|
|
958
|
+
*
|
|
959
|
+
* @returns {string} - The decoded component, or empty string if input is invalid.
|
|
960
|
+
*
|
|
961
|
+
* @example
|
|
962
|
+
* {{ 'hi%20world%26you' | decodeURIComponent }} // 'hi world&you'
|
|
963
|
+
* {{ 'foo%2Fbar%3Fbaz%3D1' | decodeURIComponent }} // 'foo/bar?baz=1'
|
|
964
|
+
*/
|
|
965
|
+
class DecodeUriComponentPipe {
|
|
966
|
+
transform(value) {
|
|
967
|
+
if (typeof value !== 'string')
|
|
968
|
+
return '';
|
|
969
|
+
try {
|
|
970
|
+
return decodeURIComponent(value);
|
|
971
|
+
}
|
|
972
|
+
catch {
|
|
973
|
+
return value;
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: DecodeUriComponentPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
977
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: DecodeUriComponentPipe, isStandalone: true, name: "decodeURIComponent" });
|
|
978
|
+
}
|
|
979
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: DecodeUriComponentPipe, decorators: [{
|
|
980
|
+
type: Pipe,
|
|
981
|
+
args: [{
|
|
982
|
+
name: 'decodeURIComponent',
|
|
983
|
+
standalone: true,
|
|
984
|
+
}]
|
|
985
|
+
}] });
|
|
986
|
+
|
|
987
|
+
/**
|
|
988
|
+
* SplitPipe: Splits a string into an array using the given separator.
|
|
989
|
+
*
|
|
990
|
+
* Wraps `String.prototype.split`. Returns an empty array for invalid inputs.
|
|
991
|
+
*
|
|
992
|
+
* @param {string} value - The string to split.
|
|
993
|
+
* @param {string | RegExp} [separator=''] - Character, string, or regex to split on.
|
|
994
|
+
* An empty separator splits the string into individual characters.
|
|
995
|
+
* @param {number} [limit] - Optional maximum number of elements to return.
|
|
996
|
+
*
|
|
997
|
+
* @returns {string[]} - The resulting array, or an empty array for invalid input.
|
|
998
|
+
*
|
|
999
|
+
* @example
|
|
1000
|
+
* {{ 'a,b,c' | split:',' }} // ['a', 'b', 'c']
|
|
1001
|
+
* {{ 'abc' | split }} // ['a', 'b', 'c']
|
|
1002
|
+
* {{ 'one two three' | split:' ':2 }} // ['one', 'two']
|
|
1003
|
+
*/
|
|
1004
|
+
class SplitPipe {
|
|
1005
|
+
transform(value, separator = '', limit) {
|
|
1006
|
+
if (typeof value !== 'string')
|
|
1007
|
+
return [];
|
|
1008
|
+
if (typeof limit === 'number' && limit >= 0) {
|
|
1009
|
+
return value.split(separator, limit);
|
|
1010
|
+
}
|
|
1011
|
+
return value.split(separator);
|
|
1012
|
+
}
|
|
1013
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: SplitPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
1014
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: SplitPipe, isStandalone: true, name: "split" });
|
|
1015
|
+
}
|
|
1016
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: SplitPipe, decorators: [{
|
|
1017
|
+
type: Pipe,
|
|
1018
|
+
args: [{
|
|
1019
|
+
name: 'split',
|
|
1020
|
+
standalone: true,
|
|
1021
|
+
}]
|
|
1022
|
+
}] });
|
|
1023
|
+
|
|
1024
|
+
/**
|
|
1025
|
+
* MatchPipe: Returns all regex matches found in a string.
|
|
1026
|
+
*
|
|
1027
|
+
* Wraps `String.prototype.match` with a global default. Returns an empty array
|
|
1028
|
+
* when nothing matches or the regex is invalid.
|
|
1029
|
+
*
|
|
1030
|
+
* @param {string} value - The string to search.
|
|
1031
|
+
* @param {string | RegExp} pattern - Pattern string (or RegExp) to match.
|
|
1032
|
+
* @param {string} [flags='g'] - Regex flags used when `pattern` is a string.
|
|
1033
|
+
*
|
|
1034
|
+
* @returns {string[]} - Array of matches, or empty array if none / invalid input.
|
|
1035
|
+
*
|
|
1036
|
+
* @example
|
|
1037
|
+
* {{ 'abc123def456' | match:'[0-9]+' }} // ['123', '456']
|
|
1038
|
+
* {{ 'hello world' | match:'[a-z]+' }} // ['hello', 'world']
|
|
1039
|
+
* {{ 'HELLO' | match:'[a-z]+':'gi' }} // ['HELLO']
|
|
1040
|
+
*/
|
|
1041
|
+
class MatchPipe {
|
|
1042
|
+
transform(value, pattern, flags = 'g') {
|
|
1043
|
+
if (typeof value !== 'string' || !pattern)
|
|
1044
|
+
return [];
|
|
1045
|
+
try {
|
|
1046
|
+
const regex = typeof pattern === 'string'
|
|
1047
|
+
? new RegExp(pattern, flags.includes('g') ? flags : flags + 'g')
|
|
1048
|
+
: (pattern.flags.includes('g') ? pattern : new RegExp(pattern.source, pattern.flags + 'g'));
|
|
1049
|
+
const matches = value.match(regex);
|
|
1050
|
+
return matches ?? [];
|
|
1051
|
+
}
|
|
1052
|
+
catch {
|
|
1053
|
+
return [];
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: MatchPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
1057
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: MatchPipe, isStandalone: true, name: "match" });
|
|
1058
|
+
}
|
|
1059
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: MatchPipe, decorators: [{
|
|
1060
|
+
type: Pipe,
|
|
1061
|
+
args: [{
|
|
1062
|
+
name: 'match',
|
|
1063
|
+
standalone: true,
|
|
1064
|
+
}]
|
|
1065
|
+
}] });
|
|
1066
|
+
|
|
1067
|
+
/**
|
|
1068
|
+
* TestPipe: Returns true when a string matches a regex pattern.
|
|
1069
|
+
*
|
|
1070
|
+
* Wraps `RegExp.prototype.test`. Returns false for invalid input or regex.
|
|
1071
|
+
*
|
|
1072
|
+
* @param {string} value - The string to test.
|
|
1073
|
+
* @param {string | RegExp} pattern - Pattern string (or RegExp) to test against.
|
|
1074
|
+
* @param {string} [flags=''] - Regex flags used when `pattern` is a string.
|
|
1075
|
+
*
|
|
1076
|
+
* @returns {boolean} - `true` if the pattern matches anywhere in the string.
|
|
1077
|
+
*
|
|
1078
|
+
* @example
|
|
1079
|
+
* {{ 'abc@x.com' | test:'@' }} // true
|
|
1080
|
+
* {{ 'ABC' | test:'[a-z]':'i' }} // true
|
|
1081
|
+
* {{ '123' | test:'^[0-9]+$' }} // true
|
|
1082
|
+
*/
|
|
1083
|
+
class TestPipe {
|
|
1084
|
+
transform(value, pattern, flags = '') {
|
|
1085
|
+
if (typeof value !== 'string' || !pattern)
|
|
1086
|
+
return false;
|
|
1087
|
+
try {
|
|
1088
|
+
const regex = typeof pattern === 'string'
|
|
1089
|
+
? new RegExp(pattern, flags)
|
|
1090
|
+
: pattern;
|
|
1091
|
+
return regex.test(value);
|
|
1092
|
+
}
|
|
1093
|
+
catch {
|
|
1094
|
+
return false;
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: TestPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
1098
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: TestPipe, isStandalone: true, name: "test" });
|
|
1099
|
+
}
|
|
1100
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: TestPipe, decorators: [{
|
|
1101
|
+
type: Pipe,
|
|
1102
|
+
args: [{
|
|
1103
|
+
name: 'test',
|
|
1104
|
+
standalone: true,
|
|
1105
|
+
}]
|
|
1106
|
+
}] });
|
|
1107
|
+
|
|
1108
|
+
/**
|
|
1109
|
+
* NewlinesPipe: Replaces line breaks in a string with a custom replacement.
|
|
1110
|
+
*
|
|
1111
|
+
* Handles all common line-break variants (`\n`, `\r\n`, `\r`). Defaults to
|
|
1112
|
+
* `<br>` for HTML display via `[innerHTML]`. Pass any string to customize.
|
|
1113
|
+
*
|
|
1114
|
+
* @param {string} value - The string containing line breaks.
|
|
1115
|
+
* @param {string} [replacement='<br>'] - String inserted in place of each line break.
|
|
1116
|
+
*
|
|
1117
|
+
* @returns {string} - The transformed string, or empty string if input is invalid.
|
|
1118
|
+
*
|
|
1119
|
+
* @example
|
|
1120
|
+
* {{ text | newlines }} // 'a<br>b<br>c' (use [innerHTML])
|
|
1121
|
+
* {{ text | newlines:' | ' }} // 'a | b | c'
|
|
1122
|
+
* {{ text | newlines:' ' }} // 'a b c' (flatten to single line)
|
|
1123
|
+
*/
|
|
1124
|
+
class NewlinesPipe {
|
|
1125
|
+
transform(value, replacement = '<br>') {
|
|
1126
|
+
if (typeof value !== 'string')
|
|
1127
|
+
return '';
|
|
1128
|
+
return value.replace(/\r\n|\r|\n/g, replacement);
|
|
1129
|
+
}
|
|
1130
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: NewlinesPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
1131
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: NewlinesPipe, isStandalone: true, name: "newlines" });
|
|
1132
|
+
}
|
|
1133
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: NewlinesPipe, decorators: [{
|
|
1134
|
+
type: Pipe,
|
|
1135
|
+
args: [{
|
|
1136
|
+
name: 'newlines',
|
|
1137
|
+
standalone: true,
|
|
1138
|
+
}]
|
|
1139
|
+
}] });
|
|
1140
|
+
|
|
1141
|
+
/**
|
|
1142
|
+
* TemplatePipe: Replaces `{key}` placeholders in a string with values from an object.
|
|
1143
|
+
*
|
|
1144
|
+
* Supports dot notation for nested keys. Missing keys are left as-is.
|
|
1145
|
+
*
|
|
1146
|
+
* @param {string} value - The template string containing placeholders like `{name}`.
|
|
1147
|
+
* @param {Record<string, unknown>} [values={}] - Map of keys to replacement values.
|
|
1148
|
+
*
|
|
1149
|
+
* @returns {string} - The interpolated string, or empty string if input is invalid.
|
|
1150
|
+
*
|
|
1151
|
+
* @example
|
|
1152
|
+
* {{ 'Hello {name}!' | template:{name:'Alice'} }} // 'Hello Alice!'
|
|
1153
|
+
* {{ '{user.name} is {user.age}' | template:{user:{name:'Bob',age:30}} }} // 'Bob is 30'
|
|
1154
|
+
* {{ 'Hi {missing}!' | template:{name:'Alice'} }} // 'Hi {missing}!'
|
|
1155
|
+
*/
|
|
1156
|
+
class TemplatePipe {
|
|
1157
|
+
transform(value, values = {}) {
|
|
1158
|
+
if (typeof value !== 'string')
|
|
1159
|
+
return '';
|
|
1160
|
+
if (!values || typeof values !== 'object')
|
|
1161
|
+
return value;
|
|
1162
|
+
return value.replace(/\{([\w.]+)\}/g, (match, key) => {
|
|
1163
|
+
const resolved = this.getNestedValue(values, key);
|
|
1164
|
+
return resolved === undefined || resolved === null ? match : String(resolved);
|
|
1165
|
+
});
|
|
1166
|
+
}
|
|
1167
|
+
getNestedValue(obj, path) {
|
|
1168
|
+
return path.split('.').reduce((current, segment) => current?.[segment], obj);
|
|
1169
|
+
}
|
|
1170
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: TemplatePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
1171
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: TemplatePipe, isStandalone: true, name: "template" });
|
|
1172
|
+
}
|
|
1173
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: TemplatePipe, decorators: [{
|
|
1174
|
+
type: Pipe,
|
|
1175
|
+
args: [{
|
|
1176
|
+
name: 'template',
|
|
1177
|
+
standalone: true,
|
|
1178
|
+
}]
|
|
1179
|
+
}] });
|
|
1180
|
+
|
|
1181
|
+
/**
|
|
1182
|
+
* LatinizePipe: Strips diacritics (accents) from a string while preserving
|
|
1183
|
+
* casing, spaces, and punctuation.
|
|
1184
|
+
*
|
|
1185
|
+
* Uses Unicode NFD normalization to split combining marks from base letters,
|
|
1186
|
+
* then removes the combining mark range (U+0300–U+036F). Unlike `slugify`,
|
|
1187
|
+
* this pipe leaves the string structure intact — it only removes accents.
|
|
1188
|
+
*
|
|
1189
|
+
* @param {string} value - The string to latinize.
|
|
1190
|
+
*
|
|
1191
|
+
* @returns {string} - The latinized string, or empty string if input is invalid.
|
|
1192
|
+
*
|
|
1193
|
+
* @example
|
|
1194
|
+
* {{ 'Café' | latinize }} // 'Cafe'
|
|
1195
|
+
* {{ 'naïve résumé' | latinize }} // 'naive resume'
|
|
1196
|
+
* {{ 'Crème Brûlée' | latinize }} // 'Creme Brulee'
|
|
1197
|
+
*/
|
|
1198
|
+
class LatinizePipe {
|
|
1199
|
+
transform(value) {
|
|
1200
|
+
if (typeof value !== 'string')
|
|
1201
|
+
return '';
|
|
1202
|
+
return value.normalize('NFD').replace(/[̀-ͯ]/g, '');
|
|
1203
|
+
}
|
|
1204
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: LatinizePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
1205
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: LatinizePipe, isStandalone: true, name: "latinize" });
|
|
1206
|
+
}
|
|
1207
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: LatinizePipe, decorators: [{
|
|
1208
|
+
type: Pipe,
|
|
1209
|
+
args: [{
|
|
1210
|
+
name: 'latinize',
|
|
1211
|
+
standalone: true,
|
|
1212
|
+
}]
|
|
1213
|
+
}] });
|
|
1214
|
+
|
|
1215
|
+
/**
|
|
1216
|
+
* WrapPipe: Surrounds a string with a prefix and optional suffix.
|
|
1217
|
+
*
|
|
1218
|
+
* When no suffix is provided, the prefix is used on both sides.
|
|
1219
|
+
*
|
|
1220
|
+
* @param {string} value - The string to wrap.
|
|
1221
|
+
* @param {string} [prefix=''] - Text to place before the value.
|
|
1222
|
+
* @param {string} [suffix] - Text to place after the value (defaults to prefix).
|
|
1223
|
+
*
|
|
1224
|
+
* @returns {string} - The wrapped string, or empty string if input is invalid.
|
|
1225
|
+
*
|
|
1226
|
+
* @example
|
|
1227
|
+
* {{ 'value' | wrap:'[':']' }} // '[value]'
|
|
1228
|
+
* {{ 'bold' | wrap:'**' }} // '**bold**'
|
|
1229
|
+
* {{ 'tag' | wrap:'<':'>' }} // '<tag>'
|
|
1230
|
+
*/
|
|
1231
|
+
class WrapPipe {
|
|
1232
|
+
transform(value, prefix = '', suffix) {
|
|
1233
|
+
if (typeof value !== 'string')
|
|
1234
|
+
return '';
|
|
1235
|
+
const pfx = typeof prefix === 'string' ? prefix : '';
|
|
1236
|
+
const sfx = suffix === undefined
|
|
1237
|
+
? pfx
|
|
1238
|
+
: (typeof suffix === 'string' ? suffix : '');
|
|
1239
|
+
return `${pfx}${value}${sfx}`;
|
|
1240
|
+
}
|
|
1241
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: WrapPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
1242
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: WrapPipe, isStandalone: true, name: "wrap" });
|
|
1243
|
+
}
|
|
1244
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: WrapPipe, decorators: [{
|
|
1245
|
+
type: Pipe,
|
|
1246
|
+
args: [{
|
|
1247
|
+
name: 'wrap',
|
|
1248
|
+
standalone: true,
|
|
1249
|
+
}]
|
|
1250
|
+
}] });
|
|
1251
|
+
|
|
1252
|
+
/**
|
|
1253
|
+
* KeysPipe: Returns the own enumerable property names of an object as an array.
|
|
1254
|
+
*
|
|
1255
|
+
* Wraps `Object.keys`. Works on plain objects and arrays. Returns an empty array
|
|
1256
|
+
* for null, undefined, or primitive inputs.
|
|
1257
|
+
*
|
|
1258
|
+
* @param {unknown} value - The object whose keys to extract.
|
|
1259
|
+
*
|
|
1260
|
+
* @returns {string[]} - Array of property names, or an empty array if invalid input.
|
|
1261
|
+
*
|
|
1262
|
+
* @example
|
|
1263
|
+
* {{ { a: 1, b: 2, c: 3 } | keys }} // ['a', 'b', 'c']
|
|
1264
|
+
* {{ user | keys }} // ['name', 'age', 'email']
|
|
1265
|
+
* @for (key of obj | keys; track key) { ... }
|
|
1266
|
+
*/
|
|
1267
|
+
class KeysPipe {
|
|
1268
|
+
transform(value) {
|
|
1269
|
+
if (value === null || value === undefined)
|
|
1270
|
+
return [];
|
|
1271
|
+
if (typeof value !== 'object')
|
|
1272
|
+
return [];
|
|
1273
|
+
return Object.keys(value);
|
|
1274
|
+
}
|
|
1275
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: KeysPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
1276
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: KeysPipe, isStandalone: true, name: "keys" });
|
|
1277
|
+
}
|
|
1278
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: KeysPipe, decorators: [{
|
|
1279
|
+
type: Pipe,
|
|
1280
|
+
args: [{
|
|
1281
|
+
name: 'keys',
|
|
1282
|
+
standalone: true,
|
|
1283
|
+
}]
|
|
1284
|
+
}] });
|
|
1285
|
+
|
|
1286
|
+
/**
|
|
1287
|
+
* ValuesPipe: Returns the own enumerable property values of an object as an array.
|
|
1288
|
+
*
|
|
1289
|
+
* Wraps `Object.values`. Works on plain objects and arrays. Returns an empty array
|
|
1290
|
+
* for null, undefined, or primitive inputs.
|
|
1291
|
+
*
|
|
1292
|
+
* @param {unknown} value - The object whose values to extract.
|
|
1293
|
+
*
|
|
1294
|
+
* @returns {unknown[]} - Array of property values, or an empty array if invalid input.
|
|
1295
|
+
*
|
|
1296
|
+
* @example
|
|
1297
|
+
* {{ { a: 1, b: 2, c: 3 } | values }} // [1, 2, 3]
|
|
1298
|
+
* {{ user | values }} // ['Alice', 30, 'a@b.com']
|
|
1299
|
+
* @for (val of obj | values; track $index) { ... }
|
|
1300
|
+
*/
|
|
1301
|
+
class ValuesPipe {
|
|
1302
|
+
transform(value) {
|
|
1303
|
+
if (value === null || value === undefined)
|
|
1304
|
+
return [];
|
|
1305
|
+
if (typeof value !== 'object')
|
|
1306
|
+
return [];
|
|
1307
|
+
return Object.values(value);
|
|
1308
|
+
}
|
|
1309
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: ValuesPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
1310
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: ValuesPipe, isStandalone: true, name: "values" });
|
|
1311
|
+
}
|
|
1312
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: ValuesPipe, decorators: [{
|
|
1313
|
+
type: Pipe,
|
|
1314
|
+
args: [{
|
|
1315
|
+
name: 'values',
|
|
1316
|
+
standalone: true,
|
|
1317
|
+
}]
|
|
1318
|
+
}] });
|
|
1319
|
+
|
|
1320
|
+
/**
|
|
1321
|
+
* PairsPipe: Returns the own enumerable properties of an object as an array of
|
|
1322
|
+
* [key, value] tuples.
|
|
1323
|
+
*
|
|
1324
|
+
* Wraps `Object.entries`. Works on plain objects and arrays. Returns an empty
|
|
1325
|
+
* array for null, undefined, or primitive inputs.
|
|
1326
|
+
*
|
|
1327
|
+
* @param {unknown} value - The object to convert into key/value pairs.
|
|
1328
|
+
*
|
|
1329
|
+
* @returns {[string, unknown][]} - Array of [key, value] tuples, or empty array.
|
|
1330
|
+
*
|
|
1331
|
+
* @example
|
|
1332
|
+
* {{ { a: 1, b: 2 } | pairs }} // [['a', 1], ['b', 2]]
|
|
1333
|
+
* @for (entry of user | pairs; track entry[0]) {
|
|
1334
|
+
* <li>{{ entry[0] }}: {{ entry[1] }}</li>
|
|
1335
|
+
* }
|
|
1336
|
+
*/
|
|
1337
|
+
class PairsPipe {
|
|
1338
|
+
transform(value) {
|
|
1339
|
+
if (value === null || value === undefined)
|
|
1340
|
+
return [];
|
|
1341
|
+
if (typeof value !== 'object')
|
|
1342
|
+
return [];
|
|
1343
|
+
return Object.entries(value);
|
|
1344
|
+
}
|
|
1345
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: PairsPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
1346
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: PairsPipe, isStandalone: true, name: "pairs" });
|
|
1347
|
+
}
|
|
1348
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: PairsPipe, decorators: [{
|
|
1349
|
+
type: Pipe,
|
|
1350
|
+
args: [{
|
|
1351
|
+
name: 'pairs',
|
|
1352
|
+
standalone: true,
|
|
1353
|
+
}]
|
|
1354
|
+
}] });
|
|
1355
|
+
|
|
1356
|
+
/**
|
|
1357
|
+
* PickPipe: Returns a new object containing only the specified keys.
|
|
1358
|
+
*
|
|
1359
|
+
* Non-existent keys are skipped silently. Returns an empty object for null,
|
|
1360
|
+
* undefined, or primitive inputs. Does not mutate the input.
|
|
1361
|
+
*
|
|
1362
|
+
* @param {unknown} value - The source object.
|
|
1363
|
+
* @param {string[] | string} keys - Key (or array of keys) to keep.
|
|
1364
|
+
*
|
|
1365
|
+
* @returns {Record<string, unknown>} - A new object with only the picked keys.
|
|
1366
|
+
*
|
|
1367
|
+
* @example
|
|
1368
|
+
* {{ user | pick:['name', 'email'] }} // { name: 'Alice', email: 'a@b.com' }
|
|
1369
|
+
* {{ obj | pick:'id' }} // { id: 42 }
|
|
1370
|
+
*/
|
|
1371
|
+
class PickPipe {
|
|
1372
|
+
transform(value, keys) {
|
|
1373
|
+
if (value === null || value === undefined)
|
|
1374
|
+
return {};
|
|
1375
|
+
if (typeof value !== 'object')
|
|
1376
|
+
return {};
|
|
1377
|
+
const list = Array.isArray(keys) ? keys : (typeof keys === 'string' ? [keys] : []);
|
|
1378
|
+
if (list.length === 0)
|
|
1379
|
+
return {};
|
|
1380
|
+
const source = value;
|
|
1381
|
+
const result = {};
|
|
1382
|
+
for (const key of list) {
|
|
1383
|
+
if (typeof key !== 'string')
|
|
1384
|
+
continue;
|
|
1385
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
1386
|
+
result[key] = source[key];
|
|
1387
|
+
}
|
|
1388
|
+
}
|
|
1389
|
+
return result;
|
|
1390
|
+
}
|
|
1391
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: PickPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
1392
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: PickPipe, isStandalone: true, name: "pick" });
|
|
1393
|
+
}
|
|
1394
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: PickPipe, decorators: [{
|
|
1395
|
+
type: Pipe,
|
|
1396
|
+
args: [{
|
|
1397
|
+
name: 'pick',
|
|
1398
|
+
standalone: true,
|
|
1399
|
+
}]
|
|
1400
|
+
}] });
|
|
1401
|
+
|
|
1402
|
+
/**
|
|
1403
|
+
* OmitPipe: Returns a new object with the specified keys removed.
|
|
1404
|
+
*
|
|
1405
|
+
* Keys that don't exist on the source are ignored. Returns an empty object
|
|
1406
|
+
* for null, undefined, or primitive inputs. Does not mutate the input.
|
|
1407
|
+
*
|
|
1408
|
+
* @param {unknown} value - The source object.
|
|
1409
|
+
* @param {string[] | string} keys - Key (or array of keys) to remove.
|
|
1410
|
+
*
|
|
1411
|
+
* @returns {Record<string, unknown>} - A new object without the omitted keys.
|
|
1412
|
+
*
|
|
1413
|
+
* @example
|
|
1414
|
+
* {{ user | omit:['password'] }} // user without password
|
|
1415
|
+
* {{ obj | omit:['internal', '_id'] }} // public-safe view
|
|
1416
|
+
*/
|
|
1417
|
+
class OmitPipe {
|
|
1418
|
+
transform(value, keys) {
|
|
1419
|
+
if (value === null || value === undefined)
|
|
1420
|
+
return {};
|
|
1421
|
+
if (typeof value !== 'object')
|
|
1422
|
+
return {};
|
|
1423
|
+
const list = Array.isArray(keys) ? keys : (typeof keys === 'string' ? [keys] : []);
|
|
1424
|
+
const exclude = new Set(list.filter((k) => typeof k === 'string'));
|
|
1425
|
+
const source = value;
|
|
1426
|
+
const result = {};
|
|
1427
|
+
for (const key of Object.keys(source)) {
|
|
1428
|
+
if (!exclude.has(key)) {
|
|
1429
|
+
result[key] = source[key];
|
|
1430
|
+
}
|
|
1431
|
+
}
|
|
1432
|
+
return result;
|
|
1433
|
+
}
|
|
1434
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: OmitPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
1435
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: OmitPipe, isStandalone: true, name: "omit" });
|
|
1436
|
+
}
|
|
1437
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: OmitPipe, decorators: [{
|
|
1438
|
+
type: Pipe,
|
|
1439
|
+
args: [{
|
|
1440
|
+
name: 'omit',
|
|
1441
|
+
standalone: true,
|
|
1442
|
+
}]
|
|
1443
|
+
}] });
|
|
1444
|
+
|
|
1445
|
+
/**
|
|
1446
|
+
* InvertPipe: Returns a new object with keys and values swapped.
|
|
1447
|
+
*
|
|
1448
|
+
* Values are coerced to strings to become valid keys. When two source keys
|
|
1449
|
+
* share a value, the **last one wins** (use `invertBy` if you need to keep
|
|
1450
|
+
* every collision as an array). Returns an empty object for null, undefined,
|
|
1451
|
+
* or primitive inputs. Does not mutate the input.
|
|
1452
|
+
*
|
|
1453
|
+
* @param {unknown} value - The source object.
|
|
1454
|
+
*
|
|
1455
|
+
* @returns {Record<string, string>} - A new object with keys/values swapped.
|
|
1456
|
+
*
|
|
1457
|
+
* @example
|
|
1458
|
+
* {{ { a: 1, b: 2 } | invert }} // { '1': 'a', '2': 'b' }
|
|
1459
|
+
* {{ { en: 'hello', fr: 'bonjour' } | invert }} // { hello: 'en', bonjour: 'fr' }
|
|
1460
|
+
* {{ { a: 1, b: 1 } | invert }} // { '1': 'b' } (last wins)
|
|
1461
|
+
*/
|
|
1462
|
+
class InvertPipe {
|
|
1463
|
+
transform(value) {
|
|
1464
|
+
if (value === null || value === undefined)
|
|
1465
|
+
return {};
|
|
1466
|
+
if (typeof value !== 'object')
|
|
1467
|
+
return {};
|
|
1468
|
+
const source = value;
|
|
1469
|
+
const result = {};
|
|
1470
|
+
for (const key of Object.keys(source)) {
|
|
1471
|
+
const v = source[key];
|
|
1472
|
+
if (v === undefined)
|
|
1473
|
+
continue;
|
|
1474
|
+
result[String(v)] = key;
|
|
1475
|
+
}
|
|
1476
|
+
return result;
|
|
1477
|
+
}
|
|
1478
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: InvertPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
1479
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: InvertPipe, isStandalone: true, name: "invert" });
|
|
1480
|
+
}
|
|
1481
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: InvertPipe, decorators: [{
|
|
1482
|
+
type: Pipe,
|
|
1483
|
+
args: [{
|
|
1484
|
+
name: 'invert',
|
|
1485
|
+
standalone: true,
|
|
1486
|
+
}]
|
|
1487
|
+
}] });
|
|
1488
|
+
|
|
1489
|
+
/**
|
|
1490
|
+
* InvertByPipe: Returns a new object with values as keys, grouping the original
|
|
1491
|
+
* keys for each value into an array.
|
|
1492
|
+
*
|
|
1493
|
+
* Unlike `invert`, no data is lost when multiple source keys share a value —
|
|
1494
|
+
* they're collected into an array under the shared key.
|
|
1495
|
+
*
|
|
1496
|
+
* @param {unknown} value - The source object.
|
|
1497
|
+
*
|
|
1498
|
+
* @returns {Record<string, string[]>} - A new object with values-as-keys
|
|
1499
|
+
* pointing at arrays of the original keys.
|
|
1500
|
+
*
|
|
1501
|
+
* @example
|
|
1502
|
+
* {{ { a: 1, b: 2, c: 1 } | invertBy }} // { '1': ['a', 'c'], '2': ['b'] }
|
|
1503
|
+
* {{ { alice: 'admin', bob: 'user', carol: 'admin' } | invertBy }}
|
|
1504
|
+
* // { admin: ['alice', 'carol'], user: ['bob'] }
|
|
1505
|
+
*/
|
|
1506
|
+
class InvertByPipe {
|
|
1507
|
+
transform(value) {
|
|
1508
|
+
if (value === null || value === undefined)
|
|
1509
|
+
return {};
|
|
1510
|
+
if (typeof value !== 'object')
|
|
1511
|
+
return {};
|
|
1512
|
+
const source = value;
|
|
1513
|
+
const result = {};
|
|
1514
|
+
for (const key of Object.keys(source)) {
|
|
1515
|
+
const v = source[key];
|
|
1516
|
+
if (v === undefined)
|
|
1517
|
+
continue;
|
|
1518
|
+
const stringKey = String(v);
|
|
1519
|
+
if (!result[stringKey])
|
|
1520
|
+
result[stringKey] = [];
|
|
1521
|
+
result[stringKey].push(key);
|
|
1522
|
+
}
|
|
1523
|
+
return result;
|
|
1524
|
+
}
|
|
1525
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: InvertByPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
1526
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: InvertByPipe, isStandalone: true, name: "invertBy" });
|
|
1527
|
+
}
|
|
1528
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: InvertByPipe, decorators: [{
|
|
1529
|
+
type: Pipe,
|
|
1530
|
+
args: [{
|
|
1531
|
+
name: 'invertBy',
|
|
1532
|
+
standalone: true,
|
|
1533
|
+
}]
|
|
1534
|
+
}] });
|
|
1535
|
+
|
|
1536
|
+
/**
|
|
1537
|
+
* DiffObjPipe: Returns the slice of `value` whose properties differ from `compareTo`.
|
|
1538
|
+
*
|
|
1539
|
+
* For each key in `value`, the entry is included in the result when:
|
|
1540
|
+
* - The key is missing from `compareTo`, or
|
|
1541
|
+
* - `value[key]` is not strictly equal (`!==`) to `compareTo[key]`.
|
|
1542
|
+
*
|
|
1543
|
+
* Comparison is shallow — nested objects/arrays are compared by reference.
|
|
1544
|
+
*
|
|
1545
|
+
* @param {unknown} value - The source object.
|
|
1546
|
+
* @param {unknown} compareTo - The object to compare against.
|
|
1547
|
+
*
|
|
1548
|
+
* @returns {Record<string, unknown>} - A new object containing the differing entries.
|
|
1549
|
+
*
|
|
1550
|
+
* @example
|
|
1551
|
+
* {{ { a: 1, b: 2 } | diffObj:{ a: 1, b: 99 } }} // { b: 2 }
|
|
1552
|
+
* {{ { a: 1, b: 2, c: 3 } | diffObj:{ a: 1 } }} // { b: 2, c: 3 }
|
|
1553
|
+
* {{ { a: 1 } | diffObj:{ a: 1 } }} // {} (no differences)
|
|
1554
|
+
*/
|
|
1555
|
+
class DiffObjPipe {
|
|
1556
|
+
transform(value, compareTo) {
|
|
1557
|
+
if (value === null || value === undefined)
|
|
1558
|
+
return {};
|
|
1559
|
+
if (typeof value !== 'object')
|
|
1560
|
+
return {};
|
|
1561
|
+
const source = value;
|
|
1562
|
+
if (compareTo === null || compareTo === undefined || typeof compareTo !== 'object') {
|
|
1563
|
+
return { ...source };
|
|
1564
|
+
}
|
|
1565
|
+
const target = compareTo;
|
|
1566
|
+
const result = {};
|
|
1567
|
+
for (const key of Object.keys(source)) {
|
|
1568
|
+
if (!Object.prototype.hasOwnProperty.call(target, key) || source[key] !== target[key]) {
|
|
1569
|
+
result[key] = source[key];
|
|
1570
|
+
}
|
|
1571
|
+
}
|
|
1572
|
+
return result;
|
|
1573
|
+
}
|
|
1574
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: DiffObjPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
1575
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: DiffObjPipe, isStandalone: true, name: "diffObj" });
|
|
1576
|
+
}
|
|
1577
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: DiffObjPipe, decorators: [{
|
|
1578
|
+
type: Pipe,
|
|
1579
|
+
args: [{
|
|
1580
|
+
name: 'diffObj',
|
|
1581
|
+
standalone: true,
|
|
1582
|
+
}]
|
|
1583
|
+
}] });
|
|
1584
|
+
|
|
1585
|
+
/**
|
|
1586
|
+
* IsDefinedPipe: Returns `true` when the value is neither `null` nor `undefined`.
|
|
1587
|
+
*
|
|
1588
|
+
* Useful for guarding optional bindings in templates without resorting to
|
|
1589
|
+
* verbose `value !== null && value !== undefined` checks. Empty strings,
|
|
1590
|
+
* `0`, and `false` are all considered defined.
|
|
1591
|
+
*
|
|
1592
|
+
* @param {unknown} value - The value to test.
|
|
1593
|
+
*
|
|
1594
|
+
* @returns {boolean} - `true` if defined, `false` if null/undefined.
|
|
1595
|
+
*
|
|
1596
|
+
* @example
|
|
1597
|
+
* {{ user | isDefined }} // true when user is set
|
|
1598
|
+
* {{ 0 | isDefined }} // true
|
|
1599
|
+
* {{ '' | isDefined }} // true
|
|
1600
|
+
* {{ null | isDefined }} // false
|
|
1601
|
+
* {{ undefined | isDefined }} // false
|
|
1602
|
+
*/
|
|
1603
|
+
class IsDefinedPipe {
|
|
1604
|
+
transform(value) {
|
|
1605
|
+
return value !== null && value !== undefined;
|
|
1606
|
+
}
|
|
1607
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: IsDefinedPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
1608
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: IsDefinedPipe, isStandalone: true, name: "isDefined" });
|
|
1609
|
+
}
|
|
1610
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: IsDefinedPipe, decorators: [{
|
|
1611
|
+
type: Pipe,
|
|
1612
|
+
args: [{
|
|
1613
|
+
name: 'isDefined',
|
|
1614
|
+
standalone: true,
|
|
1615
|
+
}]
|
|
1616
|
+
}] });
|
|
1617
|
+
|
|
1618
|
+
/**
|
|
1619
|
+
* IsNullPipe: Returns `true` only when the value is exactly `null`.
|
|
1620
|
+
*
|
|
1621
|
+
* Strict check — `undefined` returns `false`. Use `isDefined` (with `!`) if
|
|
1622
|
+
* you want to catch both null and undefined together.
|
|
1623
|
+
*
|
|
1624
|
+
* @param {unknown} value - The value to test.
|
|
1625
|
+
*
|
|
1626
|
+
* @returns {boolean} - `true` if the value is null, `false` otherwise.
|
|
1627
|
+
*
|
|
1628
|
+
* @example
|
|
1629
|
+
* {{ null | isNull }} // true
|
|
1630
|
+
* {{ undefined | isNull }} // false
|
|
1631
|
+
* {{ 0 | isNull }} // false
|
|
1632
|
+
* {{ '' | isNull }} // false
|
|
1633
|
+
*/
|
|
1634
|
+
class IsNullPipe {
|
|
1635
|
+
transform(value) {
|
|
1636
|
+
return value === null;
|
|
1637
|
+
}
|
|
1638
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: IsNullPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
1639
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: IsNullPipe, isStandalone: true, name: "isNull" });
|
|
1640
|
+
}
|
|
1641
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: IsNullPipe, decorators: [{
|
|
1642
|
+
type: Pipe,
|
|
1643
|
+
args: [{
|
|
1644
|
+
name: 'isNull',
|
|
1645
|
+
standalone: true,
|
|
1646
|
+
}]
|
|
1647
|
+
}] });
|
|
1648
|
+
|
|
1649
|
+
/**
|
|
1650
|
+
* IsStringPipe: Returns `true` when the value is a primitive string.
|
|
1651
|
+
*
|
|
1652
|
+
* Uses `typeof value === 'string'` — boxed `String` objects (rare) are not
|
|
1653
|
+
* matched. Useful for polymorphic templates that render values from JSON,
|
|
1654
|
+
* dynamic forms, or `unknown`-typed data.
|
|
1655
|
+
*
|
|
1656
|
+
* @param {unknown} value - The value to test.
|
|
1657
|
+
*
|
|
1658
|
+
* @returns {boolean} - `true` if the value is a string primitive, `false` otherwise.
|
|
1659
|
+
*
|
|
1660
|
+
* @example
|
|
1661
|
+
* {{ 'hello' | isString }} // true
|
|
1662
|
+
* {{ '' | isString }} // true
|
|
1663
|
+
* {{ 42 | isString }} // false
|
|
1664
|
+
* {{ null | isString }} // false
|
|
1665
|
+
*/
|
|
1666
|
+
class IsStringPipe {
|
|
1667
|
+
transform(value) {
|
|
1668
|
+
return typeof value === 'string';
|
|
1669
|
+
}
|
|
1670
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: IsStringPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
1671
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: IsStringPipe, isStandalone: true, name: "isString" });
|
|
1672
|
+
}
|
|
1673
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: IsStringPipe, decorators: [{
|
|
1674
|
+
type: Pipe,
|
|
1675
|
+
args: [{
|
|
1676
|
+
name: 'isString',
|
|
1677
|
+
standalone: true,
|
|
1678
|
+
}]
|
|
1679
|
+
}] });
|
|
1680
|
+
|
|
1681
|
+
/**
|
|
1682
|
+
* IsNumberPipe: Returns `true` when the value is a primitive number.
|
|
1683
|
+
*
|
|
1684
|
+
* Uses `typeof value === 'number'`. By design `NaN` returns `true` because
|
|
1685
|
+
* its type is `number` — if you need a finite-only check, follow up with
|
|
1686
|
+
* `Number.isFinite`. Numeric strings (e.g. `'42'`) return `false`.
|
|
1687
|
+
*
|
|
1688
|
+
* @param {unknown} value - The value to test.
|
|
1689
|
+
*
|
|
1690
|
+
* @returns {boolean} - `true` if the value is a number primitive, `false` otherwise.
|
|
1691
|
+
*
|
|
1692
|
+
* @example
|
|
1693
|
+
* {{ 42 | isNumber }} // true
|
|
1694
|
+
* {{ 0 | isNumber }} // true
|
|
1695
|
+
* {{ NaN | isNumber }} // true
|
|
1696
|
+
* {{ '42' | isNumber }} // false
|
|
1697
|
+
* {{ null | isNumber }} // false
|
|
1698
|
+
*/
|
|
1699
|
+
class IsNumberPipe {
|
|
1700
|
+
transform(value) {
|
|
1701
|
+
return typeof value === 'number';
|
|
1702
|
+
}
|
|
1703
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: IsNumberPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
1704
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: IsNumberPipe, isStandalone: true, name: "isNumber" });
|
|
1705
|
+
}
|
|
1706
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: IsNumberPipe, decorators: [{
|
|
1707
|
+
type: Pipe,
|
|
1708
|
+
args: [{
|
|
1709
|
+
name: 'isNumber',
|
|
1710
|
+
standalone: true,
|
|
1711
|
+
}]
|
|
1712
|
+
}] });
|
|
1713
|
+
|
|
1714
|
+
/**
|
|
1715
|
+
* IsArrayPipe: Returns `true` when the value is an Array.
|
|
1716
|
+
*
|
|
1717
|
+
* Backed by `Array.isArray`, so array-likes (NodeList, HTMLCollection,
|
|
1718
|
+
* arguments, typed arrays) all return `false`. Use it to discriminate between
|
|
1719
|
+
* structural and scalar inputs in polymorphic templates.
|
|
1720
|
+
*
|
|
1721
|
+
* @param {unknown} value - The value to test.
|
|
1722
|
+
*
|
|
1723
|
+
* @returns {boolean} - `true` if the value is an array, `false` otherwise.
|
|
1724
|
+
*
|
|
1725
|
+
* @example
|
|
1726
|
+
* {{ [1, 2, 3] | isArray }} // true
|
|
1727
|
+
* {{ [] | isArray }} // true
|
|
1728
|
+
* {{ 'abc' | isArray }} // false
|
|
1729
|
+
* {{ { length: 0 } | isArray }} // false
|
|
1730
|
+
*/
|
|
1731
|
+
class IsArrayPipe {
|
|
1732
|
+
transform(value) {
|
|
1733
|
+
return Array.isArray(value);
|
|
1734
|
+
}
|
|
1735
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: IsArrayPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
1736
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: IsArrayPipe, isStandalone: true, name: "isArray" });
|
|
1737
|
+
}
|
|
1738
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: IsArrayPipe, decorators: [{
|
|
1739
|
+
type: Pipe,
|
|
1740
|
+
args: [{
|
|
1741
|
+
name: 'isArray',
|
|
1742
|
+
standalone: true,
|
|
1743
|
+
}]
|
|
1744
|
+
}] });
|
|
1745
|
+
|
|
1746
|
+
/**
|
|
1747
|
+
* IsObjectPipe: Returns `true` when the value is a non-null object that is
|
|
1748
|
+
* not an array.
|
|
1749
|
+
*
|
|
1750
|
+
* Lenient — class instances, Date, Map, Set, and RegExp all return `true`
|
|
1751
|
+
* because their JS type is "object". Only `null` and arrays are excluded.
|
|
1752
|
+
* Pair with `isArray` to discriminate between the two structural shapes.
|
|
1753
|
+
*
|
|
1754
|
+
* @param {unknown} value - The value to test.
|
|
1755
|
+
*
|
|
1756
|
+
* @returns {boolean} - `true` if the value is a non-null, non-array object.
|
|
1757
|
+
*
|
|
1758
|
+
* @example
|
|
1759
|
+
* {{ { a: 1 } | isObject }} // true
|
|
1760
|
+
* {{ {} | isObject }} // true
|
|
1761
|
+
* {{ [1, 2] | isObject }} // false
|
|
1762
|
+
* {{ null | isObject }} // false
|
|
1763
|
+
* {{ 'abc' | isObject }} // false
|
|
1764
|
+
*/
|
|
1765
|
+
class IsObjectPipe {
|
|
1766
|
+
transform(value) {
|
|
1767
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
1768
|
+
}
|
|
1769
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: IsObjectPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
1770
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: IsObjectPipe, isStandalone: true, name: "isObject" });
|
|
1771
|
+
}
|
|
1772
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: IsObjectPipe, decorators: [{
|
|
1773
|
+
type: Pipe,
|
|
1774
|
+
args: [{
|
|
1775
|
+
name: 'isObject',
|
|
1776
|
+
standalone: true,
|
|
1777
|
+
}]
|
|
1778
|
+
}] });
|
|
1779
|
+
|
|
1780
|
+
/**
|
|
1781
|
+
* IsFunctionPipe: Returns `true` when the value is callable.
|
|
1782
|
+
*
|
|
1783
|
+
* Backed by `typeof value === 'function'`, so arrow functions, regular
|
|
1784
|
+
* functions, async functions, generator functions, and class constructors
|
|
1785
|
+
* all return `true`. Methods and bound functions count too.
|
|
1786
|
+
*
|
|
1787
|
+
* @param {unknown} value - The value to test.
|
|
1788
|
+
*
|
|
1789
|
+
* @returns {boolean} - `true` if the value is a function, `false` otherwise.
|
|
1790
|
+
*
|
|
1791
|
+
* @example
|
|
1792
|
+
* {{ (() => 0) | isFunction }} // true
|
|
1793
|
+
* {{ Math.max | isFunction }} // true
|
|
1794
|
+
* {{ class {} | isFunction }} // true
|
|
1795
|
+
* {{ 'fn' | isFunction }} // false
|
|
1796
|
+
*/
|
|
1797
|
+
class IsFunctionPipe {
|
|
1798
|
+
transform(value) {
|
|
1799
|
+
return typeof value === 'function';
|
|
1800
|
+
}
|
|
1801
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: IsFunctionPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
1802
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: IsFunctionPipe, isStandalone: true, name: "isFunction" });
|
|
1803
|
+
}
|
|
1804
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: IsFunctionPipe, decorators: [{
|
|
1805
|
+
type: Pipe,
|
|
1806
|
+
args: [{
|
|
1807
|
+
name: 'isFunction',
|
|
1808
|
+
standalone: true,
|
|
1809
|
+
}]
|
|
1810
|
+
}] });
|
|
1811
|
+
|
|
1812
|
+
/**
|
|
1813
|
+
* IsEmptyPipe: Returns `true` when the value has nothing in it.
|
|
1814
|
+
*
|
|
1815
|
+
* - `null` / `undefined` → `true`
|
|
1816
|
+
* - `''` (empty string) → `true`
|
|
1817
|
+
* - `[]` (empty array) → `true`
|
|
1818
|
+
* - `{}` (no own enumerable keys) → `true`
|
|
1819
|
+
* - empty `Map` / `Set` → `true`
|
|
1820
|
+
* - everything else (numbers, booleans, dates, functions, non-empty containers) → `false`
|
|
1821
|
+
*
|
|
1822
|
+
* Whitespace strings count as non-empty — chain `trim` first if you want a
|
|
1823
|
+
* "blank" check.
|
|
1824
|
+
*
|
|
1825
|
+
* @param {unknown} value - The value to test.
|
|
1826
|
+
*
|
|
1827
|
+
* @returns {boolean} - `true` if the value is considered empty.
|
|
1828
|
+
*
|
|
1829
|
+
* @example
|
|
1830
|
+
* {{ '' | isEmpty }} // true
|
|
1831
|
+
* {{ [] | isEmpty }} // true
|
|
1832
|
+
* {{ {} | isEmpty }} // true
|
|
1833
|
+
* {{ null | isEmpty }} // true
|
|
1834
|
+
* {{ ' ' | isEmpty }} // false (use trim first)
|
|
1835
|
+
* {{ 0 | isEmpty }} // false
|
|
1836
|
+
*/
|
|
1837
|
+
class IsEmptyPipe {
|
|
1838
|
+
transform(value) {
|
|
1839
|
+
if (value === null || value === undefined)
|
|
1840
|
+
return true;
|
|
1841
|
+
if (typeof value === 'string' || Array.isArray(value))
|
|
1842
|
+
return value.length === 0;
|
|
1843
|
+
if (value instanceof Map || value instanceof Set)
|
|
1844
|
+
return value.size === 0;
|
|
1845
|
+
if (typeof value === 'object') {
|
|
1846
|
+
// Only plain objects are "empty when no keys".
|
|
1847
|
+
// Built-in types (Date, RegExp) and class instances carry meaning.
|
|
1848
|
+
const proto = Object.getPrototypeOf(value);
|
|
1849
|
+
if (proto === Object.prototype || proto === null) {
|
|
1850
|
+
return Object.keys(value).length === 0;
|
|
1851
|
+
}
|
|
1852
|
+
return false;
|
|
1853
|
+
}
|
|
1854
|
+
return false;
|
|
1855
|
+
}
|
|
1856
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: IsEmptyPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
1857
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: IsEmptyPipe, isStandalone: true, name: "isEmpty" });
|
|
1858
|
+
}
|
|
1859
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: IsEmptyPipe, decorators: [{
|
|
1860
|
+
type: Pipe,
|
|
1861
|
+
args: [{
|
|
1862
|
+
name: 'isEmpty',
|
|
1863
|
+
standalone: true,
|
|
1864
|
+
}]
|
|
1865
|
+
}] });
|
|
1866
|
+
|
|
476
1867
|
/**
|
|
477
1868
|
* CreditCardMaskPipe: Masks all but the last four digits of a string, optionally controlled by a boolean flag.
|
|
478
1869
|
* By default, masking is applied.
|
|
@@ -2043,6 +3434,522 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImpor
|
|
|
2043
3434
|
}]
|
|
2044
3435
|
}] });
|
|
2045
3436
|
|
|
3437
|
+
/**
|
|
3438
|
+
* MinPipe: Returns the minimum value from an array of numbers or objects.
|
|
3439
|
+
*
|
|
3440
|
+
* Supports primitive number arrays and object arrays by property key with dot notation.
|
|
3441
|
+
*
|
|
3442
|
+
* @param {unknown[]} value - The array to evaluate.
|
|
3443
|
+
* @param {string} [key] - Optional property path for object comparison (supports dot notation).
|
|
3444
|
+
*
|
|
3445
|
+
* @returns {number | undefined} - The minimum value, or undefined if the array is empty/invalid.
|
|
3446
|
+
*
|
|
3447
|
+
* @example
|
|
3448
|
+
* {{ [5, 3, 8, 1, 9] | min }} // 1
|
|
3449
|
+
* {{ products | min:'price' }} // cheapest price
|
|
3450
|
+
* {{ orders | min:'meta.total' }} // lowest order total
|
|
3451
|
+
*/
|
|
3452
|
+
class MinPipe {
|
|
3453
|
+
transform(value, key) {
|
|
3454
|
+
if (!Array.isArray(value) || value.length === 0) {
|
|
3455
|
+
return undefined;
|
|
3456
|
+
}
|
|
3457
|
+
if (!key) {
|
|
3458
|
+
const numbers = value.filter((item) => typeof item === 'number' && !isNaN(item));
|
|
3459
|
+
return numbers.length === 0 ? undefined : Math.min(...numbers);
|
|
3460
|
+
}
|
|
3461
|
+
const numbers = value
|
|
3462
|
+
.map(item => this.getNestedValue(item, key))
|
|
3463
|
+
.filter((val) => typeof val === 'number' && !isNaN(val));
|
|
3464
|
+
return numbers.length === 0 ? undefined : Math.min(...numbers);
|
|
3465
|
+
}
|
|
3466
|
+
getNestedValue(obj, path) {
|
|
3467
|
+
return path.split('.').reduce((current, segment) => current?.[segment], obj);
|
|
3468
|
+
}
|
|
3469
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: MinPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
3470
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: MinPipe, isStandalone: true, name: "min" });
|
|
3471
|
+
}
|
|
3472
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: MinPipe, decorators: [{
|
|
3473
|
+
type: Pipe,
|
|
3474
|
+
args: [{
|
|
3475
|
+
name: 'min',
|
|
3476
|
+
standalone: true,
|
|
3477
|
+
}]
|
|
3478
|
+
}] });
|
|
3479
|
+
|
|
3480
|
+
/**
|
|
3481
|
+
* MaxPipe: Returns the maximum value from an array of numbers or objects.
|
|
3482
|
+
*
|
|
3483
|
+
* Supports primitive number arrays and object arrays by property key with dot notation.
|
|
3484
|
+
*
|
|
3485
|
+
* @param {unknown[]} value - The array to evaluate.
|
|
3486
|
+
* @param {string} [key] - Optional property path for object comparison (supports dot notation).
|
|
3487
|
+
*
|
|
3488
|
+
* @returns {number | undefined} - The maximum value, or undefined if the array is empty/invalid.
|
|
3489
|
+
*
|
|
3490
|
+
* @example
|
|
3491
|
+
* {{ [5, 3, 8, 1, 9] | max }} // 9
|
|
3492
|
+
* {{ products | max:'price' }} // highest price
|
|
3493
|
+
* {{ orders | max:'meta.total' }} // largest order total
|
|
3494
|
+
*/
|
|
3495
|
+
class MaxPipe {
|
|
3496
|
+
transform(value, key) {
|
|
3497
|
+
if (!Array.isArray(value) || value.length === 0) {
|
|
3498
|
+
return undefined;
|
|
3499
|
+
}
|
|
3500
|
+
if (!key) {
|
|
3501
|
+
const numbers = value.filter((item) => typeof item === 'number' && !isNaN(item));
|
|
3502
|
+
return numbers.length === 0 ? undefined : Math.max(...numbers);
|
|
3503
|
+
}
|
|
3504
|
+
const numbers = value
|
|
3505
|
+
.map(item => this.getNestedValue(item, key))
|
|
3506
|
+
.filter((val) => typeof val === 'number' && !isNaN(val));
|
|
3507
|
+
return numbers.length === 0 ? undefined : Math.max(...numbers);
|
|
3508
|
+
}
|
|
3509
|
+
getNestedValue(obj, path) {
|
|
3510
|
+
return path.split('.').reduce((current, segment) => current?.[segment], obj);
|
|
3511
|
+
}
|
|
3512
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: MaxPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
3513
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: MaxPipe, isStandalone: true, name: "max" });
|
|
3514
|
+
}
|
|
3515
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: MaxPipe, decorators: [{
|
|
3516
|
+
type: Pipe,
|
|
3517
|
+
args: [{
|
|
3518
|
+
name: 'max',
|
|
3519
|
+
standalone: true,
|
|
3520
|
+
}]
|
|
3521
|
+
}] });
|
|
3522
|
+
|
|
3523
|
+
/**
|
|
3524
|
+
* SumPipe: Returns the sum of all numeric values in an array.
|
|
3525
|
+
*
|
|
3526
|
+
* Supports primitive number arrays and object arrays by property key with dot notation.
|
|
3527
|
+
*
|
|
3528
|
+
* @param {unknown[]} value - The array to evaluate.
|
|
3529
|
+
* @param {string} [key] - Optional property path for object summation (supports dot notation).
|
|
3530
|
+
*
|
|
3531
|
+
* @returns {number | undefined} - The total, or undefined if the array is empty/invalid.
|
|
3532
|
+
*
|
|
3533
|
+
* @example
|
|
3534
|
+
* {{ [10, 20, 30] | sum }} // 60
|
|
3535
|
+
* {{ items | sum:'price' }} // total price
|
|
3536
|
+
* {{ orders | sum:'meta.total' }} // grand total
|
|
3537
|
+
*/
|
|
3538
|
+
class SumPipe {
|
|
3539
|
+
transform(value, key) {
|
|
3540
|
+
if (!Array.isArray(value) || value.length === 0) {
|
|
3541
|
+
return undefined;
|
|
3542
|
+
}
|
|
3543
|
+
if (!key) {
|
|
3544
|
+
const numbers = value.filter((item) => typeof item === 'number' && !isNaN(item));
|
|
3545
|
+
return numbers.length === 0 ? undefined : numbers.reduce((acc, n) => acc + n, 0);
|
|
3546
|
+
}
|
|
3547
|
+
const numbers = value
|
|
3548
|
+
.map(item => this.getNestedValue(item, key))
|
|
3549
|
+
.filter((val) => typeof val === 'number' && !isNaN(val));
|
|
3550
|
+
return numbers.length === 0 ? undefined : numbers.reduce((acc, n) => acc + n, 0);
|
|
3551
|
+
}
|
|
3552
|
+
getNestedValue(obj, path) {
|
|
3553
|
+
return path.split('.').reduce((current, segment) => current?.[segment], obj);
|
|
3554
|
+
}
|
|
3555
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: SumPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
3556
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: SumPipe, isStandalone: true, name: "sum" });
|
|
3557
|
+
}
|
|
3558
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: SumPipe, decorators: [{
|
|
3559
|
+
type: Pipe,
|
|
3560
|
+
args: [{
|
|
3561
|
+
name: 'sum',
|
|
3562
|
+
standalone: true,
|
|
3563
|
+
}]
|
|
3564
|
+
}] });
|
|
3565
|
+
|
|
3566
|
+
/**
|
|
3567
|
+
* AveragePipe: Returns the arithmetic mean of all numeric values in an array.
|
|
3568
|
+
*
|
|
3569
|
+
* Supports primitive number arrays and object arrays by property key with dot notation.
|
|
3570
|
+
*
|
|
3571
|
+
* @param {unknown[]} value - The array to evaluate.
|
|
3572
|
+
* @param {string} [key] - Optional property path for object averaging (supports dot notation).
|
|
3573
|
+
*
|
|
3574
|
+
* @returns {number | undefined} - The average, or undefined if the array is empty/invalid.
|
|
3575
|
+
*
|
|
3576
|
+
* @example
|
|
3577
|
+
* {{ [10, 20, 30] | average }} // 20
|
|
3578
|
+
* {{ students | average:'grade' }} // average grade
|
|
3579
|
+
* {{ reviews | average:'meta.rating' }} // average rating
|
|
3580
|
+
*/
|
|
3581
|
+
class AveragePipe {
|
|
3582
|
+
transform(value, key) {
|
|
3583
|
+
if (!Array.isArray(value) || value.length === 0) {
|
|
3584
|
+
return undefined;
|
|
3585
|
+
}
|
|
3586
|
+
if (!key) {
|
|
3587
|
+
const numbers = value.filter((item) => typeof item === 'number' && !isNaN(item));
|
|
3588
|
+
return numbers.length === 0 ? undefined : numbers.reduce((acc, n) => acc + n, 0) / numbers.length;
|
|
3589
|
+
}
|
|
3590
|
+
const numbers = value
|
|
3591
|
+
.map(item => this.getNestedValue(item, key))
|
|
3592
|
+
.filter((val) => typeof val === 'number' && !isNaN(val));
|
|
3593
|
+
return numbers.length === 0 ? undefined : numbers.reduce((acc, n) => acc + n, 0) / numbers.length;
|
|
3594
|
+
}
|
|
3595
|
+
getNestedValue(obj, path) {
|
|
3596
|
+
return path.split('.').reduce((current, segment) => current?.[segment], obj);
|
|
3597
|
+
}
|
|
3598
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: AveragePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
3599
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: AveragePipe, isStandalone: true, name: "average" });
|
|
3600
|
+
}
|
|
3601
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: AveragePipe, decorators: [{
|
|
3602
|
+
type: Pipe,
|
|
3603
|
+
args: [{
|
|
3604
|
+
name: 'average',
|
|
3605
|
+
standalone: true,
|
|
3606
|
+
}]
|
|
3607
|
+
}] });
|
|
3608
|
+
|
|
3609
|
+
/**
|
|
3610
|
+
* PercentagePipe: Calculates what percentage a value represents of a total.
|
|
3611
|
+
*
|
|
3612
|
+
* Returns `(value / total) * 100`, optionally rounded to a given number of decimal places.
|
|
3613
|
+
*
|
|
3614
|
+
* @param {number} value - The partial value.
|
|
3615
|
+
* @param {number} total - The total/whole value.
|
|
3616
|
+
* @param {number} [decimals] - Optional number of decimal places to round to.
|
|
3617
|
+
*
|
|
3618
|
+
* @returns {number | undefined} - The percentage, or undefined if inputs are invalid.
|
|
3619
|
+
*
|
|
3620
|
+
* @example
|
|
3621
|
+
* {{ 25 | percentage:200 }} // 12.5
|
|
3622
|
+
* {{ 1 | percentage:3:2 }} // 33.33
|
|
3623
|
+
* {{ 750 | percentage:1000 }} // 75
|
|
3624
|
+
*/
|
|
3625
|
+
class PercentagePipe {
|
|
3626
|
+
transform(value, total, decimals) {
|
|
3627
|
+
if (typeof value !== 'number' || isNaN(value)) {
|
|
3628
|
+
return undefined;
|
|
3629
|
+
}
|
|
3630
|
+
if (typeof total !== 'number' || isNaN(total) || total === 0) {
|
|
3631
|
+
return undefined;
|
|
3632
|
+
}
|
|
3633
|
+
const result = (value / total) * 100;
|
|
3634
|
+
if (typeof decimals === 'number' && decimals >= 0) {
|
|
3635
|
+
const factor = Math.pow(10, decimals);
|
|
3636
|
+
return Math.round(result * factor) / factor;
|
|
3637
|
+
}
|
|
3638
|
+
return result;
|
|
3639
|
+
}
|
|
3640
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: PercentagePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
3641
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: PercentagePipe, isStandalone: true, name: "percentage" });
|
|
3642
|
+
}
|
|
3643
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: PercentagePipe, decorators: [{
|
|
3644
|
+
type: Pipe,
|
|
3645
|
+
args: [{
|
|
3646
|
+
name: 'percentage',
|
|
3647
|
+
standalone: true,
|
|
3648
|
+
}]
|
|
3649
|
+
}] });
|
|
3650
|
+
|
|
3651
|
+
/**
|
|
3652
|
+
* CeilPipe: Rounds a number up to the specified number of decimal places.
|
|
3653
|
+
*
|
|
3654
|
+
* Uses `Math.ceil` — always rounds toward positive infinity.
|
|
3655
|
+
*
|
|
3656
|
+
* @param {number} value - The number to round up.
|
|
3657
|
+
* @param {number} [precision=0] - Number of decimal places to preserve (defaults to 0 = integer).
|
|
3658
|
+
*
|
|
3659
|
+
* @returns {number | undefined} - The rounded-up value, or undefined if the input is invalid.
|
|
3660
|
+
*
|
|
3661
|
+
* @example
|
|
3662
|
+
* {{ 4.1 | ceil }} // 5
|
|
3663
|
+
* {{ 4.123 | ceil:2 }} // 4.13
|
|
3664
|
+
* {{ 0.001 | ceil:2 }} // 0.01
|
|
3665
|
+
* {{ -4.9 | ceil }} // -4
|
|
3666
|
+
*/
|
|
3667
|
+
class CeilPipe {
|
|
3668
|
+
transform(value, precision = 0) {
|
|
3669
|
+
if (typeof value !== 'number' || isNaN(value)) {
|
|
3670
|
+
return undefined;
|
|
3671
|
+
}
|
|
3672
|
+
if (typeof precision !== 'number' || isNaN(precision) || precision < 0) {
|
|
3673
|
+
return undefined;
|
|
3674
|
+
}
|
|
3675
|
+
const factor = Math.pow(10, precision);
|
|
3676
|
+
return Math.ceil(value * factor) / factor;
|
|
3677
|
+
}
|
|
3678
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: CeilPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
3679
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: CeilPipe, isStandalone: true, name: "ceil" });
|
|
3680
|
+
}
|
|
3681
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: CeilPipe, decorators: [{
|
|
3682
|
+
type: Pipe,
|
|
3683
|
+
args: [{
|
|
3684
|
+
name: 'ceil',
|
|
3685
|
+
standalone: true,
|
|
3686
|
+
}]
|
|
3687
|
+
}] });
|
|
3688
|
+
|
|
3689
|
+
/**
|
|
3690
|
+
* FloorPipe: Rounds a number down to the specified number of decimal places.
|
|
3691
|
+
*
|
|
3692
|
+
* Uses `Math.floor` — always rounds toward negative infinity.
|
|
3693
|
+
*
|
|
3694
|
+
* @param {number} value - The number to round down.
|
|
3695
|
+
* @param {number} [precision=0] - Number of decimal places to preserve (defaults to 0 = integer).
|
|
3696
|
+
*
|
|
3697
|
+
* @returns {number | undefined} - The rounded-down value, or undefined if the input is invalid.
|
|
3698
|
+
*
|
|
3699
|
+
* @example
|
|
3700
|
+
* {{ 4.9 | floor }} // 4
|
|
3701
|
+
* {{ 4.567 | floor:2 }} // 4.56
|
|
3702
|
+
* {{ 0.999 | floor:1 }} // 0.9
|
|
3703
|
+
* {{ -4.1 | floor }} // -5
|
|
3704
|
+
*/
|
|
3705
|
+
class FloorPipe {
|
|
3706
|
+
transform(value, precision = 0) {
|
|
3707
|
+
if (typeof value !== 'number' || isNaN(value)) {
|
|
3708
|
+
return undefined;
|
|
3709
|
+
}
|
|
3710
|
+
if (typeof precision !== 'number' || isNaN(precision) || precision < 0) {
|
|
3711
|
+
return undefined;
|
|
3712
|
+
}
|
|
3713
|
+
const factor = Math.pow(10, precision);
|
|
3714
|
+
return Math.floor(value * factor) / factor;
|
|
3715
|
+
}
|
|
3716
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: FloorPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
3717
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: FloorPipe, isStandalone: true, name: "floor" });
|
|
3718
|
+
}
|
|
3719
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: FloorPipe, decorators: [{
|
|
3720
|
+
type: Pipe,
|
|
3721
|
+
args: [{
|
|
3722
|
+
name: 'floor',
|
|
3723
|
+
standalone: true,
|
|
3724
|
+
}]
|
|
3725
|
+
}] });
|
|
3726
|
+
|
|
3727
|
+
/**
|
|
3728
|
+
* RoundPipe: Rounds a number to the nearest value at the specified number of decimal places.
|
|
3729
|
+
*
|
|
3730
|
+
* Uses `Math.round` — rounds half-up (e.g. 2.5 → 3, -2.5 → -2).
|
|
3731
|
+
*
|
|
3732
|
+
* @param {number} value - The number to round.
|
|
3733
|
+
* @param {number} [precision=0] - Number of decimal places to preserve (defaults to 0 = integer).
|
|
3734
|
+
*
|
|
3735
|
+
* @returns {number | undefined} - The rounded value, or undefined if the input is invalid.
|
|
3736
|
+
*
|
|
3737
|
+
* @example
|
|
3738
|
+
* {{ 4.4 | round }} // 4
|
|
3739
|
+
* {{ 4.5 | round }} // 5
|
|
3740
|
+
* {{ 4.567 | round:2 }} // 4.57
|
|
3741
|
+
* {{ 0.125 | round:2 }} // 0.13
|
|
3742
|
+
*/
|
|
3743
|
+
class RoundPipe {
|
|
3744
|
+
transform(value, precision = 0) {
|
|
3745
|
+
if (typeof value !== 'number' || isNaN(value)) {
|
|
3746
|
+
return undefined;
|
|
3747
|
+
}
|
|
3748
|
+
if (typeof precision !== 'number' || isNaN(precision) || precision < 0) {
|
|
3749
|
+
return undefined;
|
|
3750
|
+
}
|
|
3751
|
+
const factor = Math.pow(10, precision);
|
|
3752
|
+
return Math.round(value * factor) / factor;
|
|
3753
|
+
}
|
|
3754
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: RoundPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
3755
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: RoundPipe, isStandalone: true, name: "round" });
|
|
3756
|
+
}
|
|
3757
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: RoundPipe, decorators: [{
|
|
3758
|
+
type: Pipe,
|
|
3759
|
+
args: [{
|
|
3760
|
+
name: 'round',
|
|
3761
|
+
standalone: true,
|
|
3762
|
+
}]
|
|
3763
|
+
}] });
|
|
3764
|
+
|
|
3765
|
+
/**
|
|
3766
|
+
* SqrtPipe: Returns the square root of a number.
|
|
3767
|
+
*
|
|
3768
|
+
* Uses `Math.sqrt`. Returns undefined for negative numbers.
|
|
3769
|
+
*
|
|
3770
|
+
* @param {number} value - The number to compute the square root of.
|
|
3771
|
+
*
|
|
3772
|
+
* @returns {number | undefined} - The square root, or undefined if the input is invalid or negative.
|
|
3773
|
+
*
|
|
3774
|
+
* @example
|
|
3775
|
+
* {{ 9 | sqrt }} // 3
|
|
3776
|
+
* {{ 2 | sqrt }} // 1.4142135623730951
|
|
3777
|
+
* {{ 144 | sqrt }} // 12
|
|
3778
|
+
*/
|
|
3779
|
+
class SqrtPipe {
|
|
3780
|
+
transform(value) {
|
|
3781
|
+
if (typeof value !== 'number' || isNaN(value)) {
|
|
3782
|
+
return undefined;
|
|
3783
|
+
}
|
|
3784
|
+
if (value < 0) {
|
|
3785
|
+
return undefined;
|
|
3786
|
+
}
|
|
3787
|
+
return Math.sqrt(value);
|
|
3788
|
+
}
|
|
3789
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: SqrtPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
3790
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: SqrtPipe, isStandalone: true, name: "sqrt" });
|
|
3791
|
+
}
|
|
3792
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: SqrtPipe, decorators: [{
|
|
3793
|
+
type: Pipe,
|
|
3794
|
+
args: [{
|
|
3795
|
+
name: 'sqrt',
|
|
3796
|
+
standalone: true,
|
|
3797
|
+
}]
|
|
3798
|
+
}] });
|
|
3799
|
+
|
|
3800
|
+
/**
|
|
3801
|
+
* PowPipe: Raises a number to the specified power.
|
|
3802
|
+
*
|
|
3803
|
+
* Uses `Math.pow`. The exponent defaults to 2 (squaring).
|
|
3804
|
+
*
|
|
3805
|
+
* @param {number} value - The base number.
|
|
3806
|
+
* @param {number} [exponent=2] - The power to raise the base to (defaults to 2).
|
|
3807
|
+
*
|
|
3808
|
+
* @returns {number | undefined} - The result, or undefined if the inputs are invalid.
|
|
3809
|
+
*
|
|
3810
|
+
* @example
|
|
3811
|
+
* {{ 3 | pow }} // 9 (3^2)
|
|
3812
|
+
* {{ 2 | pow:3 }} // 8 (2^3)
|
|
3813
|
+
* {{ 5 | pow:0 }} // 1 (anything^0)
|
|
3814
|
+
*/
|
|
3815
|
+
class PowPipe {
|
|
3816
|
+
transform(value, exponent = 2) {
|
|
3817
|
+
if (typeof value !== 'number' || isNaN(value)) {
|
|
3818
|
+
return undefined;
|
|
3819
|
+
}
|
|
3820
|
+
if (typeof exponent !== 'number' || isNaN(exponent)) {
|
|
3821
|
+
return undefined;
|
|
3822
|
+
}
|
|
3823
|
+
return Math.pow(value, exponent);
|
|
3824
|
+
}
|
|
3825
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: PowPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
3826
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: PowPipe, isStandalone: true, name: "pow" });
|
|
3827
|
+
}
|
|
3828
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: PowPipe, decorators: [{
|
|
3829
|
+
type: Pipe,
|
|
3830
|
+
args: [{
|
|
3831
|
+
name: 'pow',
|
|
3832
|
+
standalone: true,
|
|
3833
|
+
}]
|
|
3834
|
+
}] });
|
|
3835
|
+
|
|
3836
|
+
/**
|
|
3837
|
+
* DegreesPipe: Converts a value in radians to degrees.
|
|
3838
|
+
*
|
|
3839
|
+
* Formula: `degrees = radians * (180 / Math.PI)`
|
|
3840
|
+
*
|
|
3841
|
+
* @param {number} value - The angle in radians.
|
|
3842
|
+
*
|
|
3843
|
+
* @returns {number | undefined} - The angle in degrees, or undefined if the input is invalid.
|
|
3844
|
+
*
|
|
3845
|
+
* @example
|
|
3846
|
+
* {{ 3.14159 | degrees }} // ~180
|
|
3847
|
+
* {{ 1.5708 | degrees }} // ~90
|
|
3848
|
+
* {{ 0 | degrees }} // 0
|
|
3849
|
+
*/
|
|
3850
|
+
class DegreesPipe {
|
|
3851
|
+
transform(value) {
|
|
3852
|
+
if (typeof value !== 'number' || isNaN(value)) {
|
|
3853
|
+
return undefined;
|
|
3854
|
+
}
|
|
3855
|
+
return value * (180 / Math.PI);
|
|
3856
|
+
}
|
|
3857
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: DegreesPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
3858
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: DegreesPipe, isStandalone: true, name: "degrees" });
|
|
3859
|
+
}
|
|
3860
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: DegreesPipe, decorators: [{
|
|
3861
|
+
type: Pipe,
|
|
3862
|
+
args: [{
|
|
3863
|
+
name: 'degrees',
|
|
3864
|
+
standalone: true,
|
|
3865
|
+
}]
|
|
3866
|
+
}] });
|
|
3867
|
+
|
|
3868
|
+
/**
|
|
3869
|
+
* BytesPipe: Formats a number of bytes into a human-readable string with appropriate units.
|
|
3870
|
+
*
|
|
3871
|
+
* Supports both binary (1024-based: KiB, MiB, GiB) and decimal (1000-based: KB, MB, GB) units.
|
|
3872
|
+
* Defaults to decimal (1000-based) units.
|
|
3873
|
+
*
|
|
3874
|
+
* @param {number} value - The number of bytes.
|
|
3875
|
+
* @param {number} [decimals=1] - Number of decimal places in the output.
|
|
3876
|
+
* @param {string} [base='decimal'] - Unit base: 'decimal' (1000, KB/MB/GB) or 'binary' (1024, KiB/MiB/GiB).
|
|
3877
|
+
*
|
|
3878
|
+
* @returns {string | undefined} - The formatted string, or undefined if the input is invalid.
|
|
3879
|
+
*
|
|
3880
|
+
* @example
|
|
3881
|
+
* {{ 1536 | bytes }} // "1.5 KB"
|
|
3882
|
+
* {{ 1048576 | bytes:2 }} // "1.05 MB"
|
|
3883
|
+
* {{ 1073741824 | bytes:1:'binary' }} // "1.0 GiB"
|
|
3884
|
+
*/
|
|
3885
|
+
class BytesPipe {
|
|
3886
|
+
decimalUnits = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB'];
|
|
3887
|
+
binaryUnits = ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB'];
|
|
3888
|
+
transform(value, decimals = 1, base = 'decimal') {
|
|
3889
|
+
if (typeof value !== 'number' || isNaN(value)) {
|
|
3890
|
+
return undefined;
|
|
3891
|
+
}
|
|
3892
|
+
if (value < 0) {
|
|
3893
|
+
return undefined;
|
|
3894
|
+
}
|
|
3895
|
+
if (value === 0) {
|
|
3896
|
+
return '0 B';
|
|
3897
|
+
}
|
|
3898
|
+
const isBinary = base === 'binary';
|
|
3899
|
+
const divisor = isBinary ? 1024 : 1000;
|
|
3900
|
+
const units = isBinary ? this.binaryUnits : this.decimalUnits;
|
|
3901
|
+
let unitIndex = 0;
|
|
3902
|
+
let size = value;
|
|
3903
|
+
while (size >= divisor && unitIndex < units.length - 1) {
|
|
3904
|
+
size /= divisor;
|
|
3905
|
+
unitIndex++;
|
|
3906
|
+
}
|
|
3907
|
+
const precision = typeof decimals === 'number' && decimals >= 0 ? decimals : 1;
|
|
3908
|
+
return `${size.toFixed(precision)} ${units[unitIndex]}`;
|
|
3909
|
+
}
|
|
3910
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: BytesPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
3911
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: BytesPipe, isStandalone: true, name: "bytes" });
|
|
3912
|
+
}
|
|
3913
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: BytesPipe, decorators: [{
|
|
3914
|
+
type: Pipe,
|
|
3915
|
+
args: [{
|
|
3916
|
+
name: 'bytes',
|
|
3917
|
+
standalone: true,
|
|
3918
|
+
}]
|
|
3919
|
+
}] });
|
|
3920
|
+
|
|
3921
|
+
/**
|
|
3922
|
+
* RadiansPipe: Converts a value in degrees to radians.
|
|
3923
|
+
*
|
|
3924
|
+
* Formula: `radians = degrees * (Math.PI / 180)`
|
|
3925
|
+
*
|
|
3926
|
+
* @param {number} value - The angle in degrees.
|
|
3927
|
+
*
|
|
3928
|
+
* @returns {number | undefined} - The angle in radians, or undefined if the input is invalid.
|
|
3929
|
+
*
|
|
3930
|
+
* @example
|
|
3931
|
+
* {{ 180 | radians }} // ~3.14159
|
|
3932
|
+
* {{ 90 | radians }} // ~1.5708
|
|
3933
|
+
* {{ 0 | radians }} // 0
|
|
3934
|
+
*/
|
|
3935
|
+
class RadiansPipe {
|
|
3936
|
+
transform(value) {
|
|
3937
|
+
if (typeof value !== 'number' || isNaN(value)) {
|
|
3938
|
+
return undefined;
|
|
3939
|
+
}
|
|
3940
|
+
return value * (Math.PI / 180);
|
|
3941
|
+
}
|
|
3942
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: RadiansPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
3943
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: RadiansPipe, isStandalone: true, name: "radians" });
|
|
3944
|
+
}
|
|
3945
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: RadiansPipe, decorators: [{
|
|
3946
|
+
type: Pipe,
|
|
3947
|
+
args: [{
|
|
3948
|
+
name: 'radians',
|
|
3949
|
+
standalone: true,
|
|
3950
|
+
}]
|
|
3951
|
+
}] });
|
|
3952
|
+
|
|
2046
3953
|
// Text
|
|
2047
3954
|
const ALL_PIPES = [
|
|
2048
3955
|
// Text
|
|
@@ -2056,6 +3963,44 @@ const ALL_PIPES = [
|
|
|
2056
3963
|
SnakeCasePipe,
|
|
2057
3964
|
TitleCasePipe,
|
|
2058
3965
|
TruncatePipe,
|
|
3966
|
+
TrimPipe,
|
|
3967
|
+
CapitalizePipe,
|
|
3968
|
+
UpperFirstPipe,
|
|
3969
|
+
LeftPadPipe,
|
|
3970
|
+
RightPadPipe,
|
|
3971
|
+
PadPipe,
|
|
3972
|
+
RepeatPipe,
|
|
3973
|
+
SlugifyPipe,
|
|
3974
|
+
StripTagsPipe,
|
|
3975
|
+
EncodeUriPipe,
|
|
3976
|
+
EncodeUriComponentPipe,
|
|
3977
|
+
DecodeUriPipe,
|
|
3978
|
+
DecodeUriComponentPipe,
|
|
3979
|
+
SplitPipe,
|
|
3980
|
+
MatchPipe,
|
|
3981
|
+
TestPipe,
|
|
3982
|
+
NewlinesPipe,
|
|
3983
|
+
TemplatePipe,
|
|
3984
|
+
LatinizePipe,
|
|
3985
|
+
WrapPipe,
|
|
3986
|
+
// Object
|
|
3987
|
+
KeysPipe,
|
|
3988
|
+
ValuesPipe,
|
|
3989
|
+
PairsPipe,
|
|
3990
|
+
PickPipe,
|
|
3991
|
+
OmitPipe,
|
|
3992
|
+
InvertPipe,
|
|
3993
|
+
InvertByPipe,
|
|
3994
|
+
DiffObjPipe,
|
|
3995
|
+
// Boolean
|
|
3996
|
+
IsDefinedPipe,
|
|
3997
|
+
IsNullPipe,
|
|
3998
|
+
IsStringPipe,
|
|
3999
|
+
IsNumberPipe,
|
|
4000
|
+
IsArrayPipe,
|
|
4001
|
+
IsObjectPipe,
|
|
4002
|
+
IsFunctionPipe,
|
|
4003
|
+
IsEmptyPipe,
|
|
2059
4004
|
// Security & Privacy
|
|
2060
4005
|
CreditCardMaskPipe,
|
|
2061
4006
|
EmailMaskPipe,
|
|
@@ -2093,7 +4038,21 @@ const ALL_PIPES = [
|
|
|
2093
4038
|
WithoutPipe,
|
|
2094
4039
|
SomePipe,
|
|
2095
4040
|
UnionPipe,
|
|
2096
|
-
FilterByPipe
|
|
4041
|
+
FilterByPipe,
|
|
4042
|
+
// Math
|
|
4043
|
+
MinPipe,
|
|
4044
|
+
MaxPipe,
|
|
4045
|
+
SumPipe,
|
|
4046
|
+
AveragePipe,
|
|
4047
|
+
PercentagePipe,
|
|
4048
|
+
CeilPipe,
|
|
4049
|
+
FloorPipe,
|
|
4050
|
+
RoundPipe,
|
|
4051
|
+
SqrtPipe,
|
|
4052
|
+
PowPipe,
|
|
4053
|
+
DegreesPipe,
|
|
4054
|
+
BytesPipe,
|
|
4055
|
+
RadiansPipe,
|
|
2097
4056
|
];
|
|
2098
4057
|
|
|
2099
4058
|
// Text
|
|
@@ -2102,5 +4061,5 @@ const ALL_PIPES = [
|
|
|
2102
4061
|
* Generated bundle index. Do not edit.
|
|
2103
4062
|
*/
|
|
2104
4063
|
|
|
2105
|
-
export { ALL_PIPES, AsciiArtPipe, BarcodePipe, CamelCasePipe, ChunkPipe, ColorConvertPipe, CountPipe, CreditCardMaskPipe, DeviceTypePipe, DiffPipe, EmailMaskPipe, EveryPipe, FilterByPipe, Flatten, GravatarPipe, GroupByPipe, HighlightPipe, HtmlEscapePipe, HtmlSanitizePipe, InitialPipe, InitialsPipe, IntersectionPipe, IpAddressMaskPipe, JsonPrettyPipe, KebabCasePipe, MorseCodePipe, OrderByPipe, PluckPipe, QrCodePipe, RangePipe, ReplacePipe, ReversePipe, SamplePipe, ShufflePipe, SnakeCasePipe, SomePipe, TailPipe, TextToSpeechPipe, TimeAgoPipePipe, TitleCasePipe, TruncatePipe, TruthifyPipe, UnionPipe, UniquePipe, WithoutPipe };
|
|
4064
|
+
export { ALL_PIPES, AsciiArtPipe, AveragePipe, BarcodePipe, BytesPipe, CamelCasePipe, CapitalizePipe, CeilPipe, ChunkPipe, ColorConvertPipe, CountPipe, CreditCardMaskPipe, DecodeUriComponentPipe, DecodeUriPipe, DegreesPipe, DeviceTypePipe, DiffObjPipe, DiffPipe, EmailMaskPipe, EncodeUriComponentPipe, EncodeUriPipe, EveryPipe, FilterByPipe, Flatten, FloorPipe, GravatarPipe, GroupByPipe, HighlightPipe, HtmlEscapePipe, HtmlSanitizePipe, InitialPipe, InitialsPipe, IntersectionPipe, InvertByPipe, InvertPipe, IpAddressMaskPipe, IsArrayPipe, IsDefinedPipe, IsEmptyPipe, IsFunctionPipe, IsNullPipe, IsNumberPipe, IsObjectPipe, IsStringPipe, JsonPrettyPipe, KebabCasePipe, KeysPipe, LatinizePipe, LeftPadPipe, MatchPipe, MaxPipe, MinPipe, MorseCodePipe, NewlinesPipe, OmitPipe, OrderByPipe, PadPipe, PairsPipe, PercentagePipe, PickPipe, PluckPipe, PowPipe, QrCodePipe, RadiansPipe, RangePipe, RepeatPipe, ReplacePipe, ReversePipe, RightPadPipe, RoundPipe, SamplePipe, ShufflePipe, SlugifyPipe, SnakeCasePipe, SomePipe, SplitPipe, SqrtPipe, StripTagsPipe, SumPipe, TailPipe, TemplatePipe, TestPipe, TextToSpeechPipe, TimeAgoPipePipe, TitleCasePipe, TrimPipe, TruncatePipe, TruthifyPipe, UnionPipe, UniquePipe, UpperFirstPipe, ValuesPipe, WithoutPipe, WrapPipe };
|
|
2106
4065
|
//# sourceMappingURL=ngx-transforms.mjs.map
|