Repository: JedWatson/classnames Branch: main Commit: dcbb7fb269c0 Files: 27 Total size: 40.7 KB Directory structure: gitextract_vmzpiaz5/ ├── .editorconfig ├── .github/ │ ├── dependabot.yml │ └── workflows/ │ ├── node.js.yml │ └── release.yml ├── .gitignore ├── .npmignore ├── CONTRIBUTING.md ├── HISTORY.md ├── LICENSE ├── README.md ├── benchmarks/ │ ├── benchmarks.js │ ├── index.html │ ├── run.js │ └── runInBrowser.js ├── bind.d.ts ├── bind.js ├── dedupe.d.ts ├── dedupe.js ├── index.d.ts ├── index.js ├── package.json └── tests/ ├── bind.js ├── bind.test-d.ts ├── dedupe.js ├── dedupe.test-d.ts ├── index.js └── index.test-d.ts ================================================ FILE CONTENTS ================================================ ================================================ FILE: .editorconfig ================================================ # This file is for unifying the coding style for different editors and IDEs # editorconfig.org root = true [*] end_of_line = lf charset = utf-8 trim_trailing_whitespace = false insert_final_newline = true indent_style = tab [*.json] indent_style = space indent_size = 2 [*.yml] indent_style = space indent_size = 2 ================================================ FILE: .github/dependabot.yml ================================================ version: 2 updates: - package-ecosystem: github-actions directory: / schedule: interval: daily - package-ecosystem: npm directory: / rebase-strategy: disabled versioning-strategy: increase schedule: interval: daily ================================================ FILE: .github/workflows/node.js.yml ================================================ name: Node.js CI on: push: branches: - main pull_request: jobs: test: name: Run tests on supported Node.js versions runs-on: ubuntu-latest strategy: fail-fast: false matrix: # See supported Node.js versions at https://nodejs.org/en/about/previous-releases node-version: [18, 20, 21] steps: - name: Check out repository uses: actions/checkout@v6 - name: Set up Node.js uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} cache: npm - name: Install dependencies run: npm ci - name: Run tests run: npm test check-types: name: Check type definitions runs-on: ubuntu-latest steps: - name: Check out repository uses: actions/checkout@v6 - name: Set up Node.js uses: actions/setup-node@v4 with: node-version: 20 cache: npm - name: Install dependencies run: npm ci - name: Check type definitions run: npm run check-types benchmarks: name: Run benchmarks runs-on: ubuntu-latest steps: - name: Check out repository uses: actions/checkout@v6 - name: Set up Node.js uses: actions/setup-node@v4 with: node-version: 20 cache: npm - name: Install dependencies run: npm ci - name: Run benchmarks run: npm run bench ================================================ FILE: .github/workflows/release.yml ================================================ name: Release on: workflow_dispatch: permissions: id-token: write jobs: publish: name: Publish package to NPM runs-on: ubuntu-latest environment: release steps: - name: Check out repository uses: actions/checkout@v6 with: fetch-depth: 0 persist-credentials: false - name: Set up Node.js uses: actions/setup-node@v4 with: node-version: 20 cache: npm registry-url: https://registry.npmjs.org - name: Publish to NPM run: npm publish env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} NPM_CONFIG_PROVENANCE: true ================================================ FILE: .gitignore ================================================ # Logs logs *.log # Runtime data pids *.pid *.seed # Directory for instrumented libs generated by jscoverage/JSCover lib-cov # Coverage directory coverage # Compiled binary addons (http://nodejs.org/api/addons.html) build/Release # Dependency directory node_modules # Users Environment Variables .lock-wscript # Mac OS X DS_Store .DS_Store benchmarks/runInBrowser.bundle.js ================================================ FILE: .npmignore ================================================ /.*/ /.* /benchmarks/ /tests/ /CONTRIBUTING.md /HISTORY.md ================================================ FILE: CONTRIBUTING.md ================================================ # Contributing Thanks for your interest in classNames. Issues, PRs and suggestions welcome :) Before working on a PR, please consider the following: * Speed is a serious concern for this package as it is likely to be called a significant number of times in any project that uses it. As such, new features will only be accepted if they improve (or at least do not negatively impact) performance. * To demonstrate performance differences please set up a [JSPerf](http://jsperf.com) test and link to it from your issue / PR. * Tests must be added for any change or new feature before it will be accepted. A benchmark utility is included so that changes may be tested against the current published version. To run the benchmarks, run `npm install` in the root directory then run `npm run bench`. Please be aware though that local benchmarks are just a smoke-signal; they will run in the v8 version that your local Node.js uses, while classNames is _most_ often run across a wide variety of browsers and browser versions. It is recommended to test possible regressions in performance in all major browsers. This can be done by running `npm run bench-browser`, the benchmark will then be served from http://localhost:8080. ================================================ FILE: HISTORY.md ================================================ # Changelog ## v2.5.1 / 2023-12-29 - Remove `workspaces` field from package ([#350](https://github.com/JedWatson/classnames/pull/350)) ## v2.5.0 / 2023-12-27 - Restore ability to pass a TypeScript `interface` ([#341](https://github.com/JedWatson/classnames/pull/341)) - Add `exports` field to package ([#342](https://github.com/JedWatson/classnames/pull/342)) ## v2.4.0 / 2023-12-26 - Use string concatenation to increase performance thanks [Jon Koops](https://github.com/jonkoops) ([#336](https://github.com/JedWatson/classnames/pull/336)) ## v2.3.3 / 2023-12-21 - Fix default export, thanks [Remco Haszing](https://github.com/remcohaszing) ([#301](https://github.com/JedWatson/classnames/pull/301)) - Fix types for read-only arrays, thanks [Ben Thompson](https://github.com/BenGearset) ([#307](https://github.com/JedWatson/classnames/pull/307)) - Replace README examples with functional-style components, thanks [JoeDGit](https://github.com/JoeDGit) ([#303](https://github.com/JedWatson/classnames/pull/303)) ## 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 - Added TypeScript types - Added consistent support for custom `.toString()` methods on arguments, thanks [Stanislav Titenko](https://github.com/resetko) ## v2.2.6 / 2018-06-08 - Fixed compatibility issue with usage in an es module environment ## v2.2.5 / 2016-05-02 - Improved performance of `dedupe` variant even further, thanks [Andres Suarez](https://github.com/zertosh) ## v2.2.4 / 2016-04-25 - Improved performance of `dedupe` variant by about 2x, thanks [Bartosz Gościński](https://github.com/bgoscinski) ## v2.2.3 / 2016-01-05 - Updated `bind` variant to use `[].join(' ')` as per the main script in 2.2.2 ## v2.2.2 / 2016-01-04 - Switched from string concatenation to `[].join(' ')` for a slight performance gain in the main function. ## v2.2.1 / 2015-11-26 - Add deps parameter to the AMD module, fixes an issue using the Dojo loader, thanks [Chris Jordan](https://github.com/flipperkid) ## v2.2.0 / 2015-10-18 - added a new `bind` variant for use with [css-modules](https://github.com/css-modules/css-modules) and similar abstractions, thanks to [Kirill Yakovenko](https://github.com/blia) ## v2.1.5 / 2015-09-30 - reverted a new usage of `Object.keys` in `dedupe.js` that slipped through in the last release ## v2.1.4 / 2015-09-30 - new case added to benchmarks - safer `hasOwnProperty` check - AMD module is now named, so you can do the following: ``` define(["classnames"], function (classNames) { var style = classNames("foo", "bar"); // ... }); ``` ## v2.1.3 / 2015-07-02 - updated UMD wrapper to support AMD and CommonJS on the same pacge ## v2.1.2 / 2015-05-28 - added a proper UMD wrapper ## v2.1.1 / 2015-05-06 - minor performance improvement thanks to type caching - improved benchmarking and results output ## v2.1.0 / 2015-05-05 - added alternate `dedupe` version of classNames, which is slower (10x) but ensures that if a class is added then overridden by a falsy value in a subsequent argument, it is excluded from the result. ## v2.0.0 / 2015-05-03 - performance improvement; switched to `Array.isArray` for type detection, which is much faster in modern browsers. A polyfill is now required for IE8 support, see the Readme for details. ## v1.2.2 / 2015-04-28 - license comment updates to simplify certain build scenarios ## v1.2.1 / 2015-04-22 - added safe exporting for requireJS usage - clarified Bower usage and instructions ## v1.2.0 / 2015-03-17 - added comprehensive support for array arguments, including nested arrays - simplified code slightly ## Previous Please see the git history for the details of previous versions. ================================================ FILE: LICENSE ================================================ The MIT License (MIT) Copyright (c) 2018 Jed Watson Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: README.md ================================================ # Classnames > A simple JavaScript utility for conditionally joining classNames together.
Install from the [npm registry](https://www.npmjs.com/) with your package manager: ```bash npm install classnames ``` Use with [Node.js](https://nodejs.org/en/), [Browserify](https://browserify.org/), or [webpack](https://webpack.github.io/): ```js const classNames = require('classnames'); classNames('foo', 'bar'); // => 'foo bar' ``` Alternatively, you can simply include `index.js` on your page with a standalone `