diff --git a/Libraries/EventEmitter/EventValidator.js b/Libraries/EventEmitter/EventValidator.js index 26fda76dfa..5fc234b226 100644 --- a/Libraries/EventEmitter/EventValidator.js +++ b/Libraries/EventEmitter/EventValidator.js @@ -11,8 +11,6 @@ */ 'use strict'; -const copyProperties = require('copyProperties'); - /** * EventValidator is designed to validate event types to make it easier to catch * common mistakes. It accepts a map of all of the different types of events @@ -37,7 +35,7 @@ const EventValidator = { const eventTypes = Object.keys(types); const emitterWithValidation = Object.create(emitter); - copyProperties(emitterWithValidation, { + Object.assign(emitterWithValidation, { emit: function emit(type, a, b, c, d, e, _) { assertAllowsEventType(type, eventTypes); return emitter.emit.call(this, type, a, b, c, d, e, _); diff --git a/Libraries/EventEmitter/mixInEventEmitter.js b/Libraries/EventEmitter/mixInEventEmitter.js index 2e2f47e025..27b6726ed6 100644 --- a/Libraries/EventEmitter/mixInEventEmitter.js +++ b/Libraries/EventEmitter/mixInEventEmitter.js @@ -16,7 +16,6 @@ const EventEmitterWithHolding = require('EventEmitterWithHolding'); const EventHolder = require('EventHolder'); const EventValidator = require('EventValidator'); -const copyProperties = require('copyProperties'); const invariant = require('fbjs/lib/invariant'); const keyOf = require('fbjs/lib/keyOf'); @@ -63,13 +62,13 @@ function mixInEventEmitter(cls: Function | Object, types: Object) { // Keep track of the provided types, union the types if they already exist, // which allows for prototype subclasses to provide more types. if (target.hasOwnProperty(TYPES_KEY)) { - copyProperties(target.__types, types); + Object.assign(target.__types, types); } else if (target.__types) { - target.__types = copyProperties({}, target.__types, types); + target.__types = Object.assign({}, target.__types, types); } else { target.__types = types; } - copyProperties(target, EventEmitterMixin); + Object.assign(target, EventEmitterMixin); } const EventEmitterMixin = { diff --git a/Libraries/vendor/core/copyProperties.js b/Libraries/vendor/core/copyProperties.js deleted file mode 100644 index d98ed90558..0000000000 --- a/Libraries/vendor/core/copyProperties.js +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * @providesModule copyProperties - */ -'use strict'; - -/** - * Copy properties from one or more objects (up to 5) into the first object. - * This is a shallow copy. It mutates the first object and also returns it. - * - * NOTE: `arguments` has a very significant performance penalty, which is why - * we don't support unlimited arguments. - */ -function copyProperties(obj, a, b, c, d, e, f) { - obj = obj || {}; - - if (__DEV__) { - if (f) { - throw new Error('Too many arguments passed to copyProperties'); - } - } - - var args = [a, b, c, d, e]; - var ii = 0, v; - while (args[ii]) { - v = args[ii++]; - for (var k in v) { - obj[k] = v[k]; - } - - // IE ignores toString in object iteration.. See: - // webreflection.blogspot.com/2007/07/quick-fix-internet-explorer-and.html - if (v.hasOwnProperty && v.hasOwnProperty('toString') && - (typeof v.toString !== 'undefined') && (obj.toString !== v.toString)) { - obj.toString = v.toString; - } - } - - return obj; -} - -module.exports = copyProperties;