зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1321509 - remove references to Array.slice in addon-sdk util/object;r=zer0
MozReview-Commit-ID: 8HCwdqy4kwl --HG-- extra : rebase_source : e6712c8ec0e18427151e1db53769efea35fd5106
This commit is contained in:
Родитель
2142ad7820
Коммит
374fd022cf
|
@ -9,6 +9,10 @@ module.metadata = {
|
|||
|
||||
const { flatten } = require('./array');
|
||||
|
||||
// Create a shortcut for Array.prototype.slice.call().
|
||||
const unbind = Function.call.bind(Function.bind, Function.call);
|
||||
const slice = unbind(Array.prototype.slice);
|
||||
|
||||
/**
|
||||
* Merges all the properties of all arguments into first argument. If two or
|
||||
* more argument objects have own properties with the same name, the property
|
||||
|
@ -34,7 +38,7 @@ function merge(source) {
|
|||
// `Boolean` converts the first parameter to a boolean value. Any object is
|
||||
// converted to `true` where `null` and `undefined` becames `false`. Therefore
|
||||
// the `filter` method will keep only objects that are defined and not null.
|
||||
Array.slice(arguments, 1).filter(Boolean).forEach(function onEach(properties) {
|
||||
slice(arguments, 1).filter(Boolean).forEach(function onEach(properties) {
|
||||
getOwnPropertyIdentifiers(properties).forEach(function(name) {
|
||||
descriptor[name] = Object.getOwnPropertyDescriptor(properties, name);
|
||||
});
|
||||
|
@ -50,7 +54,7 @@ exports.merge = merge;
|
|||
* `merge(Object.create(source1), source2, source3)`.
|
||||
*/
|
||||
function extend(source) {
|
||||
let rest = Array.slice(arguments, 1);
|
||||
let rest = slice(arguments, 1);
|
||||
rest.unshift(Object.create(source));
|
||||
return merge.apply(null, rest);
|
||||
}
|
||||
|
@ -72,7 +76,7 @@ exports.each = each;
|
|||
* merging XPCOM objects
|
||||
*/
|
||||
function safeMerge(source) {
|
||||
Array.slice(arguments, 1).forEach(function onEach (obj) {
|
||||
slice(arguments, 1).forEach(function onEach (obj) {
|
||||
for (let prop in obj) source[prop] = obj[prop];
|
||||
});
|
||||
return source;
|
||||
|
|
Загрузка…
Ссылка в новой задаче