function set()

in utils/create-schema.js [94:120]


function set (object, objPath, value, customizer) {
  objPath = objPath
    .split('.')
    .join('.properties.')
    .split('.')
  let index = -1
  const length = objPath.length
  const lastIndex = length - 1
  let nested = object

  while (nested != null && ++index < length) {
    const key = objPath[index]
    let newValue = value

    if (index !== lastIndex) {
      const objValue = nested[key]
      newValue = objValue || {}
    }
    if (key === 'properties') {
      nested.type = 'object'
      nested.additionalProperties = true
    }
    nested[key] = newValue
    nested = nested[key]
  }
  return object
}