es2015/utils.js
function setField(object, fieldPath, value) {
  let currentObject = object
  let fieldNames = fieldPath.split(".")
  
  for (let fieldName of fieldNames.slice(0, -1)) {
    if (!currentObject.hasOwnProperty(fieldName)) {
      currentObject[fieldName] = {}
    }
    
    currentObject = currentObject[fieldName]
  }
  
  currentObject[fieldNames.pop()] = value
}
function setField(object, fieldPath, value) {
  let currentObject = object
  let fieldNames = fieldPath.split(".")
  
  for (let fieldName of fieldNames.slice(0, -1)) {
    if (!currentObject.hasOwnProperty(fieldName)) {
      currentObject[fieldName] = {}
    }
    
    currentObject = currentObject[fieldName]
  }
  
  currentObject[fieldNames.pop()] = value
}
function setField ( object , fieldPath , value ) { let currentObject = object let fieldNames = fieldPath . split ( "." ) for ( let fieldName of fieldNames . slice ( 0 , - 1 ) ) { if ( ! currentObject . hasOwnProperty ( fieldName ) ) { currentObject [ fieldName ] = { } } currentObject = currentObject [ fieldName ] } currentObject [ fieldNames . pop ( ) ] = value }
Sets the field at the specified field path to the provided value in the
provided object.

The function creates the field path out of empty plain objects if it does
not already exist.

@param {Object} object The object in which the specified field path should
be set to the provided value.
@param {string} fieldPath The field path at which the value should be set.
The field path must be a sequence of valid ECMAScript identifiers
separated by dots.
@param {*} value The value to set.
Sets the field at the specified field path to the provided value in the provided object .