Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
ts-nameof-proxy
Advanced tools
`nameof` in TypeScript, no compiler required. Implemented using proxy with some limitations.
nameof
in TypeScript, no compiler required. Implemented using proxy with some limitations.
Type safely generate property name or path of variable, referenced properties can be renamed in bulk by the editor.
npm install ts-nameof-proxy
nameOf(student, (s) => s.age); // "age"
nameOf(student, (s) => s.name.length); // "length"
nameOf<Student>((s) => s.name.length); // "length"
pathOf(student, (s) => s.age); // ["age"]
pathOf(student, (s) => s.name.length); // ["name", "length"]
pathOf<Student>((s) => s.name.length); // ["name", "length"]
pathStringOf(student, (s) => s.name.firstName[0]); // "['name']['firstName']['0']"
pathStringOf<Student>((s) => s.name.firstName[0]); // "['name']['firstName']['0']"
namesOf(student, (s) => (s.age, s.name.length)); // ["age", "length"]
namesOf<Student>((s) => (s.age, s.name.length)); // ["age", "length"]
pathsOf(student, (s) => (s.age, s.name.length)); // [["age"], ["name", "length"]]
pathsOf<Student>((s) => (s.age, s.name.length)); // [["age"], ["name", "length"]]
pathStringsOf(student, (s) => (s.name, s.name.firstName[0])); // ["['name']", "['name']['firstName']['0']"]
pathStringsOf<Student>((s) => (s.name, s.name.firstName[0])); // ["['name']", "['name']['firstName']['0']"]
The example below is NOT feasible:
nameOf(student); // ❌ Will throw error
nameOf(student, (student) => student); // ❌ Will throw error
const people = [
{ name: { firstName: "John", lastName: "Doe" } },
{ name: { firstName: "Jane", lastName: "Smith" } },
];
<Formik initialValues={people} onSubmit={() => {}}>
<Form>
{({ values }) =>
values.map((person, index) => (
<div key={person.name.firstName}>
<Field
name={pathStringOf(
values,
(values) => values[index].name.firstName
)}
/>
<Field
name={pathStringOf(values, (values) => values[index].name.lastName)}
/>
</div>
))
}
{/*
<Field name="['0']['name']['firstName']" />
<Field name="['0']['name']['lastName']" />
<Field name="['1']['name']['firstName']" />
<Field name="['1']['name']['lastName']" />
*/}
</Form>
</Formik>;
FAQs
`nameof` in TypeScript, no compiler required. Implemented using proxy with some limitations.
The npm package ts-nameof-proxy receives a total of 40 weekly downloads. As such, ts-nameof-proxy popularity was classified as not popular.
We found that ts-nameof-proxy 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.