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

function() plugin for rework, formerly included in core

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
21K
decreased by-18.31%
Maintainers
1
Weekly downloads
 
Created
Source

rework-plugin-function

Build Status

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).

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.

input {
  box-shadow: 0 0 5px black(0.7);
}

yields:

input {
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.7);
}

Nested functions works well too:

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()
input {
  top: divide(subtract(30, floor(multiply(20, 10))), 2);
}

Would yield:

input {
  top: -85;
}

Keywords

FAQs

Package last updated on 21 Jun 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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