ngx-transforms 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/ngx-transforms.mjs +1090 -17
- package/fesm2022/ngx-transforms.mjs.map +1 -1
- package/package.json +14 -3
- package/types/ngx-transforms.d.ts +542 -17
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ngx-transforms",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "A collection of
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "A collection of 36 standalone Angular pipes for text, security, media, data, and array transformations.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"angular",
|
|
7
7
|
"pipes",
|
|
@@ -20,7 +20,18 @@
|
|
|
20
20
|
"shuffle",
|
|
21
21
|
"unique",
|
|
22
22
|
"flatten",
|
|
23
|
-
"time-ago"
|
|
23
|
+
"time-ago",
|
|
24
|
+
"diff",
|
|
25
|
+
"intersection",
|
|
26
|
+
"union",
|
|
27
|
+
"every",
|
|
28
|
+
"some",
|
|
29
|
+
"filter-by",
|
|
30
|
+
"group-by",
|
|
31
|
+
"order-by",
|
|
32
|
+
"chunk",
|
|
33
|
+
"pluck",
|
|
34
|
+
"range"
|
|
24
35
|
],
|
|
25
36
|
"license": "MIT",
|
|
26
37
|
"author": "Mofiro Jean <mofirojean@gmail.com>",
|
|
@@ -193,22 +193,6 @@ declare class MorseCodePipe implements PipeTransform {
|
|
|
193
193
|
* @param {boolean} [isReplace=true] - Whether to perform replacement (true) or only highlight matches (false).
|
|
194
194
|
*
|
|
195
195
|
* @returns {string | SafeHtml} - Returns the transformed string or SafeHtml with highlights.
|
|
196
|
-
*
|
|
197
|
-
* @example
|
|
198
|
-
* {{ 'Hello World' | replace:'World':'Universe' }}
|
|
199
|
-
* // Output: Hello Universe
|
|
200
|
-
*
|
|
201
|
-
* {{ 'test123' | replace:/\d+/g:'X':'highlight' }}
|
|
202
|
-
* // Output: test<span class="highlight">X</span>
|
|
203
|
-
*
|
|
204
|
-
* {{ 'Angular is great' | replace:'great':'awesome':'highlight':true }}
|
|
205
|
-
* // Output: Angular is <span class="highlight">awesome</span>
|
|
206
|
-
*
|
|
207
|
-
* {{ 'Angular is great' | replace:'great':'awesome':'highlight':false }}
|
|
208
|
-
* // Output: Angular is <span class="highlight">great</span>
|
|
209
|
-
*
|
|
210
|
-
* <div [innerHTML]="'Angular is great' | replace:'great':'awesome':'highlight':false"></div>
|
|
211
|
-
* // Renders: Angular is <span class="highlight">great</span>
|
|
212
196
|
*/
|
|
213
197
|
declare class ReplacePipe implements PipeTransform {
|
|
214
198
|
private sanitizer;
|
|
@@ -639,6 +623,93 @@ declare class TimeAgoPipePipe implements PipeTransform {
|
|
|
639
623
|
static ɵpipe: i0.ɵɵPipeDeclaration<TimeAgoPipePipe, "timeAgo", true>;
|
|
640
624
|
}
|
|
641
625
|
|
|
626
|
+
/**
|
|
627
|
+
* DiffPipe: Returns elements present in the first array but not in the second.
|
|
628
|
+
*
|
|
629
|
+
* Supports primitives and objects by property key with dot notation.
|
|
630
|
+
*
|
|
631
|
+
* @param {unknown[]} value - The source array.
|
|
632
|
+
* @param {unknown[]} compared - The array to compare against.
|
|
633
|
+
* @param {string} [key] - Optional property path for object comparison (supports dot notation).
|
|
634
|
+
*
|
|
635
|
+
* @returns {unknown[]} - Elements in value that are not in compared.
|
|
636
|
+
*
|
|
637
|
+
* @example
|
|
638
|
+
* {{ [1, 2, 3, 4, 5] | diff:[3, 4, 5, 6] }} // [1, 2]
|
|
639
|
+
* {{ allUsers | diff:activeUsers:'id' }} // inactive users
|
|
640
|
+
* {{ orders | diff:shipped:'meta.trackingId' }} // unshipped orders
|
|
641
|
+
*/
|
|
642
|
+
declare class DiffPipe implements PipeTransform {
|
|
643
|
+
transform(value: unknown[], compared: unknown[], key?: string): unknown[];
|
|
644
|
+
private getNestedValue;
|
|
645
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<DiffPipe, never>;
|
|
646
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<DiffPipe, "diff", true>;
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
/**
|
|
650
|
+
* EveryPipe: Checks if all elements in an array satisfy a condition.
|
|
651
|
+
*
|
|
652
|
+
* Supports primitives (equality check) and objects by property key with dot notation.
|
|
653
|
+
*
|
|
654
|
+
* @param {unknown[]} value - The array to check.
|
|
655
|
+
* @param {unknown} match - The value to match against.
|
|
656
|
+
* @param {string} [key] - Optional property path to check (supports dot notation).
|
|
657
|
+
*
|
|
658
|
+
* @returns {boolean} - True if all elements match, false otherwise.
|
|
659
|
+
*
|
|
660
|
+
* @example
|
|
661
|
+
* {{ [true, true, true] | every:true }} // true
|
|
662
|
+
* {{ users | every:'active':'status' }} // are all users active?
|
|
663
|
+
* {{ orders | every:'shipped':'meta.state' }} // are all orders shipped?
|
|
664
|
+
*/
|
|
665
|
+
declare class EveryPipe implements PipeTransform {
|
|
666
|
+
transform(value: unknown[], match: unknown, key?: string): boolean;
|
|
667
|
+
private getNestedValue;
|
|
668
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<EveryPipe, never>;
|
|
669
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<EveryPipe, "every", true>;
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
/**
|
|
673
|
+
* IntersectionPipe: Returns elements common to both arrays.
|
|
674
|
+
*
|
|
675
|
+
* Supports primitives and objects by property key with dot notation.
|
|
676
|
+
*
|
|
677
|
+
* @param {unknown[]} value - The first array.
|
|
678
|
+
* @param {unknown[]} compared - The second array.
|
|
679
|
+
* @param {string} [key] - Optional property path for object comparison (supports dot notation).
|
|
680
|
+
*
|
|
681
|
+
* @returns {unknown[]} - Elements present in both arrays.
|
|
682
|
+
*
|
|
683
|
+
* @example
|
|
684
|
+
* {{ [1, 2, 3, 4] | intersection:[3, 4, 5, 6] }} // [3, 4]
|
|
685
|
+
* {{ teamA | intersection:teamB:'id' }} // shared members
|
|
686
|
+
* {{ required | intersection:granted:'meta.scope' }} // matched permissions
|
|
687
|
+
*/
|
|
688
|
+
declare class IntersectionPipe implements PipeTransform {
|
|
689
|
+
transform(value: unknown[], compared: unknown[], key?: string): unknown[];
|
|
690
|
+
private getNestedValue;
|
|
691
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<IntersectionPipe, never>;
|
|
692
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<IntersectionPipe, "intersection", true>;
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
/**
|
|
696
|
+
* ChunkPipe: Splits an array into smaller arrays of a specified size.
|
|
697
|
+
*
|
|
698
|
+
* @param {unknown[]} value - The array to split.
|
|
699
|
+
* @param {number} [size=1] - The size of each chunk.
|
|
700
|
+
*
|
|
701
|
+
* @returns {unknown[][]} - An array of chunks.
|
|
702
|
+
*
|
|
703
|
+
* @example
|
|
704
|
+
* {{ [1, 2, 3, 4, 5] | chunk:2 }} // [[1, 2], [3, 4], [5]]
|
|
705
|
+
* {{ [1, 2, 3, 4, 5, 6] | chunk:3 }} // [[1, 2, 3], [4, 5, 6]]
|
|
706
|
+
*/
|
|
707
|
+
declare class ChunkPipe implements PipeTransform {
|
|
708
|
+
transform(value: unknown[], size?: number): unknown[][];
|
|
709
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ChunkPipe, never>;
|
|
710
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<ChunkPipe, "chunk", true>;
|
|
711
|
+
}
|
|
712
|
+
|
|
642
713
|
/**
|
|
643
714
|
* FlattenPipe: Flattens nested arrays to a specified depth.
|
|
644
715
|
*
|
|
@@ -658,6 +729,25 @@ declare class Flatten implements PipeTransform {
|
|
|
658
729
|
static ɵpipe: i0.ɵɵPipeDeclaration<Flatten, "flatten", true>;
|
|
659
730
|
}
|
|
660
731
|
|
|
732
|
+
/**
|
|
733
|
+
* GroupByPipe: Groups array elements by a property value.
|
|
734
|
+
*
|
|
735
|
+
* @param {unknown[]} value - The array to group.
|
|
736
|
+
* @param {string} key - Property path to group by (supports dot notation).
|
|
737
|
+
*
|
|
738
|
+
* @returns {Record<string, unknown[]>} - An object where keys are group names and values are arrays.
|
|
739
|
+
*
|
|
740
|
+
* @example
|
|
741
|
+
* {{ users | groupBy:'role' }} // { admin: [...], editor: [...] }
|
|
742
|
+
* {{ orders | groupBy:'customer.city' }} // { 'New York': [...], 'London': [...] }
|
|
743
|
+
*/
|
|
744
|
+
declare class GroupByPipe implements PipeTransform {
|
|
745
|
+
transform(value: unknown[], key: string): Record<string, unknown[]>;
|
|
746
|
+
private getNestedValue;
|
|
747
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<GroupByPipe, never>;
|
|
748
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<GroupByPipe, "groupBy", true>;
|
|
749
|
+
}
|
|
750
|
+
|
|
661
751
|
/**
|
|
662
752
|
* InitialPipe: Returns all elements except the last n.
|
|
663
753
|
*
|
|
@@ -677,6 +767,66 @@ declare class InitialPipe implements PipeTransform {
|
|
|
677
767
|
static ɵpipe: i0.ɵɵPipeDeclaration<InitialPipe, "initial", true>;
|
|
678
768
|
}
|
|
679
769
|
|
|
770
|
+
/**
|
|
771
|
+
* OrderByPipe: Sorts an array by a property value.
|
|
772
|
+
*
|
|
773
|
+
* @param {unknown[]} value - The array to sort.
|
|
774
|
+
* @param {string} key - Property path to sort by (supports dot notation).
|
|
775
|
+
* @param {string} [direction='asc'] - Sort direction: 'asc' or 'desc'.
|
|
776
|
+
*
|
|
777
|
+
* @returns {unknown[]} - A new sorted array.
|
|
778
|
+
*
|
|
779
|
+
* @example
|
|
780
|
+
* {{ users | orderBy:'name' }} // sorted A-Z
|
|
781
|
+
* {{ users | orderBy:'name':'desc' }} // sorted Z-A
|
|
782
|
+
* {{ users | orderBy:'age':'asc' }} // sorted by age
|
|
783
|
+
*/
|
|
784
|
+
declare class OrderByPipe implements PipeTransform {
|
|
785
|
+
transform(value: unknown[], key: string, direction?: 'asc' | 'desc'): unknown[];
|
|
786
|
+
private getNestedValue;
|
|
787
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<OrderByPipe, never>;
|
|
788
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<OrderByPipe, "orderBy", true>;
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
/**
|
|
792
|
+
* PluckPipe: Extracts a property value from every object in an array.
|
|
793
|
+
*
|
|
794
|
+
* @param {unknown[]} value - The array of objects.
|
|
795
|
+
* @param {string} key - Property path to extract (supports dot notation).
|
|
796
|
+
*
|
|
797
|
+
* @returns {unknown[]} - An array of the extracted values.
|
|
798
|
+
*
|
|
799
|
+
* @example
|
|
800
|
+
* {{ users | pluck:'name' }} // ['Alice', 'Bob', 'Carol']
|
|
801
|
+
* {{ orders | pluck:'customer.email' }} // ['a@test.com', 'b@test.com']
|
|
802
|
+
*/
|
|
803
|
+
declare class PluckPipe implements PipeTransform {
|
|
804
|
+
transform(value: unknown[], key: string): unknown[];
|
|
805
|
+
private getNestedValue;
|
|
806
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<PluckPipe, never>;
|
|
807
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<PluckPipe, "pluck", true>;
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
/**
|
|
811
|
+
* RangePipe: Generates a numeric sequence array.
|
|
812
|
+
*
|
|
813
|
+
* @param {number} value - The number of items to generate (or the end value when start is provided).
|
|
814
|
+
* @param {number} [start=0] - The starting number.
|
|
815
|
+
* @param {number} [step=1] - The increment between each number.
|
|
816
|
+
*
|
|
817
|
+
* @returns {number[]} - An array of sequential numbers.
|
|
818
|
+
*
|
|
819
|
+
* @example
|
|
820
|
+
* {{ 5 | range }} // [0, 1, 2, 3, 4]
|
|
821
|
+
* {{ 5 | range:1 }} // [1, 2, 3, 4, 5]
|
|
822
|
+
* {{ 10 | range:0:2 }} // [0, 2, 4, 6, 8]
|
|
823
|
+
*/
|
|
824
|
+
declare class RangePipe implements PipeTransform {
|
|
825
|
+
transform(value: number, start?: number, step?: number): number[];
|
|
826
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<RangePipe, never>;
|
|
827
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<RangePipe, "range", true>;
|
|
828
|
+
}
|
|
829
|
+
|
|
680
830
|
/**
|
|
681
831
|
* ReversePipe: Reverses the characters in a string.
|
|
682
832
|
*
|
|
@@ -805,7 +955,382 @@ declare class UniquePipe implements PipeTransform {
|
|
|
805
955
|
static ɵpipe: i0.ɵɵPipeDeclaration<UniquePipe, "unique", true>;
|
|
806
956
|
}
|
|
807
957
|
|
|
958
|
+
/**
|
|
959
|
+
* WithoutPipe: Excludes specified elements from an array.
|
|
960
|
+
*
|
|
961
|
+
* Supports primitives and objects by property key with dot notation.
|
|
962
|
+
*
|
|
963
|
+
* @param {unknown[]} value - The array to filter.
|
|
964
|
+
* @param {unknown[]} excludes - Values to exclude.
|
|
965
|
+
* @param {string} [key] - Optional property path for object comparison (supports dot notation).
|
|
966
|
+
*
|
|
967
|
+
* @returns {unknown[]} - A new array without the excluded elements.
|
|
968
|
+
*
|
|
969
|
+
* @example
|
|
970
|
+
* {{ [1, 2, 3, 4, 5] | without:[2, 4] }} // [1, 3, 5]
|
|
971
|
+
* {{ users | without:['banned']:'status' }} // active users
|
|
972
|
+
* {{ orders | without:['cancelled']:'meta.status' }} // non-cancelled orders
|
|
973
|
+
*/
|
|
974
|
+
declare class WithoutPipe implements PipeTransform {
|
|
975
|
+
transform(value: unknown[], excludes: unknown[], key?: string): unknown[];
|
|
976
|
+
private getNestedValue;
|
|
977
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<WithoutPipe, never>;
|
|
978
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<WithoutPipe, "without", true>;
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
/**
|
|
982
|
+
* SomePipe: Checks if at least one element in an array satisfies a condition.
|
|
983
|
+
*
|
|
984
|
+
* Supports primitives (equality check) and objects by property key with dot notation.
|
|
985
|
+
*
|
|
986
|
+
* @param {unknown[]} value - The array to check.
|
|
987
|
+
* @param {unknown} match - The value to match against.
|
|
988
|
+
* @param {string} [key] - Optional property path to check (supports dot notation).
|
|
989
|
+
*
|
|
990
|
+
* @returns {boolean} - True if at least one element matches, false otherwise.
|
|
991
|
+
*
|
|
992
|
+
* @example
|
|
993
|
+
* {{ [false, false, true] | some:true }} // true
|
|
994
|
+
* {{ users | some:'admin':'role' }} // any admins?
|
|
995
|
+
* {{ orders | some:'failed':'meta.status' }} // any failures?
|
|
996
|
+
*/
|
|
997
|
+
declare class SomePipe implements PipeTransform {
|
|
998
|
+
transform(value: unknown[], match: unknown, key?: string): boolean;
|
|
999
|
+
private getNestedValue;
|
|
1000
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<SomePipe, never>;
|
|
1001
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<SomePipe, "some", true>;
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
/**
|
|
1005
|
+
* UnionPipe: Combines two arrays, keeping only unique elements.
|
|
1006
|
+
*
|
|
1007
|
+
* Supports primitives and objects by property key with dot notation.
|
|
1008
|
+
*
|
|
1009
|
+
* @param {unknown[]} value - The first array.
|
|
1010
|
+
* @param {unknown[]} other - The second array.
|
|
1011
|
+
* @param {string} [key] - Optional property path for uniqueness check (supports dot notation).
|
|
1012
|
+
*
|
|
1013
|
+
* @returns {unknown[]} - A merged array with duplicates removed.
|
|
1014
|
+
*
|
|
1015
|
+
* @example
|
|
1016
|
+
* {{ [1, 2, 3] | union:[3, 4, 5] }} // [1, 2, 3, 4, 5]
|
|
1017
|
+
* {{ admins | union:editors:'id' }} // all unique users
|
|
1018
|
+
* {{ local | union:remote:'meta.uuid' }} // merged records
|
|
1019
|
+
*/
|
|
1020
|
+
declare class UnionPipe implements PipeTransform {
|
|
1021
|
+
transform(value: unknown[], other: unknown[], key?: string): unknown[];
|
|
1022
|
+
private getNestedValue;
|
|
1023
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<UnionPipe, never>;
|
|
1024
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<UnionPipe, "union", true>;
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
/**
|
|
1028
|
+
* FilterByPipe: Filters an array by matching a search term against object
|
|
1029
|
+
properties.
|
|
1030
|
+
*
|
|
1031
|
+
* @param {unknown[]} value - The array to filter.
|
|
1032
|
+
* @param {string} search - The search term.
|
|
1033
|
+
* @param {string} [key] - Property to search in. If omitted, searches all string
|
|
1034
|
+
properties.
|
|
1035
|
+
*
|
|
1036
|
+
* @returns {unknown[]} - Filtered array with matching items.
|
|
1037
|
+
*
|
|
1038
|
+
* @example
|
|
1039
|
+
* {{ users | filterBy:'alice':'name' }} // users with 'alice' in name
|
|
1040
|
+
* {{ users | filterBy:'admin':'role' }} // users with role 'admin'
|
|
1041
|
+
* {{ users | filterBy:'bob' }} // search all properties for 'bob'
|
|
1042
|
+
*/
|
|
1043
|
+
declare class FilterByPipe implements PipeTransform {
|
|
1044
|
+
transform(value: unknown[], search: string, key?: string): unknown[];
|
|
1045
|
+
private searchObject;
|
|
1046
|
+
private getNestedValue;
|
|
1047
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<FilterByPipe, never>;
|
|
1048
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<FilterByPipe, "filterBy", true>;
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
/**
|
|
1052
|
+
* MinPipe: Returns the minimum value from an array of numbers or objects.
|
|
1053
|
+
*
|
|
1054
|
+
* Supports primitive number arrays and object arrays by property key with dot notation.
|
|
1055
|
+
*
|
|
1056
|
+
* @param {unknown[]} value - The array to evaluate.
|
|
1057
|
+
* @param {string} [key] - Optional property path for object comparison (supports dot notation).
|
|
1058
|
+
*
|
|
1059
|
+
* @returns {number | undefined} - The minimum value, or undefined if the array is empty/invalid.
|
|
1060
|
+
*
|
|
1061
|
+
* @example
|
|
1062
|
+
* {{ [5, 3, 8, 1, 9] | min }} // 1
|
|
1063
|
+
* {{ products | min:'price' }} // cheapest price
|
|
1064
|
+
* {{ orders | min:'meta.total' }} // lowest order total
|
|
1065
|
+
*/
|
|
1066
|
+
declare class MinPipe implements PipeTransform {
|
|
1067
|
+
transform(value: unknown[], key?: string): number | undefined;
|
|
1068
|
+
private getNestedValue;
|
|
1069
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<MinPipe, never>;
|
|
1070
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<MinPipe, "min", true>;
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1073
|
+
/**
|
|
1074
|
+
* MaxPipe: Returns the maximum value from an array of numbers or objects.
|
|
1075
|
+
*
|
|
1076
|
+
* Supports primitive number arrays and object arrays by property key with dot notation.
|
|
1077
|
+
*
|
|
1078
|
+
* @param {unknown[]} value - The array to evaluate.
|
|
1079
|
+
* @param {string} [key] - Optional property path for object comparison (supports dot notation).
|
|
1080
|
+
*
|
|
1081
|
+
* @returns {number | undefined} - The maximum value, or undefined if the array is empty/invalid.
|
|
1082
|
+
*
|
|
1083
|
+
* @example
|
|
1084
|
+
* {{ [5, 3, 8, 1, 9] | max }} // 9
|
|
1085
|
+
* {{ products | max:'price' }} // highest price
|
|
1086
|
+
* {{ orders | max:'meta.total' }} // largest order total
|
|
1087
|
+
*/
|
|
1088
|
+
declare class MaxPipe implements PipeTransform {
|
|
1089
|
+
transform(value: unknown[], key?: string): number | undefined;
|
|
1090
|
+
private getNestedValue;
|
|
1091
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<MaxPipe, never>;
|
|
1092
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<MaxPipe, "max", true>;
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
/**
|
|
1096
|
+
* SumPipe: Returns the sum of all numeric values in an array.
|
|
1097
|
+
*
|
|
1098
|
+
* Supports primitive number arrays and object arrays by property key with dot notation.
|
|
1099
|
+
*
|
|
1100
|
+
* @param {unknown[]} value - The array to evaluate.
|
|
1101
|
+
* @param {string} [key] - Optional property path for object summation (supports dot notation).
|
|
1102
|
+
*
|
|
1103
|
+
* @returns {number | undefined} - The total, or undefined if the array is empty/invalid.
|
|
1104
|
+
*
|
|
1105
|
+
* @example
|
|
1106
|
+
* {{ [10, 20, 30] | sum }} // 60
|
|
1107
|
+
* {{ items | sum:'price' }} // total price
|
|
1108
|
+
* {{ orders | sum:'meta.total' }} // grand total
|
|
1109
|
+
*/
|
|
1110
|
+
declare class SumPipe implements PipeTransform {
|
|
1111
|
+
transform(value: unknown[], key?: string): number | undefined;
|
|
1112
|
+
private getNestedValue;
|
|
1113
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<SumPipe, never>;
|
|
1114
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<SumPipe, "sum", true>;
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
/**
|
|
1118
|
+
* AveragePipe: Returns the arithmetic mean of all numeric values in an array.
|
|
1119
|
+
*
|
|
1120
|
+
* Supports primitive number arrays and object arrays by property key with dot notation.
|
|
1121
|
+
*
|
|
1122
|
+
* @param {unknown[]} value - The array to evaluate.
|
|
1123
|
+
* @param {string} [key] - Optional property path for object averaging (supports dot notation).
|
|
1124
|
+
*
|
|
1125
|
+
* @returns {number | undefined} - The average, or undefined if the array is empty/invalid.
|
|
1126
|
+
*
|
|
1127
|
+
* @example
|
|
1128
|
+
* {{ [10, 20, 30] | average }} // 20
|
|
1129
|
+
* {{ students | average:'grade' }} // average grade
|
|
1130
|
+
* {{ reviews | average:'meta.rating' }} // average rating
|
|
1131
|
+
*/
|
|
1132
|
+
declare class AveragePipe implements PipeTransform {
|
|
1133
|
+
transform(value: unknown[], key?: string): number | undefined;
|
|
1134
|
+
private getNestedValue;
|
|
1135
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<AveragePipe, never>;
|
|
1136
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<AveragePipe, "average", true>;
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
/**
|
|
1140
|
+
* PercentagePipe: Calculates what percentage a value represents of a total.
|
|
1141
|
+
*
|
|
1142
|
+
* Returns `(value / total) * 100`, optionally rounded to a given number of decimal places.
|
|
1143
|
+
*
|
|
1144
|
+
* @param {number} value - The partial value.
|
|
1145
|
+
* @param {number} total - The total/whole value.
|
|
1146
|
+
* @param {number} [decimals] - Optional number of decimal places to round to.
|
|
1147
|
+
*
|
|
1148
|
+
* @returns {number | undefined} - The percentage, or undefined if inputs are invalid.
|
|
1149
|
+
*
|
|
1150
|
+
* @example
|
|
1151
|
+
* {{ 25 | percentage:200 }} // 12.5
|
|
1152
|
+
* {{ 1 | percentage:3:2 }} // 33.33
|
|
1153
|
+
* {{ 750 | percentage:1000 }} // 75
|
|
1154
|
+
*/
|
|
1155
|
+
declare class PercentagePipe implements PipeTransform {
|
|
1156
|
+
transform(value: number, total: number, decimals?: number): number | undefined;
|
|
1157
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<PercentagePipe, never>;
|
|
1158
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<PercentagePipe, "percentage", true>;
|
|
1159
|
+
}
|
|
1160
|
+
|
|
1161
|
+
/**
|
|
1162
|
+
* CeilPipe: Rounds a number up to the specified number of decimal places.
|
|
1163
|
+
*
|
|
1164
|
+
* Uses `Math.ceil` — always rounds toward positive infinity.
|
|
1165
|
+
*
|
|
1166
|
+
* @param {number} value - The number to round up.
|
|
1167
|
+
* @param {number} [precision=0] - Number of decimal places to preserve (defaults to 0 = integer).
|
|
1168
|
+
*
|
|
1169
|
+
* @returns {number | undefined} - The rounded-up value, or undefined if the input is invalid.
|
|
1170
|
+
*
|
|
1171
|
+
* @example
|
|
1172
|
+
* {{ 4.1 | ceil }} // 5
|
|
1173
|
+
* {{ 4.123 | ceil:2 }} // 4.13
|
|
1174
|
+
* {{ 0.001 | ceil:2 }} // 0.01
|
|
1175
|
+
* {{ -4.9 | ceil }} // -4
|
|
1176
|
+
*/
|
|
1177
|
+
declare class CeilPipe implements PipeTransform {
|
|
1178
|
+
transform(value: number, precision?: number): number | undefined;
|
|
1179
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<CeilPipe, never>;
|
|
1180
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<CeilPipe, "ceil", true>;
|
|
1181
|
+
}
|
|
1182
|
+
|
|
1183
|
+
/**
|
|
1184
|
+
* FloorPipe: Rounds a number down to the specified number of decimal places.
|
|
1185
|
+
*
|
|
1186
|
+
* Uses `Math.floor` — always rounds toward negative infinity.
|
|
1187
|
+
*
|
|
1188
|
+
* @param {number} value - The number to round down.
|
|
1189
|
+
* @param {number} [precision=0] - Number of decimal places to preserve (defaults to 0 = integer).
|
|
1190
|
+
*
|
|
1191
|
+
* @returns {number | undefined} - The rounded-down value, or undefined if the input is invalid.
|
|
1192
|
+
*
|
|
1193
|
+
* @example
|
|
1194
|
+
* {{ 4.9 | floor }} // 4
|
|
1195
|
+
* {{ 4.567 | floor:2 }} // 4.56
|
|
1196
|
+
* {{ 0.999 | floor:1 }} // 0.9
|
|
1197
|
+
* {{ -4.1 | floor }} // -5
|
|
1198
|
+
*/
|
|
1199
|
+
declare class FloorPipe implements PipeTransform {
|
|
1200
|
+
transform(value: number, precision?: number): number | undefined;
|
|
1201
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<FloorPipe, never>;
|
|
1202
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<FloorPipe, "floor", true>;
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
/**
|
|
1206
|
+
* RoundPipe: Rounds a number to the nearest value at the specified number of decimal places.
|
|
1207
|
+
*
|
|
1208
|
+
* Uses `Math.round` — rounds half-up (e.g. 2.5 → 3, -2.5 → -2).
|
|
1209
|
+
*
|
|
1210
|
+
* @param {number} value - The number to round.
|
|
1211
|
+
* @param {number} [precision=0] - Number of decimal places to preserve (defaults to 0 = integer).
|
|
1212
|
+
*
|
|
1213
|
+
* @returns {number | undefined} - The rounded value, or undefined if the input is invalid.
|
|
1214
|
+
*
|
|
1215
|
+
* @example
|
|
1216
|
+
* {{ 4.4 | round }} // 4
|
|
1217
|
+
* {{ 4.5 | round }} // 5
|
|
1218
|
+
* {{ 4.567 | round:2 }} // 4.57
|
|
1219
|
+
* {{ 0.125 | round:2 }} // 0.13
|
|
1220
|
+
*/
|
|
1221
|
+
declare class RoundPipe implements PipeTransform {
|
|
1222
|
+
transform(value: number, precision?: number): number | undefined;
|
|
1223
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<RoundPipe, never>;
|
|
1224
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<RoundPipe, "round", true>;
|
|
1225
|
+
}
|
|
1226
|
+
|
|
1227
|
+
/**
|
|
1228
|
+
* SqrtPipe: Returns the square root of a number.
|
|
1229
|
+
*
|
|
1230
|
+
* Uses `Math.sqrt`. Returns undefined for negative numbers.
|
|
1231
|
+
*
|
|
1232
|
+
* @param {number} value - The number to compute the square root of.
|
|
1233
|
+
*
|
|
1234
|
+
* @returns {number | undefined} - The square root, or undefined if the input is invalid or negative.
|
|
1235
|
+
*
|
|
1236
|
+
* @example
|
|
1237
|
+
* {{ 9 | sqrt }} // 3
|
|
1238
|
+
* {{ 2 | sqrt }} // 1.4142135623730951
|
|
1239
|
+
* {{ 144 | sqrt }} // 12
|
|
1240
|
+
*/
|
|
1241
|
+
declare class SqrtPipe implements PipeTransform {
|
|
1242
|
+
transform(value: number): number | undefined;
|
|
1243
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<SqrtPipe, never>;
|
|
1244
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<SqrtPipe, "sqrt", true>;
|
|
1245
|
+
}
|
|
1246
|
+
|
|
1247
|
+
/**
|
|
1248
|
+
* PowPipe: Raises a number to the specified power.
|
|
1249
|
+
*
|
|
1250
|
+
* Uses `Math.pow`. The exponent defaults to 2 (squaring).
|
|
1251
|
+
*
|
|
1252
|
+
* @param {number} value - The base number.
|
|
1253
|
+
* @param {number} [exponent=2] - The power to raise the base to (defaults to 2).
|
|
1254
|
+
*
|
|
1255
|
+
* @returns {number | undefined} - The result, or undefined if the inputs are invalid.
|
|
1256
|
+
*
|
|
1257
|
+
* @example
|
|
1258
|
+
* {{ 3 | pow }} // 9 (3^2)
|
|
1259
|
+
* {{ 2 | pow:3 }} // 8 (2^3)
|
|
1260
|
+
* {{ 5 | pow:0 }} // 1 (anything^0)
|
|
1261
|
+
*/
|
|
1262
|
+
declare class PowPipe implements PipeTransform {
|
|
1263
|
+
transform(value: number, exponent?: number): number | undefined;
|
|
1264
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<PowPipe, never>;
|
|
1265
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<PowPipe, "pow", true>;
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
/**
|
|
1269
|
+
* DegreesPipe: Converts a value in radians to degrees.
|
|
1270
|
+
*
|
|
1271
|
+
* Formula: `degrees = radians * (180 / Math.PI)`
|
|
1272
|
+
*
|
|
1273
|
+
* @param {number} value - The angle in radians.
|
|
1274
|
+
*
|
|
1275
|
+
* @returns {number | undefined} - The angle in degrees, or undefined if the input is invalid.
|
|
1276
|
+
*
|
|
1277
|
+
* @example
|
|
1278
|
+
* {{ 3.14159 | degrees }} // ~180
|
|
1279
|
+
* {{ 1.5708 | degrees }} // ~90
|
|
1280
|
+
* {{ 0 | degrees }} // 0
|
|
1281
|
+
*/
|
|
1282
|
+
declare class DegreesPipe implements PipeTransform {
|
|
1283
|
+
transform(value: number): number | undefined;
|
|
1284
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<DegreesPipe, never>;
|
|
1285
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<DegreesPipe, "degrees", true>;
|
|
1286
|
+
}
|
|
1287
|
+
|
|
1288
|
+
/**
|
|
1289
|
+
* BytesPipe: Formats a number of bytes into a human-readable string with appropriate units.
|
|
1290
|
+
*
|
|
1291
|
+
* Supports both binary (1024-based: KiB, MiB, GiB) and decimal (1000-based: KB, MB, GB) units.
|
|
1292
|
+
* Defaults to decimal (1000-based) units.
|
|
1293
|
+
*
|
|
1294
|
+
* @param {number} value - The number of bytes.
|
|
1295
|
+
* @param {number} [decimals=1] - Number of decimal places in the output.
|
|
1296
|
+
* @param {string} [base='decimal'] - Unit base: 'decimal' (1000, KB/MB/GB) or 'binary' (1024, KiB/MiB/GiB).
|
|
1297
|
+
*
|
|
1298
|
+
* @returns {string | undefined} - The formatted string, or undefined if the input is invalid.
|
|
1299
|
+
*
|
|
1300
|
+
* @example
|
|
1301
|
+
* {{ 1536 | bytes }} // "1.5 KB"
|
|
1302
|
+
* {{ 1048576 | bytes:2 }} // "1.05 MB"
|
|
1303
|
+
* {{ 1073741824 | bytes:1:'binary' }} // "1.0 GiB"
|
|
1304
|
+
*/
|
|
1305
|
+
declare class BytesPipe implements PipeTransform {
|
|
1306
|
+
private readonly decimalUnits;
|
|
1307
|
+
private readonly binaryUnits;
|
|
1308
|
+
transform(value: number, decimals?: number, base?: 'decimal' | 'binary'): string | undefined;
|
|
1309
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<BytesPipe, never>;
|
|
1310
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<BytesPipe, "bytes", true>;
|
|
1311
|
+
}
|
|
1312
|
+
|
|
1313
|
+
/**
|
|
1314
|
+
* RadiansPipe: Converts a value in degrees to radians.
|
|
1315
|
+
*
|
|
1316
|
+
* Formula: `radians = degrees * (Math.PI / 180)`
|
|
1317
|
+
*
|
|
1318
|
+
* @param {number} value - The angle in degrees.
|
|
1319
|
+
*
|
|
1320
|
+
* @returns {number | undefined} - The angle in radians, or undefined if the input is invalid.
|
|
1321
|
+
*
|
|
1322
|
+
* @example
|
|
1323
|
+
* {{ 180 | radians }} // ~3.14159
|
|
1324
|
+
* {{ 90 | radians }} // ~1.5708
|
|
1325
|
+
* {{ 0 | radians }} // 0
|
|
1326
|
+
*/
|
|
1327
|
+
declare class RadiansPipe implements PipeTransform {
|
|
1328
|
+
transform(value: number): number | undefined;
|
|
1329
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<RadiansPipe, never>;
|
|
1330
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<RadiansPipe, "radians", true>;
|
|
1331
|
+
}
|
|
1332
|
+
|
|
808
1333
|
declare const ALL_PIPES: Provider[];
|
|
809
1334
|
|
|
810
|
-
export { ALL_PIPES, AsciiArtPipe, BarcodePipe, CamelCasePipe, ColorConvertPipe, CountPipe, CreditCardMaskPipe, DeviceTypePipe, EmailMaskPipe, Flatten, GravatarPipe, HighlightPipe, HtmlEscapePipe, HtmlSanitizePipe, InitialPipe, InitialsPipe, IpAddressMaskPipe, JsonPrettyPipe, KebabCasePipe, MorseCodePipe, QrCodePipe, ReplacePipe, ReversePipe, SamplePipe, ShufflePipe, SnakeCasePipe, TailPipe, TextToSpeechPipe, TimeAgoPipePipe, TitleCasePipe, TruncatePipe, TruthifyPipe, UniquePipe };
|
|
1335
|
+
export { ALL_PIPES, AsciiArtPipe, AveragePipe, BarcodePipe, BytesPipe, CamelCasePipe, CeilPipe, ChunkPipe, ColorConvertPipe, CountPipe, CreditCardMaskPipe, DegreesPipe, DeviceTypePipe, DiffPipe, EmailMaskPipe, EveryPipe, FilterByPipe, Flatten, FloorPipe, GravatarPipe, GroupByPipe, HighlightPipe, HtmlEscapePipe, HtmlSanitizePipe, InitialPipe, InitialsPipe, IntersectionPipe, IpAddressMaskPipe, JsonPrettyPipe, KebabCasePipe, MaxPipe, MinPipe, MorseCodePipe, OrderByPipe, PercentagePipe, PluckPipe, PowPipe, QrCodePipe, RadiansPipe, RangePipe, ReplacePipe, ReversePipe, RoundPipe, SamplePipe, ShufflePipe, SnakeCasePipe, SomePipe, SqrtPipe, SumPipe, TailPipe, TextToSpeechPipe, TimeAgoPipePipe, TitleCasePipe, TruncatePipe, TruthifyPipe, UnionPipe, UniquePipe, WithoutPipe };
|
|
811
1336
|
export type { AsciiArtOptions, BarcodeElementType, BarcodeFormat, BarcodeOptions, ColorTargetType, DeviceType, QrCodeOptions };
|