ngx-transforms 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1048,7 +1048,289 @@ declare class FilterByPipe implements PipeTransform {
|
|
|
1048
1048
|
static ɵpipe: i0.ɵɵPipeDeclaration<FilterByPipe, "filterBy", true>;
|
|
1049
1049
|
}
|
|
1050
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
|
+
|
|
1051
1333
|
declare const ALL_PIPES: Provider[];
|
|
1052
1334
|
|
|
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 };
|
|
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 };
|
|
1054
1336
|
export type { AsciiArtOptions, BarcodeElementType, BarcodeFormat, BarcodeOptions, ColorTargetType, DeviceType, QrCodeOptions };
|