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.
class-prefixer
Advanced tools
clsssName prefixer
npm install class-prefixer
import className from 'class-prefixer';
// base
let cls = className('pre');
cls() // pre
cls('a b') // pre-a pre-b;
cls({a: true, b: true}) // pre-a pre-b;
cls('a', 'b c') // pre-a b c;
cls('a', {b: true, c: false}) // pre-a b;
cls = cls.add('next');
cls('a') // pre-next-a
// add default prefix
cls('a', true).should.eql('pre pre-a');
cls('a', 'b', true).should.eql('pre pre-a b');
在react中的使用:
import className from 'class-prefixer';
const cls = className('app');
const clsBody = cls.add('body');
export default function App(props) {
return <div className={cls}>
<div className={cls('header')}>header</div>
<div className={clsBody}>
<div className={clsBody('content')}>
body content
<a className={clsBody('link', { actived: true })}>link</a>
</div>
</div>
</div>;
}
ReactDOM.render(<App />, document.getElementById('__react-content'));
对应到less中:
.app {
color: #aaa;
&-header {
color: #bbb;
}
&-body {
color: #ccc;
&-content {
color: #ddd;
}
&-link.actived {
color: blue;
}
}
}
最终转换成的css, 这种没有嵌套的css格式性能是最好的:
.app { color: #aaa; }
.app-header { color: #bbb; }
.app-body { color: #ccc; }
.app-body-content { color: #ddd; }
.app-body-link.actived { color: blue; }
FAQs
clsssName prefixer
The npm package class-prefixer receives a total of 0 weekly downloads. As such, class-prefixer popularity was classified as not popular.
We found that class-prefixer 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.