Sha256: 77129469f883c20425051b9c461addc866a2581a48efb74b7dcc2d6c71a73c4e

Contents?: true

Size: 1.05 KB

Versions: 3

Compression:

Stored size: 1.05 KB

Contents

import { changeProperties } from './property_events';
import { set } from './property_set';
/**
 @module @ember/object
*/
/**
  Set a list of properties on an object. These properties are set inside
  a single `beginPropertyChanges` and `endPropertyChanges` batch, so
  observers will be buffered.

  ```javascript
  import EmberObject from '@ember/object';
  let anObject = EmberObject.create();

  anObject.setProperties({
    firstName: 'Stanley',
    lastName: 'Stuart',
    age: 21
  });
  ```

  @method setProperties
  @static
  @for @ember/object
  @param obj
  @param {Object} properties
  @return properties
  @public
*/
export default function setProperties(obj, properties) {
    if (properties === null || typeof properties !== 'object') {
        return properties;
    }
    changeProperties(() => {
        let props = Object.keys(properties);
        let propertyName;
        for (let i = 0; i < props.length; i++) {
            propertyName = props[i];
            set(obj, propertyName, properties[propertyName]);
        }
    });
    return properties;
}

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
discourse-ember-source-3.6.0.0 dist/es/@ember/-internals/metal/lib/set_properties.js
discourse-ember-source-3.5.1.1 dist/es/ember-metal/lib/set_properties.js
discourse-ember-source-3.5.1.0 dist/dist/es/ember-metal/lib/set_properties.js