source: node_modules/ramda/src/internal/_dissoc.js@ d24f17c

main
Last change on this file since d24f17c was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 765 bytes
Line 
1var _isInteger =
2/*#__PURE__*/
3require("./_isInteger.js");
4
5var _isArray =
6/*#__PURE__*/
7require("./_isArray.js");
8
9var remove =
10/*#__PURE__*/
11require("../remove.js");
12/**
13 * Returns a new object that does not contain a `prop` property.
14 *
15 * @private
16 * @param {String|Number} prop The name of the property to dissociate
17 * @param {Object|Array} obj The object to clone
18 * @return {Object} A new object equivalent to the original but without the specified property
19 */
20
21
22function _dissoc(prop, obj) {
23 if (obj == null) {
24 return obj;
25 }
26
27 if (_isInteger(prop) && _isArray(obj)) {
28 return remove(prop, 1, obj);
29 }
30
31 var result = {};
32
33 for (var p in obj) {
34 result[p] = obj[p];
35 }
36
37 delete result[prop];
38 return result;
39}
40
41module.exports = _dissoc;
Note: See TracBrowser for help on using the repository browser.