@bigbinary/neeto-commons-frontend 2.1.1 → 2.1.3

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigbinary/neeto-commons-frontend",
3
- "version": "2.1.1",
3
+ "version": "2.1.3",
4
4
  "description": "A package encapsulating common code across neeto projects including initializers, utility functions, common components and hooks and so on.",
5
5
  "repository": "git@github.com:bigbinary/neeto-commons-frontend.git",
6
6
  "author": "Amaljith K <amaljith.k@bigbinary.com>",
package/pure.d.ts CHANGED
@@ -1391,7 +1391,7 @@ export function _renameKeys<M extends {
1391
1391
  *
1392
1392
  * @endexample
1393
1393
  */
1394
- export function replaceBy<T>(pattern: MatchPattern<T>, entityArray: T[]): T[];
1394
+ export function replaceBy<T>(pattern: MatchPattern<T>, entity: T, entityArray: T[]): T[];
1395
1395
  /**
1396
1396
  *
1397
1397
  * Curried: true
@@ -1414,9 +1414,59 @@ export function replaceBy<T>(pattern: MatchPattern<T>, entityArray: T[]): T[];
1414
1414
  *
1415
1415
  * @endexample
1416
1416
  */
1417
- export function replaceBy(pattern: MatchPattern): <T>(entityArray: T[]) => T[];
1418
- export function _replaceBy<T>(pattern: MatchPattern<T>, entityArray: NilOr<T[]>): NilOr<T[]>;
1419
- export function _replaceBy(pattern: MatchPattern): <T>(entityArray: NilOr<T[]>) => NilOr<T[]>;
1417
+ export function replaceBy<T>(pattern: MatchPattern<T>, entity: T): <T>(entityArray: T[]) => T[];
1418
+ /**
1419
+ *
1420
+ * Curried: true
1421
+ *
1422
+ * Failsafe status: alternative available
1423
+ *
1424
+ * Replace all items that matches the given pattern with the given item.
1425
+ *
1426
+ * @example
1427
+ *
1428
+ * const array = [
1429
+ * { id: 1, name: "Sam", address: { street: "First street", pin: 101283 } },
1430
+ * { id: 2, name: "Oliver", address: { street: "Second street", pin: 998472 } },
1431
+ * ];
1432
+ * const newItem = { id: 2, name: "John" };
1433
+ *
1434
+ * replaceBy({ name: "Oliver" }, newItem, array);
1435
+ *
1436
+ * [{id: 1, name: "Sam"}, {id: 2, name: "John"}]
1437
+ *
1438
+ * @endexample
1439
+ */
1440
+ export function replaceBy(pattern: MatchPattern): <T>(entity: T) => (entityArray: T[]) => T[];
1441
+ export function _replaceBy<T>(pattern: MatchPattern<T>, entity: NilOr<T>, entityArray: NilOr<T[]>): NilOr<T[]>;
1442
+ export function _replaceBy<T>(pattern: MatchPattern<T>, entity: NilOr<T>): <T>(entityArray: NilOr<T[]>) => NilOr<T[]>;
1443
+ export function _replaceBy(pattern: MatchPattern): <T>(entity: NilOr<T>) => <T>(entityArray: NilOr<T[]>) => NilOr<T[]>;
1444
+ /**
1445
+ *
1446
+ * Curried: true
1447
+ *
1448
+ * Failsafe status: alternative available
1449
+ *
1450
+ * Returns a new array with the item having the given id is replaced with the given
1451
+ *
1452
+ * object.
1453
+ *
1454
+ * @example
1455
+ *
1456
+ * const array = [
1457
+ * { id: 1, name: "Sam" },
1458
+ * { id: 2, name: "Oliver" },
1459
+ * ];
1460
+ * const idOfItemToBeReplaced = 2;
1461
+ * const newItem = { id: 3, name: "John" };
1462
+ *
1463
+ * replaceById(idOfItemToBeReplaced, newItem, array);
1464
+ *
1465
+ * [{ id: 1, name: "Sam" }, { id: 3, name: "John" }]
1466
+ *
1467
+ * @endexample
1468
+ */
1469
+ export function replaceById<T>(id: any, entity: T, entityArray: T[]): T[];
1420
1470
  /**
1421
1471
  *
1422
1472
  * Curried: true
@@ -1442,7 +1492,7 @@ export function _replaceBy(pattern: MatchPattern): <T>(entityArray: NilOr<T[]>)
1442
1492
  *
1443
1493
  * @endexample
1444
1494
  */
1445
- export function replaceById<T>(id: any, entityArray: T[]): T[];
1495
+ export function replaceById<T>(id: any, entity: T): <T>(entityArray: T[]) => T[];
1446
1496
  /**
1447
1497
  *
1448
1498
  * Curried: true
@@ -1468,9 +1518,10 @@ export function replaceById<T>(id: any, entityArray: T[]): T[];
1468
1518
  *
1469
1519
  * @endexample
1470
1520
  */
1471
- export function replaceById(id: any): <T>(entityArray: T[]) => T[];
1472
- export function _replaceById<T>(id: any, entityArray: NilOr<T[]>): NilOr<T[]>;
1473
- export function _replaceById(id: any): <T>(entityArray: NilOr<T[]>) => NilOr<T[]>;
1521
+ export function replaceById(id: any): <T>(entity: T) => <T>(entityArray: T[]) => T[];
1522
+ export function _replaceById<T>(id: any, entity: NilOr<T>, entityArray: NilOr<T[]>): NilOr<T[]>;
1523
+ export function _replaceById<T>(id: any, entity: NilOr<T>): <T>(entityArray: NilOr<T[]>) => NilOr<T[]>;
1524
+ export function _replaceById(id: any): <T>(entity: NilOr<T>) => <T>(entityArray: NilOr<T[]>) => NilOr<T[]>;
1474
1525
  /**
1475
1526
  *
1476
1527
  * Curried: false