Sha256: ad8e85a5e18f247038d4bac8d5dcc60c0d5151d0b3c9f06e313850ebec4f2b70

Contents?: true

Size: 1.18 KB

Versions: 3

Compression:

Stored size: 1.18 KB

Contents

/**
 @module @ember/polyfills
*/
/**
  Copy properties from a source object to a target object.

  ```javascript
  import { assign } from '@ember/polyfills';

  var a = { first: 'Yehuda' };
  var b = { last: 'Katz' };
  var c = { company: 'Tilde Inc.' };
  assign(a, b, c); // a === { first: 'Yehuda', last: 'Katz', company: 'Tilde Inc.' }, b === { last: 'Katz' }, c === { company: 'Tilde Inc.' }
  ```

  @method assign
  @for @ember/polyfills
  @param {Object} target The object to assign into
  @param {Object} ...args The objects to copy properties from
  @return {Object}
  @public
  @static
*/
export function assign(target) {
    for (let i = 1; i < arguments.length; i++) {
        let arg = arguments[i];
        if (!arg) {
            continue;
        }
        let updates = Object.keys(arg);
        for (let i = 0; i < updates.length; i++) {
            let prop = updates[i];
            target[prop] = arg[prop];
        }
    }
    return target;
}
// Note: We use the bracket notation so
//       that the babel plugin does not
//       transform it.
// https://www.npmjs.com/package/babel-plugin-transform-object-assign
const { assign: _assign } = Object;
export default (_assign || assign);

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
discourse-ember-source-3.6.0.0 dist/es/@ember/polyfills/lib/assign.js
discourse-ember-source-3.5.1.1 dist/es/@ember/polyfills/lib/assign.js
discourse-ember-source-3.5.1.0 dist/dist/es/@ember/polyfills/lib/assign.js