@bbn/bbn 1.0.224 → 1.0.225

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.
@@ -0,0 +1 @@
1
+ export default function mutateObject(a1: any, a2: any, hashFn: any): any;
@@ -0,0 +1,28 @@
1
+ import isObject from '../type/isObject.js';
2
+ import hash from '../string/hash.js';
3
+ import isSame from '../type/isSame.js';
4
+ import checkType from '../type/checkType.js';
5
+ export default function mutateObject(a1, a2, hashFn) {
6
+ if (!isObject(a1, a2)) {
7
+ throw new TypeError('mutateObject can only be called with arrays');
8
+ }
9
+ if (hashFn) {
10
+ checkType(hashFn, 'function', 'The hash function must be a function');
11
+ }
12
+ else {
13
+ hashFn = hash;
14
+ }
15
+ var mapA2 = Object.keys(a2);
16
+ // Remove items from a1 that are not in a2
17
+ for (var n in a1) {
18
+ if (!mapA2.includes(n)) {
19
+ delete a1[n];
20
+ }
21
+ }
22
+ mapA2.forEach(function (n) {
23
+ if (!isSame(a1[n], a2[n])) {
24
+ a1[n] = a2[n];
25
+ }
26
+ });
27
+ return a1;
28
+ }
package/dist/fn.d.ts CHANGED
@@ -170,6 +170,7 @@ import money from './fn/misc/money.js';
170
170
  import move from './fn/object/move.js';
171
171
  import multiorder from './fn/object/multiorder.js';
172
172
  import mutateArray from './fn/object/mutateArray.js';
173
+ import mutateObject from './fn/object/mutateObject.js';
173
174
  import nl2br from './fn/string/nl2br.js';
174
175
  import numProperties from './fn/object/numProperties.js';
175
176
  import objectToFormData from './fn/form/objectToFormData.js';
@@ -401,6 +402,7 @@ declare const _default: {
401
402
  move: typeof move;
402
403
  multiorder: typeof multiorder;
403
404
  mutateArray: typeof mutateArray;
405
+ mutateObject: typeof mutateObject;
404
406
  nl2br: typeof nl2br;
405
407
  numProperties: typeof numProperties;
406
408
  objectToFormData: typeof objectToFormData;
package/dist/fn.js CHANGED
@@ -170,6 +170,7 @@ import money from './fn/misc/money.js';
170
170
  import move from './fn/object/move.js';
171
171
  import multiorder from './fn/object/multiorder.js';
172
172
  import mutateArray from './fn/object/mutateArray.js';
173
+ import mutateObject from './fn/object/mutateObject.js';
173
174
  import nl2br from './fn/string/nl2br.js';
174
175
  import numProperties from './fn/object/numProperties.js';
175
176
  import objectToFormData from './fn/form/objectToFormData.js';
@@ -401,6 +402,7 @@ export default {
401
402
  move: move,
402
403
  multiorder: multiorder,
403
404
  mutateArray: mutateArray,
405
+ mutateObject: mutateObject,
404
406
  nl2br: nl2br,
405
407
  numProperties: numProperties,
406
408
  objectToFormData: objectToFormData,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bbn/bbn",
3
- "version": "1.0.224",
3
+ "version": "1.0.225",
4
4
  "description": "Javascript toolkit",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",