Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
@jcayzac/astro-classlist
Advanced tools
Helper for Astro components to coerce `class:list` into an array of strings.
@jcayzac/astro-classlist
Coerce Astro's
class:list
into an array of strings.
This module provides a single utility for Astro components, that coerce a value received as a class:list
prop into an array of strings.
You probably need this if your component receives a class:list
prop and passes it to a child component, and if you want to add other classes to the list.
Because class:list
can be an object or an iterable and contain things other than strings, it can get a bit messy if you want to add something to that.
// This is what you normally get from Astro
type AstroBuiltinAttributes['class:list'] =
| string
| Record<string, boolean>
| Record<any, any>
| Iterable<string>
| Iterable<any>
| undefined
// This is what you get when using this utility
type ClassList = string[]
# pnpm
pnpm add @jcayzac/astro-classlist
# bun
bunx add @jcayzac/astro-classlist
# npm
npx add @jcayzac/astro-classlist
# yarn
yarn add @jcayzac/astro-classlist
# deno
deno add npm:@jcayzac/astro-classlist
---
import type { AstroBuiltinAttributes } from 'astro'
import ChildComponent from '@components/ChildComponent.astro'
import { ClassList } from '@jcayzac/astro-classlist'
interface Props {
'class:list': AstroBuiltinAttributes['class:list']
}
const { 'class:list': classList } = Astro.props as Props
const classes: string[] = ClassList.toArray(classList)
---
<ChildComponent class:list={['mx-auto', ...classes]} />
If you like anything here, consider buying me a coffee using one of the following platforms:
FAQs
Helper for Astro components to coerce `class:list` into an array of strings.
The npm package @jcayzac/astro-classlist receives a total of 11 weekly downloads. As such, @jcayzac/astro-classlist popularity was classified as not popular.
We found that @jcayzac/astro-classlist 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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.