main
Last change
on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
699 bytes
|
Rev | Line | |
---|
[d24f17c] | 1 | import _isInteger from "./_isInteger.js";
|
---|
| 2 | import _isArray from "./_isArray.js";
|
---|
| 3 | import remove from "../remove.js";
|
---|
| 4 | /**
|
---|
| 5 | * Returns a new object that does not contain a `prop` property.
|
---|
| 6 | *
|
---|
| 7 | * @private
|
---|
| 8 | * @param {String|Number} prop The name of the property to dissociate
|
---|
| 9 | * @param {Object|Array} obj The object to clone
|
---|
| 10 | * @return {Object} A new object equivalent to the original but without the specified property
|
---|
| 11 | */
|
---|
| 12 |
|
---|
| 13 | export default function _dissoc(prop, obj) {
|
---|
| 14 | if (obj == null) {
|
---|
| 15 | return obj;
|
---|
| 16 | }
|
---|
| 17 |
|
---|
| 18 | if (_isInteger(prop) && _isArray(obj)) {
|
---|
| 19 | return remove(prop, 1, obj);
|
---|
| 20 | }
|
---|
| 21 |
|
---|
| 22 | var result = {};
|
---|
| 23 |
|
---|
| 24 | for (var p in obj) {
|
---|
| 25 | result[p] = obj[p];
|
---|
| 26 | }
|
---|
| 27 |
|
---|
| 28 | delete result[prop];
|
---|
| 29 | return result;
|
---|
| 30 | } |
---|
Note:
See
TracBrowser
for help on using the repository browser.