Socket
Socket
Sign inDemoInstall

classnames

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

classnames - npm Package Compare versions

Comparing version 1.1.1 to 1.1.2

bower.json

7

index.js

@@ -7,7 +7,7 @@ function classNames() {

var arg = args[i];
if (arg == null) {
if (!arg) {
continue;
}
if ('string' === typeof arg) {
if ('string' === typeof arg || 'number' === typeof arg) {
classes.push(arg);

@@ -26,2 +26,3 @@ } else if ('object' === typeof arg) {

module.exports = classNames;
// safely export classNames in case the script is included directly on a page
try { module.exports = classNames; } catch(e) {};
{
"name": "classnames",
"version": "1.1.1",
"version": "1.1.2",
"description": "A simple utility for conditionally joining classNames together",

@@ -16,2 +16,3 @@ "main": "index.js",

"keywords": [
"react",
"css",

@@ -18,0 +19,0 @@ "classes",

@@ -12,20 +12,20 @@ Classnames

The `classnames` function takes any number of arguments which can be a string or object.
The argument `'foo'` is short for `{foo: true}`. If the value of the key is falsy, it won't be included in the output.
The `classNames` function takes any number of arguments which can be a string or object.
The argument `'foo'` is short for `{foo: true}`. If the value of the key is falsy, it won't be included in the output.
```js
classnames('foo', 'bar'); // => 'foo bar'
classnames('foo', {bar: true}); // => 'foo bar'
classnames({foo: true}, {bar: true}); // => 'foo bar'
classnames({foo: true, bar: true}); // => 'foo bar'
classNames('foo', 'bar'); // => 'foo bar'
classNames('foo', {bar: true}); // => 'foo bar'
classNames({foo: true}, {bar: true}); // => 'foo bar'
classNames({foo: true, bar: true}); // => 'foo bar'
// lots of arguments of various types
classnames('foo', {bar: true, duck: false}, 'baz', {quux: true}) // => 'foo bar baz quux'
classNames('foo', {bar: true, duck: false}, 'baz', {quux: true}) // => 'foo bar baz quux'
// other falsy values are just ignored
classnames(null, false, 'bar', undefined, 0, {baz: null}, ''); // => 'bar'
classNames(null, false, 'bar', undefined, 0, 1, {baz: null}, ''); // => 'bar 1'
// if you have an array of these, use apply
var array = ['foo', {bar: true}];
classnames.apply(null, array); // => 'foo bar'
classNames.apply(null, array); // => 'foo bar'
```

@@ -16,4 +16,4 @@ var assert = require("assert");

it('joins arrays of class names and ignore non-string values', function() {
assert.equal(classNames('a', 0, null, undefined, true, 1, 'b'), 'a b');
it('joins arrays of class names and ignore falsy values', function() {
assert.equal(classNames('a', 0, null, undefined, true, 1, 'b'), 'a 1 b');
});

@@ -25,2 +25,6 @@

it('should be trimmed', function() {
assert.equal(classNames('', 'b', {}, ''), 'b');
});
it('returns an empty string for an empty configuration', function() {

@@ -27,0 +31,0 @@ assert.equal(classNames({}), '');

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc