@jsopen/objects 1.6.1 → 1.6.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/CHANGELOG.md CHANGED
@@ -1,7 +1,7 @@
1
1
  ## Changelog
2
2
 
3
- ### [v1.6.1](https://github.com/panates/jsopen-objects/compare/v1.6.0...v1.6.1) -
3
+ ### [v1.6.3](https://github.com/panates/jsopen-objects/compare/v1.6.2...v1.6.3) -
4
4
 
5
- #### 🚀 New Features
5
+ #### 🪲 Fixes
6
6
 
7
- - feat: Added deepClone shortcut method @Eray Hanoğlu
7
+ - fix: merge fails on null fields @Eray Hanoğlu
package/cjs/clone.js CHANGED
@@ -9,6 +9,6 @@ function clone(obj, options) {
9
9
  deep: options?.deep ?? true,
10
10
  });
11
11
  }
12
- function deepClone(obj) {
13
- return clone(obj, { deep: 'full' });
12
+ function deepClone(obj, options) {
13
+ return clone(obj, { ...options, deep: 'full' });
14
14
  }
package/cjs/is-object.js CHANGED
@@ -7,7 +7,8 @@ function isObject(v) {
7
7
  return v && typeof v === 'object' && !Array.isArray(v);
8
8
  }
9
9
  function isPlainObject(obj) {
10
- if (typeof obj === 'object' &&
10
+ if (obj &&
11
+ typeof obj === 'object' &&
11
12
  Object.prototype.toString.call(obj) === '[object Object]') {
12
13
  const proto = Object.getPrototypeOf(obj);
13
14
  /* istanbul ignore next */
package/cjs/merge.js CHANGED
@@ -67,7 +67,7 @@ let trgVal;
67
67
  };
68
68
  if (options?.deep) {
69
69
  if (options.deep === 'full') {
70
- context.deepTest = v => typeof v === 'object' && !(0, type_guards_js_1.isBuiltIn)(v);
70
+ context.deepTest = v => v && typeof v === 'object' && !(0, type_guards_js_1.isBuiltIn)(v);
71
71
  }
72
72
  scriptL0.push(`let subPath;`, `let _isArray;`);
73
73
  if (typeof options?.deep === 'function') {
@@ -5,7 +5,8 @@ exports.isConstructor = isConstructor;
5
5
  exports.isIterable = isIterable;
6
6
  exports.isAsyncIterable = isAsyncIterable;
7
7
  function isBuiltIn(v) {
8
- return ((typeof v === 'object' &&
8
+ return ((v &&
9
+ typeof v === 'object' &&
9
10
  (v instanceof Date ||
10
11
  v instanceof RegExp ||
11
12
  v instanceof Map ||
package/esm/clone.js CHANGED
@@ -5,6 +5,6 @@ export function clone(obj, options) {
5
5
  deep: options?.deep ?? true,
6
6
  });
7
7
  }
8
- export function deepClone(obj) {
9
- return clone(obj, { deep: 'full' });
8
+ export function deepClone(obj, options) {
9
+ return clone(obj, { ...options, deep: 'full' });
10
10
  }
package/esm/is-object.js CHANGED
@@ -3,7 +3,8 @@ export function isObject(v) {
3
3
  return v && typeof v === 'object' && !Array.isArray(v);
4
4
  }
5
5
  export function isPlainObject(obj) {
6
- if (typeof obj === 'object' &&
6
+ if (obj &&
7
+ typeof obj === 'object' &&
7
8
  Object.prototype.toString.call(obj) === '[object Object]') {
8
9
  const proto = Object.getPrototypeOf(obj);
9
10
  /* istanbul ignore next */
package/esm/merge.js CHANGED
@@ -63,7 +63,7 @@ let trgVal;
63
63
  };
64
64
  if (options?.deep) {
65
65
  if (options.deep === 'full') {
66
- context.deepTest = v => typeof v === 'object' && !isBuiltIn(v);
66
+ context.deepTest = v => v && typeof v === 'object' && !isBuiltIn(v);
67
67
  }
68
68
  scriptL0.push(`let subPath;`, `let _isArray;`);
69
69
  if (typeof options?.deep === 'function') {
@@ -1,5 +1,6 @@
1
1
  export function isBuiltIn(v) {
2
- return ((typeof v === 'object' &&
2
+ return ((v &&
3
+ typeof v === 'object' &&
3
4
  (v instanceof Date ||
4
5
  v instanceof RegExp ||
5
6
  v instanceof Map ||
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@jsopen/objects",
3
3
  "description": "Helper utilities for working with JavaScript objects and arrays",
4
- "version": "1.6.1",
4
+ "version": "1.6.3",
5
5
  "author": "Panates",
6
6
  "license": "MIT",
7
7
  "dependencies": {
package/types/clone.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { StrictOmit } from 'ts-gems';
1
2
  import { merge } from './merge.js';
2
3
  export declare function clone<T extends object>(obj: T, options?: merge.Options): T;
3
- export declare function deepClone<T extends object>(obj: T): T;
4
+ export declare function deepClone<T extends object>(obj: T, options?: StrictOmit<merge.Options, 'deep'>): T;