# counteraction

> Compute CSS list-style-type and @counter-style values

Latest version **1.3.2** (published 2022-08-06) · BSD-3-Clause license · 0 weekly downloads

## Install

```sh
npm install counteraction
pnpm add counteraction
yarn add counteraction
bun add counteraction
```

## 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.3.2 |
| Published | 2022-08-06 |
| First published | 2019-11-17 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 81.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Andreas Lind |
| Maintainers | papandreou |
| Keywords | css, count, counter, counter-style, symbols, list-style, list, cyclic, hebrew, armenian, georgian, roman |

## Links

- npm: https://www.npmjs.com/package/counteraction
- Repository: https://github.com/papandreou/counteraction
- Homepage: https://github.com/papandreou/counteraction#readme
- Issues: https://github.com/papandreou/counteraction/issues
- npm.io page: https://npm.io/package/counteraction

## 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.3.2 (latest) — 2022-08-06
- 1.3.1 — 2022-01-10
- 1.3.0 — 2019-11-19
- 1.2.0 — 2019-11-19
- 1.1.0 — 2019-11-17
- 1.0.0 — 2019-11-17

## README

# counteraction

[![Build Status](https://travis-ci.org/papandreou/counteraction.svg?branch=master)](https://travis-ci.org/papandreou/counteraction)

[![Coverage Status](https://coveralls.io/repos/github/papandreou/counteraction/badge.svg?branch=master)](https://coveralls.io/github/papandreou/counteraction?branch=master)

Implementations of most of the counter types supported by the [`list-style-type`
CSS property](https://developer.mozilla.org/en-US/docs/Web/CSS/list-style-type)
as well as the numbering systems allowed by
[`@counter-style`](https://developer.mozilla.org/en-US/docs/Web/CSS/@counter-style).

Many of the renderers are based on CLDR with the code generated by the [cldr module](https://github.com/papandreou/node-cldr) (see `extractRbnfFunctionByType`).

## Installation

```
npm install counteraction
```

## Supported renderers

Simple `list-style-type` renderers (option-less):

- `armenian`
- `decimal`
- `decimal-leading-zero`
- `ethiopic`
- `georgian`
- `hebrew`
- `lower-alpha`
- `lower-greek`
- `lower-latin`
- `lower-roman`
- `tamil`
- `upper-alpha`
- `upper-greek`
- `upper-latin`
- `upper-roman`

These bogus ones are there for completeness:

- `disc` (renders a `•` regardless of the value)
- `none` (renders the empty string regardless of the value)

More complex `@counter-system` renderers:

- `alphabetic`
- `additive`
- `cyclic`
- `fixed`
- `symbolic`
- `numeric`

## Example

The simple counter renderers are instantiated by their name and don't need any options:

```js
const counteraction = require('counteraction');

const renderer = counteraction('lower-roman');
console.log(renderer.render(123)); // cxxiii
```

```output
cxxiii
```

The `@counter-system` ones are created by their `system` name and accept an
options object that corresponds to the CSS properties of the `@counter-style`
declaration:

```js
const renderer = counteraction('alphabetic', {
  symbols: ['X', 'Y', 'Z'],
});
console.log(renderer.render(123)); // XXXXZ
```

```output
XXXXZ
```

The name (system) can also be passed as a separate property instead of the name
parameter. That might be easier if you're working with a parsed representation
of the whole `@counter-style` declaration:

```js
const renderer = counteraction({
  system: 'alphabetic',
  symbols: ['X', 'Y', 'Z'],
});
console.log(renderer.render(123)); // XXXXZ
```

```output
XXXXZ
```

They also support a `fallback` option to be used when the value is out of range.
It can be passed as either a renderer instance or the name of a
`list-style-type` renderer:

```js
const renderer = counteraction('fixed', {
  symbols: ['X', 'Y', 'Z'],
  fallback: 'disc',
});
console.log(renderer.render(3)); // Z
console.log(renderer.render(4)); // •
```

```output
Z
•
```

The `fallback` option can also be passed as another renderer instance, or "lazily" as a function that returns either a `list-style-type` name or a renderer.

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