-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 🔨 Give more control to apply operation * ✨ add core.unset
- Loading branch information
Showing
9 changed files
with
45 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { apply } from './apply' | ||
import { unsafeToPath } from './toPath' | ||
|
||
const unsetOperation = (obj, prop) => { delete obj[prop] } | ||
|
||
/** | ||
* Removes the property at <code>path</code> of <code>object</code>. | ||
* This is the <code>lodash/fp</code> <code>unset</code>, with no arguments rearranging and no currying. | ||
* @function | ||
* @memberof core | ||
* @param {Object} obj The object to modify. | ||
* @param {Array|string} path The path of the property to unset. | ||
* @return {Object} Returns the updated object. | ||
* @example unset({ nested: { prop: 'value' } }, 'nested.prop') // => { nested: {} } | ||
* @since 0.4.0 | ||
*/ | ||
const unset = (obj, path) => apply(obj, unsafeToPath(path), unsetOperation) | ||
|
||
export { unset } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,10 @@ | ||
import _unset from 'lodash/fp/unset' | ||
import { lodashFpConvert } from 'util/lodashFpConvert' | ||
import { unset } from 'core/unset' | ||
|
||
/** | ||
* Removes the property at <code>path</code> of <code>object</code>. | ||
* This is the <code>lodash/fp</code> <code>unset</code>, with no arguments rearranging and no currying. | ||
* @function | ||
* This is an alias for {@link core.unset}. | ||
* @function unset | ||
* @memberof object | ||
* @param {Object} object The object to modify. | ||
* @param {Array|string} path The path of the property to unset. | ||
* @return {Object} Returns the updated object. | ||
* @example unset({ nested: { prop: 'value' } }, 'nested.prop') // => { nested: {} } | ||
* @see {@link https://lodash.com/docs#unset|lodash.unset} for more information. | ||
* @since 0.1.5 | ||
* @deprecated Use {@link core.unset} | ||
*/ | ||
const unset = lodashFpConvert(_unset) | ||
export { unset } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters