mirror of
https://github.com/shelljs/shelljs.git
synced 2026-01-18 16:03:37 +00:00
refactor: switch common.extend() to Object.assign ponyfill (#490)
This commit is contained in:
parent
11141a35ba
commit
add14adbf4
@ -236,10 +236,10 @@ function randomFileName() {
|
||||
}
|
||||
exports.randomFileName = randomFileName;
|
||||
|
||||
// extend(target_obj, source_obj1 [, source_obj2 ...])
|
||||
// Shallow extend, e.g.:
|
||||
// extend({A:1}, {b:2}, {c:3}) returns {A:1, b:2, c:3}
|
||||
function extend(target) {
|
||||
// objectAssign(target_obj, source_obj1 [, source_obj2 ...])
|
||||
// Ponyfill for Object.assign
|
||||
// objectAssign({A:1}, {b:2}, {c:3}) returns {A:1, b:2, c:3}
|
||||
function objectAssign(target) {
|
||||
var sources = [].slice.call(arguments, 1);
|
||||
sources.forEach(function(source) {
|
||||
for (var key in source)
|
||||
@ -248,7 +248,7 @@ function extend(target) {
|
||||
|
||||
return target;
|
||||
}
|
||||
exports.extend = extend;
|
||||
exports.extend = Object.assign || objectAssign;
|
||||
|
||||
// Common wrapper for all Unix-like commands that performs glob expansion,
|
||||
// command-logging, and other nice things
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user