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.
@@ -315,22 +315,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImpor
315
315
  * @param {boolean} [isReplace=true] - Whether to perform replacement (true) or only highlight matches (false).
316
316
  *
317
317
  * @returns {string | SafeHtml} - Returns the transformed string or SafeHtml with highlights.
318
- *
319
- * @example
320
- * {{ 'Hello World' | replace:'World':'Universe' }}
321
- * // Output: Hello Universe
322
- *
323
- * {{ 'test123' | replace:/\d+/g:'X':'highlight' }}
324
- * // Output: test<span class="highlight">X</span>
325
- *
326
- * {{ 'Angular is great' | replace:'great':'awesome':'highlight':true }}
327
- * // Output: Angular is <span class="highlight">awesome</span>
328
- *
329
- * {{ 'Angular is great' | replace:'great':'awesome':'highlight':false }}
330
- * // Output: Angular is <span class="highlight">great</span>
331
- *
332
- * <div [innerHTML]="'Angular is great' | replace:'great':'awesome':'highlight':false"></div>
333
- * // Renders: Angular is <span class="highlight">great</span>
334
318
  */
335
319
  class ReplacePipe {
336
320
  sanitizer = inject(DomSanitizer);
@@ -1204,6 +1188,179 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImpor
1204
1188
  }]
1205
1189
  }] });
1206
1190
 
1191
+ /**
1192
+ * DiffPipe: Returns elements present in the first array but not in the second.
1193
+ *
1194
+ * Supports primitives and objects by property key with dot notation.
1195
+ *
1196
+ * @param {unknown[]} value - The source array.
1197
+ * @param {unknown[]} compared - The array to compare against.
1198
+ * @param {string} [key] - Optional property path for object comparison (supports dot notation).
1199
+ *
1200
+ * @returns {unknown[]} - Elements in value that are not in compared.
1201
+ *
1202
+ * @example
1203
+ * {{ [1, 2, 3, 4, 5] | diff:[3, 4, 5, 6] }} // [1, 2]
1204
+ * {{ allUsers | diff:activeUsers:'id' }} // inactive users
1205
+ * {{ orders | diff:shipped:'meta.trackingId' }} // unshipped orders
1206
+ */
1207
+ class DiffPipe {
1208
+ transform(value, compared, key) {
1209
+ if (!Array.isArray(value)) {
1210
+ return [];
1211
+ }
1212
+ if (!Array.isArray(compared) || compared.length === 0) {
1213
+ return [...value];
1214
+ }
1215
+ if (!key) {
1216
+ const comparedSet = new Set(compared);
1217
+ return value.filter(item => !comparedSet.has(item));
1218
+ }
1219
+ const comparedSet = new Set(compared.map(item => this.getNestedValue(item, key)));
1220
+ return value.filter(item => {
1221
+ const val = this.getNestedValue(item, key);
1222
+ return !comparedSet.has(val);
1223
+ });
1224
+ }
1225
+ getNestedValue(obj, path) {
1226
+ return path.split('.').reduce((current, segment) => current?.[segment], obj);
1227
+ }
1228
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: DiffPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1229
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: DiffPipe, isStandalone: true, name: "diff" });
1230
+ }
1231
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: DiffPipe, decorators: [{
1232
+ type: Pipe,
1233
+ args: [{
1234
+ name: 'diff',
1235
+ standalone: true,
1236
+ }]
1237
+ }] });
1238
+
1239
+ /**
1240
+ * EveryPipe: Checks if all elements in an array satisfy a condition.
1241
+ *
1242
+ * Supports primitives (equality check) and objects by property key with dot notation.
1243
+ *
1244
+ * @param {unknown[]} value - The array to check.
1245
+ * @param {unknown} match - The value to match against.
1246
+ * @param {string} [key] - Optional property path to check (supports dot notation).
1247
+ *
1248
+ * @returns {boolean} - True if all elements match, false otherwise.
1249
+ *
1250
+ * @example
1251
+ * {{ [true, true, true] | every:true }} // true
1252
+ * {{ users | every:'active':'status' }} // are all users active?
1253
+ * {{ orders | every:'shipped':'meta.state' }} // are all orders shipped?
1254
+ */
1255
+ class EveryPipe {
1256
+ transform(value, match, key) {
1257
+ if (!Array.isArray(value) || value.length === 0) {
1258
+ return false;
1259
+ }
1260
+ if (!key) {
1261
+ return value.every(item => item === match);
1262
+ }
1263
+ return value.every(item => this.getNestedValue(item, key) === match);
1264
+ }
1265
+ getNestedValue(obj, path) {
1266
+ return path.split('.').reduce((current, segment) => current?.[segment], obj);
1267
+ }
1268
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: EveryPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1269
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: EveryPipe, isStandalone: true, name: "every" });
1270
+ }
1271
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: EveryPipe, decorators: [{
1272
+ type: Pipe,
1273
+ args: [{
1274
+ name: 'every',
1275
+ standalone: true,
1276
+ }]
1277
+ }] });
1278
+
1279
+ /**
1280
+ * IntersectionPipe: Returns elements common to both arrays.
1281
+ *
1282
+ * Supports primitives and objects by property key with dot notation.
1283
+ *
1284
+ * @param {unknown[]} value - The first array.
1285
+ * @param {unknown[]} compared - The second array.
1286
+ * @param {string} [key] - Optional property path for object comparison (supports dot notation).
1287
+ *
1288
+ * @returns {unknown[]} - Elements present in both arrays.
1289
+ *
1290
+ * @example
1291
+ * {{ [1, 2, 3, 4] | intersection:[3, 4, 5, 6] }} // [3, 4]
1292
+ * {{ teamA | intersection:teamB:'id' }} // shared members
1293
+ * {{ required | intersection:granted:'meta.scope' }} // matched permissions
1294
+ */
1295
+ class IntersectionPipe {
1296
+ transform(value, compared, key) {
1297
+ if (!Array.isArray(value)) {
1298
+ return [];
1299
+ }
1300
+ if (!Array.isArray(compared) || compared.length === 0) {
1301
+ return [];
1302
+ }
1303
+ if (!key) {
1304
+ const comparedSet = new Set(compared);
1305
+ return value.filter(item => comparedSet.has(item));
1306
+ }
1307
+ const comparedSet = new Set(compared.map(item => this.getNestedValue(item, key)));
1308
+ return value.filter(item => {
1309
+ const val = this.getNestedValue(item, key);
1310
+ return comparedSet.has(val);
1311
+ });
1312
+ }
1313
+ getNestedValue(obj, path) {
1314
+ return path.split('.').reduce((current, segment) => current?.[segment], obj);
1315
+ }
1316
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: IntersectionPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1317
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: IntersectionPipe, isStandalone: true, name: "intersection" });
1318
+ }
1319
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: IntersectionPipe, decorators: [{
1320
+ type: Pipe,
1321
+ args: [{
1322
+ name: 'intersection',
1323
+ standalone: true,
1324
+ }]
1325
+ }] });
1326
+
1327
+ /**
1328
+ * ChunkPipe: Splits an array into smaller arrays of a specified size.
1329
+ *
1330
+ * @param {unknown[]} value - The array to split.
1331
+ * @param {number} [size=1] - The size of each chunk.
1332
+ *
1333
+ * @returns {unknown[][]} - An array of chunks.
1334
+ *
1335
+ * @example
1336
+ * {{ [1, 2, 3, 4, 5] | chunk:2 }} // [[1, 2], [3, 4], [5]]
1337
+ * {{ [1, 2, 3, 4, 5, 6] | chunk:3 }} // [[1, 2, 3], [4, 5, 6]]
1338
+ */
1339
+ class ChunkPipe {
1340
+ transform(value, size = 1) {
1341
+ if (!Array.isArray(value) || value.length === 0) {
1342
+ return [];
1343
+ }
1344
+ if (size <= 0) {
1345
+ return [];
1346
+ }
1347
+ const result = [];
1348
+ for (let i = 0; i < value.length; i += size) {
1349
+ result.push(value.slice(i, i + size));
1350
+ }
1351
+ return result;
1352
+ }
1353
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: ChunkPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1354
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: ChunkPipe, isStandalone: true, name: "chunk" });
1355
+ }
1356
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: ChunkPipe, decorators: [{
1357
+ type: Pipe,
1358
+ args: [{
1359
+ name: 'chunk',
1360
+ standalone: true
1361
+ }]
1362
+ }] });
1363
+
1207
1364
  /**
1208
1365
  * FlattenPipe: Flattens nested arrays to a specified depth.
1209
1366
  *
@@ -1235,6 +1392,46 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImpor
1235
1392
  }]
1236
1393
  }] });
1237
1394
 
1395
+ /**
1396
+ * GroupByPipe: Groups array elements by a property value.
1397
+ *
1398
+ * @param {unknown[]} value - The array to group.
1399
+ * @param {string} key - Property path to group by (supports dot notation).
1400
+ *
1401
+ * @returns {Record<string, unknown[]>} - An object where keys are group names and values are arrays.
1402
+ *
1403
+ * @example
1404
+ * {{ users | groupBy:'role' }} // { admin: [...], editor: [...] }
1405
+ * {{ orders | groupBy:'customer.city' }} // { 'New York': [...], 'London': [...] }
1406
+ */
1407
+ class GroupByPipe {
1408
+ transform(value, key) {
1409
+ if (!Array.isArray(value) || !key) {
1410
+ return {};
1411
+ }
1412
+ return value.reduce((groups, item) => {
1413
+ const groupKey = String(this.getNestedValue(item, key) ?? 'undefined');
1414
+ if (!groups[groupKey]) {
1415
+ groups[groupKey] = [];
1416
+ }
1417
+ groups[groupKey].push(item);
1418
+ return groups;
1419
+ }, {});
1420
+ }
1421
+ getNestedValue(obj, path) {
1422
+ return path.split('.').reduce((current, segment) => current?.[segment], obj);
1423
+ }
1424
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: GroupByPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1425
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: GroupByPipe, isStandalone: true, name: "groupBy" });
1426
+ }
1427
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: GroupByPipe, decorators: [{
1428
+ type: Pipe,
1429
+ args: [{
1430
+ name: 'groupBy',
1431
+ standalone: true,
1432
+ }]
1433
+ }] });
1434
+
1238
1435
  /**
1239
1436
  * InitialPipe: Returns all elements except the last n.
1240
1437
  *
@@ -1272,6 +1469,130 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImpor
1272
1469
  }]
1273
1470
  }] });
1274
1471
 
1472
+ /**
1473
+ * OrderByPipe: Sorts an array by a property value.
1474
+ *
1475
+ * @param {unknown[]} value - The array to sort.
1476
+ * @param {string} key - Property path to sort by (supports dot notation).
1477
+ * @param {string} [direction='asc'] - Sort direction: 'asc' or 'desc'.
1478
+ *
1479
+ * @returns {unknown[]} - A new sorted array.
1480
+ *
1481
+ * @example
1482
+ * {{ users | orderBy:'name' }} // sorted A-Z
1483
+ * {{ users | orderBy:'name':'desc' }} // sorted Z-A
1484
+ * {{ users | orderBy:'age':'asc' }} // sorted by age
1485
+ */
1486
+ class OrderByPipe {
1487
+ transform(value, key, direction = 'asc') {
1488
+ if (!Array.isArray(value) || value.length <= 1 || !key) {
1489
+ return Array.isArray(value) ? [...value] : [];
1490
+ }
1491
+ const dir = direction === 'desc' ? -1 : 1;
1492
+ return [...value].sort((a, b) => {
1493
+ const valA = this.getNestedValue(a, key);
1494
+ const valB = this.getNestedValue(b, key);
1495
+ if (valA === valB)
1496
+ return 0;
1497
+ if (valA === null || valA === undefined)
1498
+ return 1;
1499
+ if (valB === null || valB === undefined)
1500
+ return -1;
1501
+ if (typeof valA === 'string' && typeof valB === 'string') {
1502
+ return valA.localeCompare(valB) * dir;
1503
+ }
1504
+ if (typeof valA === 'number' && typeof valB === 'number') {
1505
+ return (valA - valB) * dir;
1506
+ }
1507
+ return String(valA).localeCompare(String(valB)) * dir;
1508
+ });
1509
+ }
1510
+ getNestedValue(obj, path) {
1511
+ return path.split('.').reduce((current, segment) => current?.[segment], obj);
1512
+ }
1513
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: OrderByPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1514
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: OrderByPipe, isStandalone: true, name: "orderBy" });
1515
+ }
1516
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: OrderByPipe, decorators: [{
1517
+ type: Pipe,
1518
+ args: [{
1519
+ name: 'orderBy',
1520
+ standalone: true,
1521
+ }]
1522
+ }] });
1523
+
1524
+ /**
1525
+ * PluckPipe: Extracts a property value from every object in an array.
1526
+ *
1527
+ * @param {unknown[]} value - The array of objects.
1528
+ * @param {string} key - Property path to extract (supports dot notation).
1529
+ *
1530
+ * @returns {unknown[]} - An array of the extracted values.
1531
+ *
1532
+ * @example
1533
+ * {{ users | pluck:'name' }} // ['Alice', 'Bob', 'Carol']
1534
+ * {{ orders | pluck:'customer.email' }} // ['a@test.com', 'b@test.com']
1535
+ */
1536
+ class PluckPipe {
1537
+ transform(value, key) {
1538
+ if (!Array.isArray(value) || !key) {
1539
+ return [];
1540
+ }
1541
+ return value.map(item => this.getNestedValue(item, key));
1542
+ }
1543
+ getNestedValue(obj, path) {
1544
+ return path.split('.').reduce((current, segment) => current?.[segment], obj);
1545
+ }
1546
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: PluckPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1547
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: PluckPipe, isStandalone: true, name: "pluck" });
1548
+ }
1549
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: PluckPipe, decorators: [{
1550
+ type: Pipe,
1551
+ args: [{
1552
+ name: 'pluck',
1553
+ standalone: true,
1554
+ }]
1555
+ }] });
1556
+
1557
+ /**
1558
+ * RangePipe: Generates a numeric sequence array.
1559
+ *
1560
+ * @param {number} value - The number of items to generate (or the end value when start is provided).
1561
+ * @param {number} [start=0] - The starting number.
1562
+ * @param {number} [step=1] - The increment between each number.
1563
+ *
1564
+ * @returns {number[]} - An array of sequential numbers.
1565
+ *
1566
+ * @example
1567
+ * {{ 5 | range }} // [0, 1, 2, 3, 4]
1568
+ * {{ 5 | range:1 }} // [1, 2, 3, 4, 5]
1569
+ * {{ 10 | range:0:2 }} // [0, 2, 4, 6, 8]
1570
+ */
1571
+ class RangePipe {
1572
+ transform(value, start = 0, step = 1) {
1573
+ if (typeof value !== 'number' || isNaN(value) || value <= 0) {
1574
+ return [];
1575
+ }
1576
+ if (step === 0) {
1577
+ return [];
1578
+ }
1579
+ const result = [];
1580
+ for (let i = 0; i < value; i++) {
1581
+ result.push(start + i * step);
1582
+ }
1583
+ return result;
1584
+ }
1585
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: RangePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1586
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: RangePipe, isStandalone: true, name: "range" });
1587
+ }
1588
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: RangePipe, decorators: [{
1589
+ type: Pipe,
1590
+ args: [{
1591
+ name: 'range',
1592
+ standalone: true,
1593
+ }]
1594
+ }] });
1595
+
1275
1596
  /**
1276
1597
  * ReversePipe: Reverses the characters in a string.
1277
1598
  *
@@ -1512,6 +1833,732 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImpor
1512
1833
  }]
1513
1834
  }] });
1514
1835
 
1836
+ /**
1837
+ * WithoutPipe: Excludes specified elements from an array.
1838
+ *
1839
+ * Supports primitives and objects by property key with dot notation.
1840
+ *
1841
+ * @param {unknown[]} value - The array to filter.
1842
+ * @param {unknown[]} excludes - Values to exclude.
1843
+ * @param {string} [key] - Optional property path for object comparison (supports dot notation).
1844
+ *
1845
+ * @returns {unknown[]} - A new array without the excluded elements.
1846
+ *
1847
+ * @example
1848
+ * {{ [1, 2, 3, 4, 5] | without:[2, 4] }} // [1, 3, 5]
1849
+ * {{ users | without:['banned']:'status' }} // active users
1850
+ * {{ orders | without:['cancelled']:'meta.status' }} // non-cancelled orders
1851
+ */
1852
+ class WithoutPipe {
1853
+ transform(value, excludes, key) {
1854
+ if (!Array.isArray(value)) {
1855
+ return [];
1856
+ }
1857
+ if (!Array.isArray(excludes) || excludes.length === 0) {
1858
+ return [...value];
1859
+ }
1860
+ const excludeSet = new Set(excludes);
1861
+ if (!key) {
1862
+ return value.filter(item => !excludeSet.has(item));
1863
+ }
1864
+ return value.filter(item => {
1865
+ const val = this.getNestedValue(item, key);
1866
+ return !excludeSet.has(val);
1867
+ });
1868
+ }
1869
+ getNestedValue(obj, path) {
1870
+ return path.split('.').reduce((current, segment) => current?.[segment], obj);
1871
+ }
1872
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: WithoutPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1873
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: WithoutPipe, isStandalone: true, name: "without" });
1874
+ }
1875
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: WithoutPipe, decorators: [{
1876
+ type: Pipe,
1877
+ args: [{
1878
+ name: 'without',
1879
+ standalone: true,
1880
+ }]
1881
+ }] });
1882
+
1883
+ /**
1884
+ * SomePipe: Checks if at least one element in an array satisfies a condition.
1885
+ *
1886
+ * Supports primitives (equality check) and objects by property key with dot notation.
1887
+ *
1888
+ * @param {unknown[]} value - The array to check.
1889
+ * @param {unknown} match - The value to match against.
1890
+ * @param {string} [key] - Optional property path to check (supports dot notation).
1891
+ *
1892
+ * @returns {boolean} - True if at least one element matches, false otherwise.
1893
+ *
1894
+ * @example
1895
+ * {{ [false, false, true] | some:true }} // true
1896
+ * {{ users | some:'admin':'role' }} // any admins?
1897
+ * {{ orders | some:'failed':'meta.status' }} // any failures?
1898
+ */
1899
+ class SomePipe {
1900
+ transform(value, match, key) {
1901
+ if (!Array.isArray(value) || value.length === 0) {
1902
+ return false;
1903
+ }
1904
+ if (!key) {
1905
+ return value.some(item => item === match);
1906
+ }
1907
+ return value.some(item => this.getNestedValue(item, key) === match);
1908
+ }
1909
+ getNestedValue(obj, path) {
1910
+ return path.split('.').reduce((current, segment) => current?.[segment], obj);
1911
+ }
1912
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: SomePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1913
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: SomePipe, isStandalone: true, name: "some" });
1914
+ }
1915
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: SomePipe, decorators: [{
1916
+ type: Pipe,
1917
+ args: [{
1918
+ name: 'some',
1919
+ standalone: true,
1920
+ }]
1921
+ }] });
1922
+
1923
+ /**
1924
+ * UnionPipe: Combines two arrays, keeping only unique elements.
1925
+ *
1926
+ * Supports primitives and objects by property key with dot notation.
1927
+ *
1928
+ * @param {unknown[]} value - The first array.
1929
+ * @param {unknown[]} other - The second array.
1930
+ * @param {string} [key] - Optional property path for uniqueness check (supports dot notation).
1931
+ *
1932
+ * @returns {unknown[]} - A merged array with duplicates removed.
1933
+ *
1934
+ * @example
1935
+ * {{ [1, 2, 3] | union:[3, 4, 5] }} // [1, 2, 3, 4, 5]
1936
+ * {{ admins | union:editors:'id' }} // all unique users
1937
+ * {{ local | union:remote:'meta.uuid' }} // merged records
1938
+ */
1939
+ class UnionPipe {
1940
+ transform(value, other, key) {
1941
+ if (!Array.isArray(value) && !Array.isArray(other)) {
1942
+ return [];
1943
+ }
1944
+ const first = Array.isArray(value) ? value : [];
1945
+ const second = Array.isArray(other) ? other : [];
1946
+ if (!key) {
1947
+ const seen = new Set();
1948
+ const result = [];
1949
+ for (const item of [...first, ...second]) {
1950
+ if (!seen.has(item)) {
1951
+ seen.add(item);
1952
+ result.push(item);
1953
+ }
1954
+ }
1955
+ return result;
1956
+ }
1957
+ const seen = new Set();
1958
+ const result = [];
1959
+ for (const item of [...first, ...second]) {
1960
+ const val = this.getNestedValue(item, key);
1961
+ if (!seen.has(val)) {
1962
+ seen.add(val);
1963
+ result.push(item);
1964
+ }
1965
+ }
1966
+ return result;
1967
+ }
1968
+ getNestedValue(obj, path) {
1969
+ return path.split('.').reduce((current, segment) => current?.[segment], obj);
1970
+ }
1971
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: UnionPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1972
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: UnionPipe, isStandalone: true, name: "union" });
1973
+ }
1974
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: UnionPipe, decorators: [{
1975
+ type: Pipe,
1976
+ args: [{
1977
+ name: 'union',
1978
+ standalone: true,
1979
+ }]
1980
+ }] });
1981
+
1982
+ /**
1983
+ * FilterByPipe: Filters an array by matching a search term against object
1984
+ properties.
1985
+ *
1986
+ * @param {unknown[]} value - The array to filter.
1987
+ * @param {string} search - The search term.
1988
+ * @param {string} [key] - Property to search in. If omitted, searches all string
1989
+ properties.
1990
+ *
1991
+ * @returns {unknown[]} - Filtered array with matching items.
1992
+ *
1993
+ * @example
1994
+ * {{ users | filterBy:'alice':'name' }} // users with 'alice' in name
1995
+ * {{ users | filterBy:'admin':'role' }} // users with role 'admin'
1996
+ * {{ users | filterBy:'bob' }} // search all properties for 'bob'
1997
+ */
1998
+ class FilterByPipe {
1999
+ transform(value, search, key) {
2000
+ if (!Array.isArray(value) || !search) {
2001
+ return Array.isArray(value) ? [...value] : [];
2002
+ }
2003
+ const term = String(search).toLowerCase();
2004
+ if (key) {
2005
+ return value.filter(item => {
2006
+ const val = this.getNestedValue(item, key);
2007
+ return val !== undefined && val !== null
2008
+ && String(val).toLowerCase().includes(term);
2009
+ });
2010
+ }
2011
+ return value.filter(item => {
2012
+ if (typeof item === 'object' && item !== null) {
2013
+ return this.searchObject(item, term);
2014
+ }
2015
+ return String(item).toLowerCase().includes(term);
2016
+ });
2017
+ }
2018
+ searchObject(obj, term) {
2019
+ return Object.values(obj).some(val => {
2020
+ if (typeof val === 'string') {
2021
+ return val.toLowerCase().includes(term);
2022
+ }
2023
+ if (typeof val === 'number' || typeof val === 'boolean') {
2024
+ return String(val).toLowerCase().includes(term);
2025
+ }
2026
+ if (typeof val === 'object' && val !== null) {
2027
+ return this.searchObject(val, term);
2028
+ }
2029
+ return false;
2030
+ });
2031
+ }
2032
+ getNestedValue(obj, path) {
2033
+ return path.split('.').reduce((current, segment) => current?.[segment], obj);
2034
+ }
2035
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: FilterByPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
2036
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: FilterByPipe, isStandalone: true, name: "filterBy" });
2037
+ }
2038
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: FilterByPipe, decorators: [{
2039
+ type: Pipe,
2040
+ args: [{
2041
+ name: 'filterBy',
2042
+ standalone: true,
2043
+ }]
2044
+ }] });
2045
+
2046
+ /**
2047
+ * MinPipe: Returns the minimum value from an array of numbers or objects.
2048
+ *
2049
+ * Supports primitive number arrays and object arrays by property key with dot notation.
2050
+ *
2051
+ * @param {unknown[]} value - The array to evaluate.
2052
+ * @param {string} [key] - Optional property path for object comparison (supports dot notation).
2053
+ *
2054
+ * @returns {number | undefined} - The minimum value, or undefined if the array is empty/invalid.
2055
+ *
2056
+ * @example
2057
+ * {{ [5, 3, 8, 1, 9] | min }} // 1
2058
+ * {{ products | min:'price' }} // cheapest price
2059
+ * {{ orders | min:'meta.total' }} // lowest order total
2060
+ */
2061
+ class MinPipe {
2062
+ transform(value, key) {
2063
+ if (!Array.isArray(value) || value.length === 0) {
2064
+ return undefined;
2065
+ }
2066
+ if (!key) {
2067
+ const numbers = value.filter((item) => typeof item === 'number' && !isNaN(item));
2068
+ return numbers.length === 0 ? undefined : Math.min(...numbers);
2069
+ }
2070
+ const numbers = value
2071
+ .map(item => this.getNestedValue(item, key))
2072
+ .filter((val) => typeof val === 'number' && !isNaN(val));
2073
+ return numbers.length === 0 ? undefined : Math.min(...numbers);
2074
+ }
2075
+ getNestedValue(obj, path) {
2076
+ return path.split('.').reduce((current, segment) => current?.[segment], obj);
2077
+ }
2078
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: MinPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
2079
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: MinPipe, isStandalone: true, name: "min" });
2080
+ }
2081
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: MinPipe, decorators: [{
2082
+ type: Pipe,
2083
+ args: [{
2084
+ name: 'min',
2085
+ standalone: true,
2086
+ }]
2087
+ }] });
2088
+
2089
+ /**
2090
+ * MaxPipe: Returns the maximum value from an array of numbers or objects.
2091
+ *
2092
+ * Supports primitive number arrays and object arrays by property key with dot notation.
2093
+ *
2094
+ * @param {unknown[]} value - The array to evaluate.
2095
+ * @param {string} [key] - Optional property path for object comparison (supports dot notation).
2096
+ *
2097
+ * @returns {number | undefined} - The maximum value, or undefined if the array is empty/invalid.
2098
+ *
2099
+ * @example
2100
+ * {{ [5, 3, 8, 1, 9] | max }} // 9
2101
+ * {{ products | max:'price' }} // highest price
2102
+ * {{ orders | max:'meta.total' }} // largest order total
2103
+ */
2104
+ class MaxPipe {
2105
+ transform(value, key) {
2106
+ if (!Array.isArray(value) || value.length === 0) {
2107
+ return undefined;
2108
+ }
2109
+ if (!key) {
2110
+ const numbers = value.filter((item) => typeof item === 'number' && !isNaN(item));
2111
+ return numbers.length === 0 ? undefined : Math.max(...numbers);
2112
+ }
2113
+ const numbers = value
2114
+ .map(item => this.getNestedValue(item, key))
2115
+ .filter((val) => typeof val === 'number' && !isNaN(val));
2116
+ return numbers.length === 0 ? undefined : Math.max(...numbers);
2117
+ }
2118
+ getNestedValue(obj, path) {
2119
+ return path.split('.').reduce((current, segment) => current?.[segment], obj);
2120
+ }
2121
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: MaxPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
2122
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: MaxPipe, isStandalone: true, name: "max" });
2123
+ }
2124
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: MaxPipe, decorators: [{
2125
+ type: Pipe,
2126
+ args: [{
2127
+ name: 'max',
2128
+ standalone: true,
2129
+ }]
2130
+ }] });
2131
+
2132
+ /**
2133
+ * SumPipe: Returns the sum of all numeric values in an array.
2134
+ *
2135
+ * Supports primitive number arrays and object arrays by property key with dot notation.
2136
+ *
2137
+ * @param {unknown[]} value - The array to evaluate.
2138
+ * @param {string} [key] - Optional property path for object summation (supports dot notation).
2139
+ *
2140
+ * @returns {number | undefined} - The total, or undefined if the array is empty/invalid.
2141
+ *
2142
+ * @example
2143
+ * {{ [10, 20, 30] | sum }} // 60
2144
+ * {{ items | sum:'price' }} // total price
2145
+ * {{ orders | sum:'meta.total' }} // grand total
2146
+ */
2147
+ class SumPipe {
2148
+ transform(value, key) {
2149
+ if (!Array.isArray(value) || value.length === 0) {
2150
+ return undefined;
2151
+ }
2152
+ if (!key) {
2153
+ const numbers = value.filter((item) => typeof item === 'number' && !isNaN(item));
2154
+ return numbers.length === 0 ? undefined : numbers.reduce((acc, n) => acc + n, 0);
2155
+ }
2156
+ const numbers = value
2157
+ .map(item => this.getNestedValue(item, key))
2158
+ .filter((val) => typeof val === 'number' && !isNaN(val));
2159
+ return numbers.length === 0 ? undefined : numbers.reduce((acc, n) => acc + n, 0);
2160
+ }
2161
+ getNestedValue(obj, path) {
2162
+ return path.split('.').reduce((current, segment) => current?.[segment], obj);
2163
+ }
2164
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: SumPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
2165
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: SumPipe, isStandalone: true, name: "sum" });
2166
+ }
2167
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: SumPipe, decorators: [{
2168
+ type: Pipe,
2169
+ args: [{
2170
+ name: 'sum',
2171
+ standalone: true,
2172
+ }]
2173
+ }] });
2174
+
2175
+ /**
2176
+ * AveragePipe: Returns the arithmetic mean of all numeric values in an array.
2177
+ *
2178
+ * Supports primitive number arrays and object arrays by property key with dot notation.
2179
+ *
2180
+ * @param {unknown[]} value - The array to evaluate.
2181
+ * @param {string} [key] - Optional property path for object averaging (supports dot notation).
2182
+ *
2183
+ * @returns {number | undefined} - The average, or undefined if the array is empty/invalid.
2184
+ *
2185
+ * @example
2186
+ * {{ [10, 20, 30] | average }} // 20
2187
+ * {{ students | average:'grade' }} // average grade
2188
+ * {{ reviews | average:'meta.rating' }} // average rating
2189
+ */
2190
+ class AveragePipe {
2191
+ transform(value, key) {
2192
+ if (!Array.isArray(value) || value.length === 0) {
2193
+ return undefined;
2194
+ }
2195
+ if (!key) {
2196
+ const numbers = value.filter((item) => typeof item === 'number' && !isNaN(item));
2197
+ return numbers.length === 0 ? undefined : numbers.reduce((acc, n) => acc + n, 0) / numbers.length;
2198
+ }
2199
+ const numbers = value
2200
+ .map(item => this.getNestedValue(item, key))
2201
+ .filter((val) => typeof val === 'number' && !isNaN(val));
2202
+ return numbers.length === 0 ? undefined : numbers.reduce((acc, n) => acc + n, 0) / numbers.length;
2203
+ }
2204
+ getNestedValue(obj, path) {
2205
+ return path.split('.').reduce((current, segment) => current?.[segment], obj);
2206
+ }
2207
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: AveragePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
2208
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: AveragePipe, isStandalone: true, name: "average" });
2209
+ }
2210
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: AveragePipe, decorators: [{
2211
+ type: Pipe,
2212
+ args: [{
2213
+ name: 'average',
2214
+ standalone: true,
2215
+ }]
2216
+ }] });
2217
+
2218
+ /**
2219
+ * PercentagePipe: Calculates what percentage a value represents of a total.
2220
+ *
2221
+ * Returns `(value / total) * 100`, optionally rounded to a given number of decimal places.
2222
+ *
2223
+ * @param {number} value - The partial value.
2224
+ * @param {number} total - The total/whole value.
2225
+ * @param {number} [decimals] - Optional number of decimal places to round to.
2226
+ *
2227
+ * @returns {number | undefined} - The percentage, or undefined if inputs are invalid.
2228
+ *
2229
+ * @example
2230
+ * {{ 25 | percentage:200 }} // 12.5
2231
+ * {{ 1 | percentage:3:2 }} // 33.33
2232
+ * {{ 750 | percentage:1000 }} // 75
2233
+ */
2234
+ class PercentagePipe {
2235
+ transform(value, total, decimals) {
2236
+ if (typeof value !== 'number' || isNaN(value)) {
2237
+ return undefined;
2238
+ }
2239
+ if (typeof total !== 'number' || isNaN(total) || total === 0) {
2240
+ return undefined;
2241
+ }
2242
+ const result = (value / total) * 100;
2243
+ if (typeof decimals === 'number' && decimals >= 0) {
2244
+ const factor = Math.pow(10, decimals);
2245
+ return Math.round(result * factor) / factor;
2246
+ }
2247
+ return result;
2248
+ }
2249
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: PercentagePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
2250
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: PercentagePipe, isStandalone: true, name: "percentage" });
2251
+ }
2252
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: PercentagePipe, decorators: [{
2253
+ type: Pipe,
2254
+ args: [{
2255
+ name: 'percentage',
2256
+ standalone: true,
2257
+ }]
2258
+ }] });
2259
+
2260
+ /**
2261
+ * CeilPipe: Rounds a number up to the specified number of decimal places.
2262
+ *
2263
+ * Uses `Math.ceil` — always rounds toward positive infinity.
2264
+ *
2265
+ * @param {number} value - The number to round up.
2266
+ * @param {number} [precision=0] - Number of decimal places to preserve (defaults to 0 = integer).
2267
+ *
2268
+ * @returns {number | undefined} - The rounded-up value, or undefined if the input is invalid.
2269
+ *
2270
+ * @example
2271
+ * {{ 4.1 | ceil }} // 5
2272
+ * {{ 4.123 | ceil:2 }} // 4.13
2273
+ * {{ 0.001 | ceil:2 }} // 0.01
2274
+ * {{ -4.9 | ceil }} // -4
2275
+ */
2276
+ class CeilPipe {
2277
+ transform(value, precision = 0) {
2278
+ if (typeof value !== 'number' || isNaN(value)) {
2279
+ return undefined;
2280
+ }
2281
+ if (typeof precision !== 'number' || isNaN(precision) || precision < 0) {
2282
+ return undefined;
2283
+ }
2284
+ const factor = Math.pow(10, precision);
2285
+ return Math.ceil(value * factor) / factor;
2286
+ }
2287
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: CeilPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
2288
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: CeilPipe, isStandalone: true, name: "ceil" });
2289
+ }
2290
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: CeilPipe, decorators: [{
2291
+ type: Pipe,
2292
+ args: [{
2293
+ name: 'ceil',
2294
+ standalone: true,
2295
+ }]
2296
+ }] });
2297
+
2298
+ /**
2299
+ * FloorPipe: Rounds a number down to the specified number of decimal places.
2300
+ *
2301
+ * Uses `Math.floor` — always rounds toward negative infinity.
2302
+ *
2303
+ * @param {number} value - The number to round down.
2304
+ * @param {number} [precision=0] - Number of decimal places to preserve (defaults to 0 = integer).
2305
+ *
2306
+ * @returns {number | undefined} - The rounded-down value, or undefined if the input is invalid.
2307
+ *
2308
+ * @example
2309
+ * {{ 4.9 | floor }} // 4
2310
+ * {{ 4.567 | floor:2 }} // 4.56
2311
+ * {{ 0.999 | floor:1 }} // 0.9
2312
+ * {{ -4.1 | floor }} // -5
2313
+ */
2314
+ class FloorPipe {
2315
+ transform(value, precision = 0) {
2316
+ if (typeof value !== 'number' || isNaN(value)) {
2317
+ return undefined;
2318
+ }
2319
+ if (typeof precision !== 'number' || isNaN(precision) || precision < 0) {
2320
+ return undefined;
2321
+ }
2322
+ const factor = Math.pow(10, precision);
2323
+ return Math.floor(value * factor) / factor;
2324
+ }
2325
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: FloorPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
2326
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: FloorPipe, isStandalone: true, name: "floor" });
2327
+ }
2328
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: FloorPipe, decorators: [{
2329
+ type: Pipe,
2330
+ args: [{
2331
+ name: 'floor',
2332
+ standalone: true,
2333
+ }]
2334
+ }] });
2335
+
2336
+ /**
2337
+ * RoundPipe: Rounds a number to the nearest value at the specified number of decimal places.
2338
+ *
2339
+ * Uses `Math.round` — rounds half-up (e.g. 2.5 → 3, -2.5 → -2).
2340
+ *
2341
+ * @param {number} value - The number to round.
2342
+ * @param {number} [precision=0] - Number of decimal places to preserve (defaults to 0 = integer).
2343
+ *
2344
+ * @returns {number | undefined} - The rounded value, or undefined if the input is invalid.
2345
+ *
2346
+ * @example
2347
+ * {{ 4.4 | round }} // 4
2348
+ * {{ 4.5 | round }} // 5
2349
+ * {{ 4.567 | round:2 }} // 4.57
2350
+ * {{ 0.125 | round:2 }} // 0.13
2351
+ */
2352
+ class RoundPipe {
2353
+ transform(value, precision = 0) {
2354
+ if (typeof value !== 'number' || isNaN(value)) {
2355
+ return undefined;
2356
+ }
2357
+ if (typeof precision !== 'number' || isNaN(precision) || precision < 0) {
2358
+ return undefined;
2359
+ }
2360
+ const factor = Math.pow(10, precision);
2361
+ return Math.round(value * factor) / factor;
2362
+ }
2363
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: RoundPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
2364
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: RoundPipe, isStandalone: true, name: "round" });
2365
+ }
2366
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: RoundPipe, decorators: [{
2367
+ type: Pipe,
2368
+ args: [{
2369
+ name: 'round',
2370
+ standalone: true,
2371
+ }]
2372
+ }] });
2373
+
2374
+ /**
2375
+ * SqrtPipe: Returns the square root of a number.
2376
+ *
2377
+ * Uses `Math.sqrt`. Returns undefined for negative numbers.
2378
+ *
2379
+ * @param {number} value - The number to compute the square root of.
2380
+ *
2381
+ * @returns {number | undefined} - The square root, or undefined if the input is invalid or negative.
2382
+ *
2383
+ * @example
2384
+ * {{ 9 | sqrt }} // 3
2385
+ * {{ 2 | sqrt }} // 1.4142135623730951
2386
+ * {{ 144 | sqrt }} // 12
2387
+ */
2388
+ class SqrtPipe {
2389
+ transform(value) {
2390
+ if (typeof value !== 'number' || isNaN(value)) {
2391
+ return undefined;
2392
+ }
2393
+ if (value < 0) {
2394
+ return undefined;
2395
+ }
2396
+ return Math.sqrt(value);
2397
+ }
2398
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: SqrtPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
2399
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: SqrtPipe, isStandalone: true, name: "sqrt" });
2400
+ }
2401
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: SqrtPipe, decorators: [{
2402
+ type: Pipe,
2403
+ args: [{
2404
+ name: 'sqrt',
2405
+ standalone: true,
2406
+ }]
2407
+ }] });
2408
+
2409
+ /**
2410
+ * PowPipe: Raises a number to the specified power.
2411
+ *
2412
+ * Uses `Math.pow`. The exponent defaults to 2 (squaring).
2413
+ *
2414
+ * @param {number} value - The base number.
2415
+ * @param {number} [exponent=2] - The power to raise the base to (defaults to 2).
2416
+ *
2417
+ * @returns {number | undefined} - The result, or undefined if the inputs are invalid.
2418
+ *
2419
+ * @example
2420
+ * {{ 3 | pow }} // 9 (3^2)
2421
+ * {{ 2 | pow:3 }} // 8 (2^3)
2422
+ * {{ 5 | pow:0 }} // 1 (anything^0)
2423
+ */
2424
+ class PowPipe {
2425
+ transform(value, exponent = 2) {
2426
+ if (typeof value !== 'number' || isNaN(value)) {
2427
+ return undefined;
2428
+ }
2429
+ if (typeof exponent !== 'number' || isNaN(exponent)) {
2430
+ return undefined;
2431
+ }
2432
+ return Math.pow(value, exponent);
2433
+ }
2434
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: PowPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
2435
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: PowPipe, isStandalone: true, name: "pow" });
2436
+ }
2437
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: PowPipe, decorators: [{
2438
+ type: Pipe,
2439
+ args: [{
2440
+ name: 'pow',
2441
+ standalone: true,
2442
+ }]
2443
+ }] });
2444
+
2445
+ /**
2446
+ * DegreesPipe: Converts a value in radians to degrees.
2447
+ *
2448
+ * Formula: `degrees = radians * (180 / Math.PI)`
2449
+ *
2450
+ * @param {number} value - The angle in radians.
2451
+ *
2452
+ * @returns {number | undefined} - The angle in degrees, or undefined if the input is invalid.
2453
+ *
2454
+ * @example
2455
+ * {{ 3.14159 | degrees }} // ~180
2456
+ * {{ 1.5708 | degrees }} // ~90
2457
+ * {{ 0 | degrees }} // 0
2458
+ */
2459
+ class DegreesPipe {
2460
+ transform(value) {
2461
+ if (typeof value !== 'number' || isNaN(value)) {
2462
+ return undefined;
2463
+ }
2464
+ return value * (180 / Math.PI);
2465
+ }
2466
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: DegreesPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
2467
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: DegreesPipe, isStandalone: true, name: "degrees" });
2468
+ }
2469
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: DegreesPipe, decorators: [{
2470
+ type: Pipe,
2471
+ args: [{
2472
+ name: 'degrees',
2473
+ standalone: true,
2474
+ }]
2475
+ }] });
2476
+
2477
+ /**
2478
+ * BytesPipe: Formats a number of bytes into a human-readable string with appropriate units.
2479
+ *
2480
+ * Supports both binary (1024-based: KiB, MiB, GiB) and decimal (1000-based: KB, MB, GB) units.
2481
+ * Defaults to decimal (1000-based) units.
2482
+ *
2483
+ * @param {number} value - The number of bytes.
2484
+ * @param {number} [decimals=1] - Number of decimal places in the output.
2485
+ * @param {string} [base='decimal'] - Unit base: 'decimal' (1000, KB/MB/GB) or 'binary' (1024, KiB/MiB/GiB).
2486
+ *
2487
+ * @returns {string | undefined} - The formatted string, or undefined if the input is invalid.
2488
+ *
2489
+ * @example
2490
+ * {{ 1536 | bytes }} // "1.5 KB"
2491
+ * {{ 1048576 | bytes:2 }} // "1.05 MB"
2492
+ * {{ 1073741824 | bytes:1:'binary' }} // "1.0 GiB"
2493
+ */
2494
+ class BytesPipe {
2495
+ decimalUnits = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB'];
2496
+ binaryUnits = ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB'];
2497
+ transform(value, decimals = 1, base = 'decimal') {
2498
+ if (typeof value !== 'number' || isNaN(value)) {
2499
+ return undefined;
2500
+ }
2501
+ if (value < 0) {
2502
+ return undefined;
2503
+ }
2504
+ if (value === 0) {
2505
+ return '0 B';
2506
+ }
2507
+ const isBinary = base === 'binary';
2508
+ const divisor = isBinary ? 1024 : 1000;
2509
+ const units = isBinary ? this.binaryUnits : this.decimalUnits;
2510
+ let unitIndex = 0;
2511
+ let size = value;
2512
+ while (size >= divisor && unitIndex < units.length - 1) {
2513
+ size /= divisor;
2514
+ unitIndex++;
2515
+ }
2516
+ const precision = typeof decimals === 'number' && decimals >= 0 ? decimals : 1;
2517
+ return `${size.toFixed(precision)} ${units[unitIndex]}`;
2518
+ }
2519
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: BytesPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
2520
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: BytesPipe, isStandalone: true, name: "bytes" });
2521
+ }
2522
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: BytesPipe, decorators: [{
2523
+ type: Pipe,
2524
+ args: [{
2525
+ name: 'bytes',
2526
+ standalone: true,
2527
+ }]
2528
+ }] });
2529
+
2530
+ /**
2531
+ * RadiansPipe: Converts a value in degrees to radians.
2532
+ *
2533
+ * Formula: `radians = degrees * (Math.PI / 180)`
2534
+ *
2535
+ * @param {number} value - The angle in degrees.
2536
+ *
2537
+ * @returns {number | undefined} - The angle in radians, or undefined if the input is invalid.
2538
+ *
2539
+ * @example
2540
+ * {{ 180 | radians }} // ~3.14159
2541
+ * {{ 90 | radians }} // ~1.5708
2542
+ * {{ 0 | radians }} // 0
2543
+ */
2544
+ class RadiansPipe {
2545
+ transform(value) {
2546
+ if (typeof value !== 'number' || isNaN(value)) {
2547
+ return undefined;
2548
+ }
2549
+ return value * (Math.PI / 180);
2550
+ }
2551
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: RadiansPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
2552
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: RadiansPipe, isStandalone: true, name: "radians" });
2553
+ }
2554
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: RadiansPipe, decorators: [{
2555
+ type: Pipe,
2556
+ args: [{
2557
+ name: 'radians',
2558
+ standalone: true,
2559
+ }]
2560
+ }] });
2561
+
1515
2562
  // Text
1516
2563
  const ALL_PIPES = [
1517
2564
  // Text
@@ -1543,14 +2590,40 @@ const ALL_PIPES = [
1543
2590
  TextToSpeechPipe,
1544
2591
  TimeAgoPipePipe,
1545
2592
  // Array
2593
+ ChunkPipe,
2594
+ DiffPipe,
2595
+ EveryPipe,
2596
+ IntersectionPipe,
1546
2597
  Flatten,
2598
+ GroupByPipe,
1547
2599
  InitialPipe,
2600
+ OrderByPipe,
2601
+ PluckPipe,
2602
+ RangePipe,
1548
2603
  ReversePipe,
1549
2604
  SamplePipe,
1550
2605
  ShufflePipe,
1551
2606
  TailPipe,
1552
2607
  TruthifyPipe,
1553
2608
  UniquePipe,
2609
+ WithoutPipe,
2610
+ SomePipe,
2611
+ UnionPipe,
2612
+ FilterByPipe,
2613
+ // Math
2614
+ MinPipe,
2615
+ MaxPipe,
2616
+ SumPipe,
2617
+ AveragePipe,
2618
+ PercentagePipe,
2619
+ CeilPipe,
2620
+ FloorPipe,
2621
+ RoundPipe,
2622
+ SqrtPipe,
2623
+ PowPipe,
2624
+ DegreesPipe,
2625
+ BytesPipe,
2626
+ RadiansPipe,
1554
2627
  ];
1555
2628
 
1556
2629
  // Text
@@ -1559,5 +2632,5 @@ const ALL_PIPES = [
1559
2632
  * Generated bundle index. Do not edit.
1560
2633
  */
1561
2634
 
1562
- 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 };
2635
+ 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 };
1563
2636
  //# sourceMappingURL=ngx-transforms.mjs.map