Skip to content

Instantly share code, notes, and snippets.

@mdmoin7
Created March 24, 2019 15:03
Show Gist options
  • Save mdmoin7/1bd98361c186a339fc687ea1e7ff55d6 to your computer and use it in GitHub Desktop.
Save mdmoin7/1bd98361c186a339fc687ea1e7ff55d6 to your computer and use it in GitHub Desktop.
const createObject=(custom_schema,missingKeys,data)=>{
const newObj=Object.create({});
// add available keys
for(let key of Object.keys(custom_schema)){
const k=custom_schema[key];
newObj[k]=data[key];
}
// add missing keys
for(let k of missingKeys){
newObj[k]='';
}
return _.omitBy(newObj, _.isUndefined);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment