
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
typeVal es una función útil para determinar el tipo de un valor en JavaScript y realizar comparaciones de tipo de manera flexible y precisa.
Este es un módulo de JavaScript que exporta una función llamada typeVal. La función toma dos parámetros: value (valor) y type (tipo). Así es como funciona:
El objeto option define las correspondencias entre los tipos de JavaScript y sus representaciones en forma de cadena.
Si no se proporciona el parámetro type, la función devuelve la representación en forma de cadena del tipo del parámetro value. Busca la función adecuada en el objeto option en función del tipo del parámetro value y la invoca, devolviendo el resultado.
const { typeVal, typeValmin } = require('typeVal');
// input: value
// output: name
console.log(typeVal(42)); // "number"
console.log(typeVal(BigInt(42))); // "bigint"
console.log(typeVal("")); // "string"
console.log(typeVal(Symbol())); // "symbol"
console.log(typeVal(true)); // "boolean"
console.log(typeVal(undefined)); // "undefined"
console.log(typeVal(()=>{})); // "arrow"
console.log(typeVal(function(){})); // "function"
console.log(typeVal(class {})); // "class"
console.log(typeVal(null)); // "null"
console.log(typeVal([])); // "array"
console.log(typeVal({})); // "object"
console.log(typeVal(new (class {}))); // "instance"
Si se proporciona el parámetro type, la función verifica si la representación en forma de cadena del tipo del parámetro value coincide con el type proporcionado. Lo hace comparando el resultado de invocar la función adecuada del objeto option con el type proporcionado. Si coinciden, devuelve true; de lo contrario, devuelve false.
// inputs comparation
// output: boolean
console.log(typeVal(42, "number")); // true
console.log(typeVal(BigInt(42), "bigint")); // true
console.log(typeVal("", "string")); // true
console.log(typeVal(Symbol(), "symbol")); // true
console.log(typeVal(true, "boolean")); // true
console.log(typeVal(undefined, "undefined")); // true
console.log(typeVal(()=>{}, "arrow")); // true
console.log(typeVal(function(){}, "function")); // true
console.log(typeVal(class {}, "class")); // true
console.log(typeVal(null, "null")); // true
console.log(typeVal([], "array")); // true
console.log(typeVal({}, "object")); // true
console.log(typeVal(new (class {}), "instance")); // true
FAQs
typeVal es una función útil para determinar el tipo de un valor en JavaScript y realizar comparaciones de tipo de manera flexible y precisa.
We found that typeval demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.