UNPKG

svcorelib

Version:

Core library used in the projects of Sv443 and the Sv443 Network. Contains tons of miscellaneous QoL features.

15 lines (10 loc) 508 B
function allOfType(array, type) { let possibleTypes = [ "bigint", "boolean", "function", "number", "object", "string", "symbol", "undefined" ]; if(!Array.isArray(array)) throw new TypeError(`Parameter "array" needs to be an array`); if(!possibleTypes.includes(type)) throw new TypeError(`Parameter "type" needs to be a string that contains a primitive JavaScript variable type`); return array.every(val => typeof val === type); } module.exports = allOfType;