Skip to content

Instantly share code, notes, and snippets.

@archangel-irk
Created March 20, 2018 02:08
Show Gist options
  • Save archangel-irk/2cf45172df90f5dfc4cdf6d2bcc2740b to your computer and use it in GitHub Desktop.
Save archangel-irk/2cf45172df90f5dfc4cdf6d2bcc2740b to your computer and use it in GitHub Desktop.
Required Parameters
function requiredParam (param) {
const requiredParamError = new Error(
`Required parameter, "${param}" is missing.`
);
// preserve original stack trace
if (typeof Error.captureStackTrace === ‘function’) {
Error.captureStackTrace(
requiredParamError,
requiredParam,
);
}
throw requiredParamError;
}
function findUsersByRole ({
role = requiredParam('role'),
withContactInfo,
includeInactive,
} = {}) {...}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment