Update get util fn
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
export const get = (object, field, defaultValue) => {
|
||||
return object && object.hasOwnProperty(field) ? options[field] : defaultValue
|
||||
export const get = (object, fieldName, 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