-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add non-optional default parameters in constructor
- Loading branch information
Showing
2 changed files
with
49 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** Class for utility functions */ | ||
class Util { | ||
/** | ||
* Extend an array just like JQuery's extend. | ||
* @param {object} arguments Objects to be merged. | ||
* @return {object} Merged objects. | ||
*/ | ||
static extend() { | ||
for (let i = 1; i < arguments.length; i++) { | ||
for (let key in arguments[i]) { | ||
if (arguments[i].hasOwnProperty(key)) { | ||
if (typeof arguments[0][key] === 'object' && typeof arguments[i][key] === 'object') { | ||
this.extend(arguments[0][key], arguments[i][key]); | ||
} | ||
else { | ||
arguments[0][key] = arguments[i][key]; | ||
} | ||
} | ||
} | ||
} | ||
return arguments[0]; | ||
} | ||
} | ||
|
||
export default Util; |