@naturalcycles/js-lib 14.184.1 → 14.185.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.
@@ -189,3 +189,21 @@ export declare function _has<T extends AnyObject>(obj: T, path: string): boolean
189
189
  * Based on: https://github.com/substack/deep-freeze/blob/master/index.js
190
190
  */
191
191
  export declare function _deepFreeze(o: any): void;
192
+ /**
193
+ * let target: T = { a: 'a', n: 1}
194
+ * let source: T = { a: 'a2', b: 'b' }
195
+ *
196
+ * _objectAssignExact(target, source)
197
+ *
198
+ * Does the same as `target = source`,
199
+ * except that it mutates the target to make it exactly the same as source,
200
+ * while keeping the reference to the same object.
201
+ *
202
+ * This way it can "propagate deletions".
203
+ * E.g source doesn't have the `n` property, so it'll be deleted from target.
204
+ * With normal Object.assign - it'll override the keys that `source` has, but not the
205
+ * "missing/deleted keys".
206
+ *
207
+ * To make mutation extra clear - function returns void (unlike Object.assign).
208
+ */
209
+ export declare function _objectAssignExact<T extends AnyObject>(target: T, source: T): void;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports._deepFreeze = exports._has = exports._set = exports._get = exports._invertMap = exports._invert = exports._unset = exports._deepTrim = exports._merge = exports._filterEmptyValues = exports._undefinedIfEmpty = exports._deepCopy = exports._objectNullValuesToUndefined = exports._findKeyByValue = exports._mapObject = exports._mapKeys = exports._mapValues = exports._filterObject = exports._filterEmptyArrays = exports._filterUndefinedValues = exports._filterNullishValues = exports._filterFalsyValues = exports._mask = exports._omit = exports._pick = void 0;
3
+ exports._objectAssignExact = exports._deepFreeze = exports._has = exports._set = exports._get = exports._invertMap = exports._invert = exports._unset = exports._deepTrim = exports._merge = exports._filterEmptyValues = exports._undefinedIfEmpty = exports._deepCopy = exports._objectNullValuesToUndefined = exports._findKeyByValue = exports._mapObject = exports._mapKeys = exports._mapValues = exports._filterObject = exports._filterEmptyArrays = exports._filterUndefinedValues = exports._filterNullishValues = exports._filterFalsyValues = exports._mask = exports._omit = exports._pick = void 0;
4
4
  const is_util_1 = require("../is.util");
5
5
  const types_1 = require("../types");
6
6
  /**
@@ -384,3 +384,27 @@ function _deepFreeze(o) {
384
384
  });
385
385
  }
386
386
  exports._deepFreeze = _deepFreeze;
387
+ /**
388
+ * let target: T = { a: 'a', n: 1}
389
+ * let source: T = { a: 'a2', b: 'b' }
390
+ *
391
+ * _objectAssignExact(target, source)
392
+ *
393
+ * Does the same as `target = source`,
394
+ * except that it mutates the target to make it exactly the same as source,
395
+ * while keeping the reference to the same object.
396
+ *
397
+ * This way it can "propagate deletions".
398
+ * E.g source doesn't have the `n` property, so it'll be deleted from target.
399
+ * With normal Object.assign - it'll override the keys that `source` has, but not the
400
+ * "missing/deleted keys".
401
+ *
402
+ * To make mutation extra clear - function returns void (unlike Object.assign).
403
+ */
404
+ function _objectAssignExact(target, source) {
405
+ Object.assign(target, source);
406
+ Object.keys(target)
407
+ .filter(k => !(k in source))
408
+ .forEach(k => delete target[k]);
409
+ }
410
+ exports._objectAssignExact = _objectAssignExact;
@@ -358,3 +358,26 @@ export function _deepFreeze(o) {
358
358
  }
359
359
  });
360
360
  }
361
+ /**
362
+ * let target: T = { a: 'a', n: 1}
363
+ * let source: T = { a: 'a2', b: 'b' }
364
+ *
365
+ * _objectAssignExact(target, source)
366
+ *
367
+ * Does the same as `target = source`,
368
+ * except that it mutates the target to make it exactly the same as source,
369
+ * while keeping the reference to the same object.
370
+ *
371
+ * This way it can "propagate deletions".
372
+ * E.g source doesn't have the `n` property, so it'll be deleted from target.
373
+ * With normal Object.assign - it'll override the keys that `source` has, but not the
374
+ * "missing/deleted keys".
375
+ *
376
+ * To make mutation extra clear - function returns void (unlike Object.assign).
377
+ */
378
+ export function _objectAssignExact(target, source) {
379
+ Object.assign(target, source);
380
+ Object.keys(target)
381
+ .filter(k => !(k in source))
382
+ .forEach(k => delete target[k]);
383
+ }
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@naturalcycles/js-lib",
3
- "version": "14.184.1",
3
+ "version": "14.185.0",
4
4
  "scripts": {
5
5
  "prepare": "husky install",
6
6
  "build-prod": "build-prod-esm-cjs",
7
- "docs-serve": "NODE_OPTIONS=--openssl-legacy-provider vuepress dev docs",
8
- "docs-build": "NODE_OPTIONS=--openssl-legacy-provider vuepress build docs"
7
+ "docs-dev": "vitepress dev docs --open",
8
+ "docs-build": "vitepress build docs",
9
+ "docs-preview": "vitepress preview docs"
9
10
  },
10
11
  "dependencies": {
11
12
  "tslib": "^2.0.0",
@@ -21,8 +22,8 @@
21
22
  "crypto-js": "^4.1.1",
22
23
  "jest": "^29.0.0",
23
24
  "prettier": "^3.0.0",
24
- "vuepress": "^1.7.1",
25
- "vuepress-plugin-typescript": "^0.3.1"
25
+ "vitepress": "^1.0.0-rc.12",
26
+ "vue": "^3.2.45"
26
27
  },
27
28
  "resolutions": {
28
29
  "expect-type": "0.15.0"
@@ -419,3 +419,27 @@ export function _deepFreeze(o: any): void {
419
419
  }
420
420
  })
421
421
  }
422
+
423
+ /**
424
+ * let target: T = { a: 'a', n: 1}
425
+ * let source: T = { a: 'a2', b: 'b' }
426
+ *
427
+ * _objectAssignExact(target, source)
428
+ *
429
+ * Does the same as `target = source`,
430
+ * except that it mutates the target to make it exactly the same as source,
431
+ * while keeping the reference to the same object.
432
+ *
433
+ * This way it can "propagate deletions".
434
+ * E.g source doesn't have the `n` property, so it'll be deleted from target.
435
+ * With normal Object.assign - it'll override the keys that `source` has, but not the
436
+ * "missing/deleted keys".
437
+ *
438
+ * To make mutation extra clear - function returns void (unlike Object.assign).
439
+ */
440
+ export function _objectAssignExact<T extends AnyObject>(target: T, source: T): void {
441
+ Object.assign(target, source)
442
+ Object.keys(target)
443
+ .filter(k => !(k in source))
444
+ .forEach(k => delete target[k])
445
+ }