Research
Security News
Kill Switch Hidden in npm Packages Typosquatting Chalk and Chokidar
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Generate CSS classnames from declarations, works splendid together with e.g. React
Generate CSS classnames from declarations, works splendid together with e.g. React
Generating classnames according to the contents of a CSS declaration solves the biggest problem with large scale CSS, i.e. the fact that it cascades. See unistyle
for how to use this in a scalable way.
Install cngen
using npm:
npm install --save cngen
var cngen = require('cngen');
cngen({
color: '#FFF',
fontSize: '10px'
});
// _e80a8a8
Property order is not important, i.e. two declarations with the same properties but in a different order gives the same classname, e.g:
var cngen = require('cngen');
cngen({
color: '#FFF',
fontSize: '10px'
});
// _e80a8a8
cngen({
fontSize: '10px',
color: '#FFF'
});
// _e80a8a8
Have a look at unistyle
for how this fits together with React.
cngen(declaration)
Name | Type | Description |
---|---|---|
declaration | Object | The CSS declaration to generate a classname for |
Returns: String
, a generated classname, which consists of a "_"
followed by a hexadecimal string (generated with short-hash
).
MIT © Joakim Carlstein
FAQs
Generate CSS classnames from declarations, works splendid together with e.g. React
The npm package cngen receives a total of 2 weekly downloads. As such, cngen popularity was classified as not popular.
We found that cngen 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 found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.