
Security News
Cline CLI npm Package Compromised via Suspected Cache Poisoning Attack
A compromised npm publish token was used to push a malicious postinstall script in cline@2.3.0, affecting the popular AI coding agent CLI with 90k weekly downloads.
@frankhoodbs/cast-prop-to-type
Advanced tools
This utility provides a straightforward mechanism to cast various types of JavaScript properties to desired data types, such as number, array, boolean, and object. In the event of a casting error or invalid input, a custom ValidationError is thrown to provide a meaningful error message.
import { castPropToType } from "@frankhoodbs/cast-prop-to-type";
const numValue = castPropToType("42", "number"); // Returns 42 as a number
castPropToType(value, type)Cast the given value to the specified type.
any): The value to be casted."number" | "array" | "boolean" | "object"): The type to which the value should be casted.The casted value. Throws ValidationError if casting is not possible.
Custom error that is thrown when there's a validation error during the casting process. It extends the native JavaScript Error class.
// Casting a string to a number
const num = castPropToType("42", "number"); // 42
// Casting a string to an array
const arr = castPropToType('["a", "b", "c"]', "array"); // ["a", "b", "c"]
// Casting a string to a boolean
const boolTrue = castPropToType("true", "boolean"); // true
// Casting a string to an object
const obj = castPropToType('{"key": "value"}', "object"); // { key: "value" }
If the utility encounters an invalid value for the desired casting type or if the type itself is invalid, a ValidationError will be thrown:
try {
const num = castPropToType("foo", "number");
} catch (error) {
if (error instanceof ValidationError) {
console.error(error.message);
}
}
FAQs
Simple utility to convert string props to correct type
We found that @frankhoodbs/cast-prop-to-type demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
A compromised npm publish token was used to push a malicious postinstall script in cline@2.3.0, affecting the popular AI coding agent CLI with 90k weekly downloads.

Product
Socket is now scanning AI agent skills across multiple languages and ecosystems, detecting malicious behavior before developers install, starting with skills.sh's 60,000+ skills.

Product
Socket now supports PHP with full Composer and Packagist integration, enabling developers to search packages, generate SBOMs, and protect their PHP dependencies from supply chain threats.