export default function unset(path: string, obj: any) {
  let schema = obj; // a moving reference to internal objects within obj
  let pList = path.split('.');
  let len = pList.length;
  for (let i = 0; i < len - 1; i++) {
    let elem = pList[i];
    if (!schema[elem]) return;
    schema = schema[elem];
  }

  if (Array.isArray(schema)) {
    schema.splice(parseInt(pList[len - 1]), 1);
  } else {
    delete schema[pList[len - 1]];
  }
}
