20 lines
270 B
JavaScript
20 lines
270 B
JavaScript
|
/**
|
||
|
* Expose `required`
|
||
|
*/
|
||
|
|
||
|
module.exports = required;
|
||
|
|
||
|
/**
|
||
|
* Assert `prop` as requirement of `obj`
|
||
|
*
|
||
|
* @param {Object} obj
|
||
|
* @param {prop} prop
|
||
|
* @public
|
||
|
*/
|
||
|
|
||
|
function required (obj, prop) {
|
||
|
if (!obj[prop]) {
|
||
|
throw new Error(prop + ' is required.');
|
||
|
}
|
||
|
}
|