frontend/.pnpm-store/v3/files/6e/7be539690095544456ba5b31cd26fadce96aea792e0a0e81ef816cf018749d8251f584ecd6a3bb26f533d60f5c0c52ddcb7cbdb026596269d9a3d62ecb754b

21 lines
473 B
Plaintext

'use strict';
const checkType = (name, value, types) => {
const valid = types.some(type => {
const typeofType = typeof type;
if (typeofType === 'string') {
return typeof value === type;
}
return value instanceof type;
});
if (!valid) {
const names = types.map(type => typeof type === 'string' ? type : type.name);
throw new TypeError(`Expected '${name}' to be a type of ${names.join(' or ')}, got ${typeof value}`);
}
};
module.exports = checkType;