fast-classnames
v1.0.0
Published
Fast join class names
Downloads
2
Maintainers
Readme
fast-classnames
Fast join class names
Installation
In a browser
<script src="https://cdn.jsdelivr.net/npm/fast-classnames/umd.min.js"></script>
<!-- <script src="https://cdn.jsdelivr.net/npm/fast-classnames/iife.min.js"></script> -->
<script>
// window.fastClassnames
fastClassnames('foo', 'bar'); // => 'foo bar'
fastClassnames('foo', { bar: true }); // => 'foo bar'
fastClassnames({ 'foo-bar': true }); // => 'foo-bar'
fastClassnames({ 'foo-bar': false }); // => ''
fastClassnames({ foo: true }, { bar: true }); // => 'foo bar'
fastClassnames({ foo: true, bar: true }); // => 'foo bar'
// lots of arguments of various types
fastClassnames('foo', { bar: true, duck: false }, 'baz', { quux: true }); // => 'foo bar baz quux'
// other falsy values are just ignored
fastClassnames(null, false, 'bar', undefined, 0, 1, { baz: null }, ''); // => 'bar 1'
</script>
Using npm
npm install fast-classnames --save
var fastClassnames = require('classnames');
fastClassnames('foo', 'bar'); // => 'foo bar'
fastClassnames('foo', { bar: true }); // => 'foo bar'
fastClassnames({ 'foo-bar': true }); // => 'foo-bar'
fastClassnames({ 'foo-bar': false }); // => ''
fastClassnames({ foo: true }, { bar: true }); // => 'foo bar'
fastClassnames({ foo: true, bar: true }); // => 'foo bar'
// lots of arguments of various types
fastClassnames('foo', { bar: true, duck: false }, 'baz', { quux: true }); // => 'foo bar baz quux'
// other falsy values are just ignored
fastClassnames(null, false, 'bar', undefined, 0, 1, { baz: null }, ''); // => 'bar 1'
Benchmark
【classnames】 x 319,625 ops/sec ±18.60% (76 runs sampled)
【fastClassnames】 x 520,426 ops/sec ±0.31% (92 runs sampled)
The fastest is 【fastClassnames】