Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

classwrap

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

classwrap - npm Package Compare versions

Comparing version 1.2.3 to 2.0.0

52

package.json
{
"name": "classwrap",
"description": "0.3 KB JavaScript utility for conditionally concatenating class names.",
"version": "1.2.3",
"main": "dist/classwrap.js",
"jsnext:main": "src/index.js",
"module": "src/index.js",
"typings": "classwrap.d.ts",
"license": "MIT",
"repository": "JorgeBucaran/classwrap",
"files": [
"src",
"dist",
"classwrap.d.ts"
],
"author": "Jorge Bucaran",
"keywords": [
"css",
"jsx",
"string",
"classname"
],
"version": "2.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "jest --coverage --no-cache && tsc -p tests/ts",
"build": "npm run bundle && npm run minify",
"bundle": "rollup -i src/index.js -o dist/classwrap.js -m -f umd -n classwrap",
"minify": "uglifyjs dist/classwrap.js -o dist/classwrap.js --mangle --compress warnings=false --pure-funcs=Object.defineProperty -p relative --source-map dist/classwrap.js.map",
"bench": "node bench",
"prepare": "npm run build",
"format": "prettier --semi false --write 'src/**/*.js' '{,tests/ts/}*.ts'",
"release": "npm run build && npm test && git commit -am $npm_package_version && git tag $npm_package_version && git push origin master && git push --tags && npm publish"
"test": "echo \"Error: no test specified\" && exit 1"
},
"babel": {
"presets": "env"
"repository": {
"type": "git",
"url": "git+https://github.com/npm/deprecate-holder.git"
},
"devDependencies": {
"babel-preset-env": "^1.6.1",
"jest": "^21.2.1",
"prettier": "~1.7.4",
"rollup": "^0.50.0",
"typescript": "^2.5.3",
"uglify-js": "^2.7.5"
}
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/npm/deprecate-holder/issues"
},
"homepage": "https://github.com/npm/deprecate-holder#readme",
"dependencies": {}
}

@@ -1,106 +0,5 @@

# Classwrap
[![Travis CI](https://img.shields.io/travis/JorgeBucaran/classwrap/master.svg)](https://travis-ci.org/JorgeBucaran/classwrap)
[![Codecov](https://img.shields.io/codecov/c/github/JorgeBucaran/classwrap/master.svg)](https://codecov.io/gh/JorgeBucaran/classwrap)
[![npm](https://img.shields.io/npm/v/classwrap.svg)](https://www.npmjs.org/package/classwrap)
# Deprecated Package
Classwrap is a 0.3 KB JavaScript utility for conditionally concatenating [class names](https://developer.mozilla.org/en-US/docs/Web/API/Element/className).
This package is no longer supported and has been deprecated. To avoid malicious use, npm is hanging on to the package name.
[Try it Online](https://codepen.io/JorgeBucaran/pen/GMRjRB)
```js
import cw from "classwrap"
export function ToggleButton({ toggle, isOn }) {
return (
<div class="btn" onclick={toggle}>
<div
class={cw({
circle: true,
off: !isOn,
on: isOn
})}
/>
<span
class={cw({
textOff: !isOn
})}
>
{isOn ? "ON" : "OFF"}
</span>
</div>
)
}
```
Classwrap works in all browsers >=IE9. Use it with your favorite JavaScript view library.
[![Classwrap](https://user-images.githubusercontent.com/56996/30416101-cda83bd4-9965-11e7-9db5-230ba3fc83fd.gif)](https://codepen.io/JorgeBucaran/full/GMRjRB/)
## Installation
Install with npm / Yarn.
<pre>
npm i <a href="https://www.npmjs.com/package/classwrap">classwrap</a>
</pre>
Then with a module bundler like [Rollup](https://github.com/rollup/rollup) or [Webpack](https://github.com/webpack/webpack), use as you would anything else.
```js
import cw from "classwrap"
```
Or download the minified library from a [unpkg](https://unpkg.com/classwrap@latest/dist/classwrap.js) or [jsDelivr](https://cdn.jsdelivr.net/npm/classwrap@latest/dist/classwrap.js).
```html
<script src="https://unpkg.com/classwrap"></script>
```
Then find it on `window.classwrap`.
## Usage
Classwrap joins all elements of an array or keys of an object into a string. If the value associated with a given key is falsy, the key will be ignored.
```js
cw([
"btn",
{
"btn-active": true,
"btn-large": false
}
]) // => btn btn-active
```
Nested arrays or objects are supported too. Use this feature to assemble classes with a common prefix.
```js
cw([
"tab",
{
tab: {
"--success": true,
"--error": false,
"--pending": false
}
}
]) // => tab tab--success
```
## Credits
Classwrap was inspired by [JedWatson/classnames](https://github.com/JedWatson/classnames) with support for nested objects and [improved](/bench/README.md) performance. It differs from classnames in that it does not accept [variable arguments](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments).
```js
cw("foo", "bar", "baz") // => foo
```
To solve this, wrap the arguments inside an array.
```js
cw(["foo", "bar", "baz"]) // => foo bar baz
```
## License
Classwrap is MIT licensed. See [LICENSE](LICENSE.md).
Please contact support@npmjs.com if you have questions about this package.
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