This repository was archived by the owner on Feb 20, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +27
-0
lines changed Expand file tree Collapse file tree 3 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -71,6 +71,7 @@ import occurrences from './occurrences'
71
71
import getMiddle from './getMiddle'
72
72
import debounce from './debounce'
73
73
import curry from './curry'
74
+ import removeProperty from './removeProperty'
74
75
75
76
export {
76
77
reverseArrayInPlace ,
@@ -146,4 +147,5 @@ export {
146
147
getMiddle ,
147
148
debounce ,
148
149
curry ,
150
+ removeProperty ,
149
151
}
Original file line number Diff line number Diff line change
1
+ export default removeProperty
2
+
3
+ /**
4
+ * Original Source: https://stackoverflow.com/questions/208105/how-do-i-remove-a-property-from-a-javascript-object
5
+ *
6
+ * This method will remove named property from given object
7
+ *
8
+ * @param {Object } obj - the object to remove property from
9
+ * @param {String } prop - name of property to remove
10
+ */
11
+
12
+ function removeProperty ( obj , prop ) {
13
+ delete obj [ prop ]
14
+ }
Original file line number Diff line number Diff line change
1
+ import test from 'ava'
2
+ import { removeProperty } from '../src'
3
+
4
+ test ( 'Remove a property from object' , t => {
5
+ const obj = { fname : 'foo' , lname : 'bar' }
6
+ const prop = 'lname'
7
+ const expected = { fname : 'foo' }
8
+ const actual = obj
9
+ removeProperty ( obj , prop )
10
+ t . deepEqual ( actual , expected )
11
+ } )
You can’t perform that action at this time.
0 commit comments