Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const checkParamOrThrow = (value, name, type, message) => {
if (!message) message = `Parameter "${name}" of type ${type} must be provided`;
const allowedTypes = parseType(type);
const allowsBuffer = allowedTypes.filter(item => item.type === 'Buffer').length;
const allowsPromise = allowedTypes.filter(item => item.type === 'Promise').length;
if (allowsBuffer && Buffer.isBuffer(value)) return;
if (allowsPromise && typeof value.then === 'function') return;
// This will ignore Buffer type.
if (!parsedTypeCheck(allowedTypes, value)) throw new Error(message);
};