doff
Version:
A powerful tool to free your objects and arrays from unwanted content
27 lines (19 loc) • 498 B
JavaScript
;
// Load modules
const arrayEach = require('./arrayEach');
const toString = Object.prototype.toString;
// Define exports
module.exports = function(value, ...types) {
let is = false;
if (value == null) {
return is;
}
arrayEach(types, (type) => {
if ((typeof type === 'string' && toString.call(value) === type) ||
((typeof type === 'function') && value instanceof type)) {
is = true;
return false; // Break the loop
}
});
return is;
};