File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -36,12 +36,23 @@ const invert = (obj) => {
3636 // Returns a copy of the object where the keys have become the values and the values the keys.
3737 // Assume that all of the object's values will be unique and string serializable.
3838 // http://underscorejs.org/#invert
39+ const clone = { } ;
40+ const objKeys = Object . keys ( obj ) ;
41+ const objValues = Object . values ( obj ) ;
42+ objValues . forEach ( ( key , i ) => clone [ key ] = objKeys [ i ] ) ;
43+ return clone ;
3944} ;
4045
4146const defaults = ( obj , defaultProps ) => {
4247 // Fill in undefined properties that match properties on the `defaultProps` parameter object.
4348 // Return `obj`.
4449 // http://underscorejs.org/#defaults
50+ Object . keys ( defaultProps ) . forEach ( ( key ) => {
51+ if ( ! Object . hasOwnProperty . call ( obj , key ) ) {
52+ obj [ key ] = defaultProps [ key ] ;
53+ }
54+ } ) ;
55+ return obj ;
4556} ;
4657
4758/* eslint-enable no-unused-vars */
You can’t perform that action at this time.
0 commit comments