@felte/common
Advanced tools
Comparing version 1.0.0-next.2 to 1.0.0-next.3
import { _cloneDeep } from './cloneDeep.js'; | ||
import { _get } from './get.js'; | ||
function _unset(obj, path) { | ||
if (Object(obj) !== obj) | ||
if (!obj || Object(obj) !== obj) | ||
return; | ||
@@ -13,6 +14,3 @@ // When obj is not an object | ||
: path; | ||
const foundProp = newPath.slice(0, -1).reduce((a, c) => Object(a[c]) === a[c] // Does the key exist and is its value an object? | ||
? // Yes: then follow that path | ||
a[c] | ||
: undefined, obj); | ||
const foundProp = _get(obj, newPath.slice(0, -1).join('.')); | ||
if (Array.isArray(foundProp)) { | ||
@@ -24,3 +22,3 @@ foundProp.splice(Number(newPath[newPath.length - 1]), 1); | ||
} | ||
return obj; // Return the top-level object to allow chaining | ||
return obj; | ||
} | ||
@@ -27,0 +25,0 @@ |
@@ -159,3 +159,3 @@ 'use strict'; | ||
function _unset(obj, path) { | ||
if (Object(obj) !== obj) | ||
if (!obj || Object(obj) !== obj) | ||
return; | ||
@@ -169,6 +169,3 @@ // When obj is not an object | ||
: path; | ||
const foundProp = newPath.slice(0, -1).reduce((a, c) => Object(a[c]) === a[c] // Does the key exist and is its value an object? | ||
? // Yes: then follow that path | ||
a[c] | ||
: undefined, obj); | ||
const foundProp = _get(obj, newPath.slice(0, -1).join('.')); | ||
if (Array.isArray(foundProp)) { | ||
@@ -180,3 +177,3 @@ foundProp.splice(Number(newPath[newPath.length - 1]), 1); | ||
} | ||
return obj; // Return the top-level object to allow chaining | ||
return obj; | ||
} | ||
@@ -183,0 +180,0 @@ |
{ | ||
"name": "@felte/common", | ||
"version": "1.0.0-next.2", | ||
"version": "1.0.0-next.3", | ||
"description": "Common utilities for Felte packages", | ||
@@ -5,0 +5,0 @@ "author": "Pablo Berganza <pablo@berganza.dev>", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
456252
6405