@naturalcycles/js-lib 14.206.1 → 14.207.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.
@@ -1,5 +1,5 @@
1
1
  import type { PropertyPath } from '../lodash.types';
2
- import { KeyValueTuple, SKIP } from '../types';
2
+ import { KeyValueTuple, Reviver, SKIP } from '../types';
3
3
  import type { AnyObject, ObjectMapper, ObjectPredicate, ValueOf } from '../types';
4
4
  /**
5
5
  * Returns clone of `obj` with only `props` preserved.
@@ -82,7 +82,7 @@ export declare function _objectNullValuesToUndefined<T extends AnyObject>(obj: T
82
82
  /**
83
83
  * Deep copy object (by json parse/stringify, since it has unbeatable performance+simplicity combo).
84
84
  */
85
- export declare function _deepCopy<T>(o: T): T;
85
+ export declare function _deepCopy<T>(o: T, reviver?: Reviver): T;
86
86
  /**
87
87
  * Returns `undefined` if it's empty (according to `_isEmpty()` specification),
88
88
  * otherwise returns the original object.
@@ -158,8 +158,8 @@ exports._objectNullValuesToUndefined = _objectNullValuesToUndefined;
158
158
  /**
159
159
  * Deep copy object (by json parse/stringify, since it has unbeatable performance+simplicity combo).
160
160
  */
161
- function _deepCopy(o) {
162
- return JSON.parse(JSON.stringify(o));
161
+ function _deepCopy(o, reviver) {
162
+ return JSON.parse(JSON.stringify(o), reviver);
163
163
  }
164
164
  exports._deepCopy = _deepCopy;
165
165
  /**
package/dist/types.d.ts CHANGED
@@ -54,11 +54,11 @@ export type Saved<T> = T & {
54
54
  export type SavedId<T> = T & {
55
55
  id: string;
56
56
  };
57
- export type Unsaved<T> = T extends AnyObject ? Omit<T, 'id' | 'created' | 'updated'> & {
57
+ export type Unsaved<T> = Omit<T, 'id' | 'created' | 'updated'> & {
58
58
  id?: string;
59
59
  created?: UnixTimestampNumber;
60
60
  updated?: UnixTimestampNumber;
61
- } : T;
61
+ };
62
62
  export type UnsavedId<T> = Omit<T, 'id'> & {
63
63
  id?: string;
64
64
  };
@@ -143,8 +143,8 @@ export function _objectNullValuesToUndefined(obj, mutate = false) {
143
143
  /**
144
144
  * Deep copy object (by json parse/stringify, since it has unbeatable performance+simplicity combo).
145
145
  */
146
- export function _deepCopy(o) {
147
- return JSON.parse(JSON.stringify(o));
146
+ export function _deepCopy(o, reviver) {
147
+ return JSON.parse(JSON.stringify(o), reviver);
148
148
  }
149
149
  /**
150
150
  * Returns `undefined` if it's empty (according to `_isEmpty()` specification),
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@naturalcycles/js-lib",
3
- "version": "14.206.1",
3
+ "version": "14.207.0",
4
4
  "scripts": {
5
- "prepare": "husky install",
5
+ "prepare": "husky",
6
6
  "build-prod": "build-prod-esm-cjs",
7
7
  "docs-dev": "vitepress dev docs --open",
8
8
  "docs-build": "vitepress build docs",
@@ -1,6 +1,6 @@
1
1
  import { _isEmpty, _isObject } from '../is.util'
2
2
  import type { PropertyPath } from '../lodash.types'
3
- import { _objectEntries, KeyValueTuple, SKIP } from '../types'
3
+ import { _objectEntries, KeyValueTuple, Reviver, SKIP } from '../types'
4
4
  import type { AnyObject, ObjectMapper, ObjectPredicate, ValueOf } from '../types'
5
5
 
6
6
  /**
@@ -186,8 +186,8 @@ export function _objectNullValuesToUndefined<T extends AnyObject>(obj: T, mutate
186
186
  /**
187
187
  * Deep copy object (by json parse/stringify, since it has unbeatable performance+simplicity combo).
188
188
  */
189
- export function _deepCopy<T>(o: T): T {
190
- return JSON.parse(JSON.stringify(o))
189
+ export function _deepCopy<T>(o: T, reviver?: Reviver): T {
190
+ return JSON.parse(JSON.stringify(o), reviver)
191
191
  }
192
192
 
193
193
  /**
package/src/types.ts CHANGED
@@ -71,13 +71,11 @@ export type SavedId<T> = T & {
71
71
  id: string
72
72
  }
73
73
 
74
- export type Unsaved<T> = T extends AnyObject
75
- ? Omit<T, 'id' | 'created' | 'updated'> & {
76
- id?: string
77
- created?: UnixTimestampNumber
78
- updated?: UnixTimestampNumber
79
- }
80
- : T
74
+ export type Unsaved<T> = Omit<T, 'id' | 'created' | 'updated'> & {
75
+ id?: string
76
+ created?: UnixTimestampNumber
77
+ updated?: UnixTimestampNumber
78
+ }
81
79
 
82
80
  export type UnsavedId<T> = Omit<T, 'id'> & {
83
81
  id?: string