ngx-transforms 0.1.0 → 0.2.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.
@@ -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,100 @@ 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
+
808
1051
  declare const ALL_PIPES: Provider[];
809
1052
 
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 };
1053
+ 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 };
811
1054
  export type { AsciiArtOptions, BarcodeElementType, BarcodeFormat, BarcodeOptions, ColorTargetType, DeviceType, QrCodeOptions };