Update get util fn
This commit is contained in:
@@ -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
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user