Socket
Socket
Sign inDemoInstall

classnames

Package Overview
Dependencies
0
Maintainers
2
Versions
30
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.3.1 to 2.3.2

12

bind.d.ts

@@ -1,5 +0,9 @@

export * from './index';
import { Argument } from './index';
import { ArgumentArray } from './index.js';
export type Binding = { [key: string]: string };
export default function classNames(this: Binding | void, ...args: Argument[]): string;
declare namespace classNames {
type Binding = Record<string, string>;
}
declare function classNames(this: classNames.Binding | undefined, ...args: ArgumentArray): string;
export = classNames;
/*!
Copyright (c) 2018 Jed Watson.
Licensed under the MIT License (MIT), see
http://jedwatson.github.io/classnames
Copyright (c) 2018 Jed Watson.
Licensed under the MIT License (MIT), see
http://jedwatson.github.io/classnames
*/

@@ -27,11 +27,12 @@ /* global define */

} else if (argType === 'object') {
if (arg.toString === Object.prototype.toString) {
for (var key in arg) {
if (hasOwn.call(arg, key) && arg[key]) {
classes.push(this && this[key] || key);
}
}
} else {
if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {
classes.push(arg.toString());
continue;
}
for (var key in arg) {
if (hasOwn.call(arg, key) && arg[key]) {
classes.push(this && this[key] || key);
}
}
}

@@ -38,0 +39,0 @@ }

@@ -1,4 +0,2 @@

export * from './index';
import classNames from './index';
export default classNames;
import classNames = require('./index.js');
export = classNames;
/*!
Copyright (c) 2018 Jed Watson.
Licensed under the MIT License (MIT), see
http://jedwatson.github.io/classnames
Copyright (c) 2018 Jed Watson.
Licensed under the MIT License (MIT), see
http://jedwatson.github.io/classnames
*/

@@ -32,13 +32,14 @@ /* global define */

function _parseObject (resultSet, object) {
if (object.toString === Object.prototype.toString) {
for (var k in object) {
if (hasOwn.call(object, k)) {
// set value to false instead of deleting it to avoid changing object structure
// https://www.smashingmagazine.com/2012/11/writing-fast-memory-efficient-javascript/#de-referencing-misconceptions
resultSet[k] = !!object[k];
}
}
} else {
if (object.toString !== Object.prototype.toString && !object.toString.toString().includes('[native code]')) {
resultSet[object.toString()] = true;
return;
}
for (var k in object) {
if (hasOwn.call(object, k)) {
// set value to false instead of deleting it to avoid changing object structure
// https://www.smashingmagazine.com/2012/11/writing-fast-memory-efficient-javascript/#de-referencing-misconceptions
resultSet[k] = !!object[k];
}
}
}

@@ -45,0 +46,0 @@

# Changelog
## v2.3.2 / 2022-09-13
- Fix TypeScript types when using require, thanks [Mark Dalgleish](https://github.com/markdalgleish) ([#276](https://github.com/JedWatson/classnames/pull/276))
- Fix toString as `[Object object]` in a vm, thanks [Remco Haszing](https://github.com/remcohaszing) ([#281](https://github.com/JedWatson/classnames/pull/281))
## v2.3.1 / 2021-04-03
- Fix bind/dedupe TypeScript types exports
- Fix mapping Value types, thanks [Remco Haszing](https://github.com/remcohaszing)
- Removed non-existent named exports from types, thanks [Remco Haszing](https://github.com/remcohaszing)
## v2.3.0 / 2021-04-01

@@ -4,0 +15,0 @@

@@ -11,6 +11,14 @@ // LICENSE is MIT

export type Value = string | number | boolean | undefined | null;
export type Mapping = { [key: string]: any };
export type Argument = Value | Mapping | Argument[];
declare namespace classNames {
type Value = string | number | boolean | undefined | null;
type Mapping = Record<string, unknown>;
interface ArgumentArray extends Array<Argument> {}
type Argument = Value | Mapping | ArgumentArray;
}
export default function classNames(...args: Argument[]): string;
/**
* A simple JavaScript utility for conditionally joining classNames together.
*/
declare function classNames(...args: classNames.ArgumentArray): string;
export = classNames;
/*!
Copyright (c) 2018 Jed Watson.
Licensed under the MIT License (MIT), see
http://jedwatson.github.io/classnames
Copyright (c) 2018 Jed Watson.
Licensed under the MIT License (MIT), see
http://jedwatson.github.io/classnames
*/

@@ -12,2 +12,3 @@ /* global define */

var hasOwn = {}.hasOwnProperty;
var nativeCodeString = '[native code]';

@@ -33,11 +34,12 @@ function classNames() {

} else if (argType === 'object') {
if (arg.toString === Object.prototype.toString) {
for (var key in arg) {
if (hasOwn.call(arg, key) && arg[key]) {
classes.push(key);
}
}
} else {
if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {
classes.push(arg.toString());
continue;
}
for (var key in arg) {
if (hasOwn.call(arg, key) && arg[key]) {
classes.push(key);
}
}
}

@@ -44,0 +46,0 @@ }

{
"name": "classnames",
"version": "2.3.1",
"version": "2.3.2",
"description": "A simple utility for conditionally joining classNames together",

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

"benchmarks-browserify": "./node_modules/.bin/browserify ./benchmarks/runInBrowser.js >./benchmarks/runInBrowser.bundle.js",
"dtslint": "dtslint",
"test": "mocha tests/*.js"

@@ -28,7 +29,15 @@ },

],
"files": [
"HISTORY.md",
"LICENSE",
"README.md",
"*.d.ts",
"*.js"
],
"devDependencies": {
"benchmark": "^2.1.4",
"browserify": "^17.0.0",
"mocha": "^8.3.2"
"dtslint": "^4.0.9",
"mocha": "^10.0.0"
}
}

@@ -5,3 +5,3 @@ Classnames

[![NPM version](https://badgen.net/npm/v/classnames)](https://www.npmjs.com/package/classnames)
[![Build status](https://badgen.net/travis/JedWatson/classnames)](https://travis-ci.org/JedWatson/classnames)
![Node.js CI](https://github.com/JedWatson/classnames/workflows/Node.js%20CI/badge.svg)
[![NPM Weekly Downloads](https://badgen.net/npm/dw/classnames)](https://www.npmjs.com/package/classnames)

@@ -8,0 +8,0 @@ [![License](https://badgen.net/npm/license/classnames)](https://www.npmjs.com/package/classnames)

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc