# rework-plugin-function

> function() plugin for rework, formerly included in core

Latest version **1.0.2** (published 2015-02-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install rework-plugin-function
pnpm add rework-plugin-function
yarn add rework-plugin-function
bun add rework-plugin-function
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2015-02-12 |
| First published | 2014-03-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 10 |
| Author | reworkcss |
| Maintainers | bclinkinbeard, jongleberry, conradz, necolas, slexaxton |
| Keywords | browser, server, css, preprocess, transform |

## Links

- npm: https://www.npmjs.com/package/rework-plugin-function
- Repository: https://github.com/reworkcss/rework-plugin-function
- Issues: https://github.com/reworkcss/rework-plugin-function/issues
- npm.io page: https://npm.io/package/rework-plugin-function

## Dependencies (1)

- [rework-visit](https://npm.io/package/rework-visit.md) ^1.0.0

## Alternatives

- [style-dictionary](https://npm.io/package/style-dictionary.md) — 2.0M weekly downloads
- [postcss-merge-idents](https://npm.io/package/postcss-merge-idents.md) — 1.7M weekly downloads
- [@fontsource/noto-sans](https://npm.io/package/@fontsource/noto-sans.md) — 93.0K weekly downloads
- [uglifycss](https://npm.io/package/uglifycss.md) — 71.6K weekly downloads
- [mat4-interpolate](https://npm.io/package/mat4-interpolate.md) — 23.3K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2015-02-12
- 1.0.1 — 2014-06-21
- 1.0.0 — 2014-06-20
- 0.1.3 — 2014-03-07
- 0.1.2 — 2014-03-06
- 0.1.1 — 2014-03-05
- 0.1.0 — 2014-03-05

## README

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;
}
```

---
_Source: https://npm.io/package/rework-plugin-function · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
