New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

rework-plugin-function

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rework-plugin-function - npm Package Compare versions

Comparing version 0.1.3 to 1.0.0

.travis.yml

2

package.json
{
"name": "rework-plugin-function",
"version": "0.1.3",
"version": "1.0.0",
"description": "function() plugin for rework, formerly included in core",

@@ -5,0 +5,0 @@ "main": "index.js",

rework-plugin-function
====================
[![Build Status](https://travis-ci.org/reworkcss/rework-plugin-function.png)](https://travis-ci.org/reworkcss/rework-plugin-function)
function() plugin for rework, formerly included in core
Add user-defined CSS functions.
For example create `black(0.5)` shortcut, to replace
long `rgba(0, 0, 0, 0.5)`.
```js
var rework = require('rework'),
var reworkFunction = require('rework-plugin-function');
var css = rework(css)
.use(reworkFunction({ black: black }))
.toString()
function black(opacity) {
return 'rgba(0, 0, 0, ' + opacity + ')';
}
```
User code will receive CSS arguments and replace user-defined function
by returned code.
```css
input {
box-shadow: 0 0 5px black(0.7);
}
```
yields:
```css
input {
box-shadow: 0 0 5px rgba(0, 0, 0, 0.7);
}
```
Nested functions works well too:
```javascript
var css = rework(css)
.use(reworkFunction({
subtract: function(a, b) { return a - b },
multiply: function(a, b) { return a * b },
divide: function(a, b) { return a / b },
floor: Math.floor
}))
.toString()
```
```css
input {
top: divide(subtract(30, floor(multiply(20, 10))), 2);
}
```
Would yield:
```css
input {
top: -85;
}
```

Sorry, the diff of this file is not supported yet

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