Update get util fn

This commit is contained in:
Vadim
2021-06-30 23:36:19 +03:00
parent 3cf4a3e7fe
commit 1bac1f3f82

View File

@@ -1,3 +1,9 @@
export const get = (object, field, defaultValue) => { export const get = (object, fieldName, defaultValue) => {
return object && object.hasOwnProperty(field) ? options[field] : defaultValue if (object && object.hasOwnProperty(fieldName)) {
return object[fieldName]
}
if (defaultValue === undefined) {
throw new Error(`Required arg "${fieldName}" was not provided`)
}
return defaultValue
} }