# countingup

> Counter Class for JavaScript

Latest version **0.4.7** (published 2026-07-21) · UNLICENSED license · 0 weekly downloads

## Install

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

## Health

**Score 65/100 (B)** — status: active.

Positive: has types; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.4.7 |
| Published | 2026-07-21 |
| First published | 2023-01-11 |
| Weekly downloads | 0 |
| License | UNLICENSED |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 21 |
| Unpacked size | 17.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Samuel Fox J. |
| Maintainers | tj-commits |
| Keywords | math, js, utils, problems, calculations |

## Links

- npm: https://www.npmjs.com/package/countingup
- Repository: https://github.com/tj-commits/countingup
- Homepage: https://github.com/tj-commits/countingup#readme
- Issues: https://github.com/tj-commits/countingup/issues
- npm.io page: https://npm.io/package/countingup

## Dependencies (21)

- [const-e](https://npm.io/package/const-e.md) ^1.0.1
- [math.pi](https://npm.io/package/math.pi.md) ^1.0.0
- [const-ln2](https://npm.io/package/const-ln2.md) ^1.0.0
- [is-object](https://npm.io/package/is-object.md) ^1.0.2
- [const-ln10](https://npm.io/package/const-ln10.md) ^1.0.0
- [infinities](https://npm.io/package/infinities.md) ^1.0.1
- [is-integer](https://npm.io/package/is-integer.md) ^1.0.7
- [const-log2e](https://npm.io/package/const-log2e.md) ^1.0.0
- [const-log10e](https://npm.io/package/const-log10e.md) ^1.0.0
- [const-sqrt-half](https://npm.io/package/const-sqrt-half.md) ^1.0.0
- [immediate-error](https://npm.io/package/immediate-error.md) ^7.1.0
- [@std262/libnumbers](https://npm.io/package/@std262/libnumbers.md) ^1.0.1
- [primitive-value-nan](https://npm.io/package/primitive-value-nan.md) ^1.0.1
- [@is-(unknown)/is-nil](https://npm.io/package/@is-(unknown)/is-nil.md) ^1.2.0
- [@positive-numbers/one](https://npm.io/package/@positive-numbers/one.md) ^3.0.0
- [@positive-numbers/zero](https://npm.io/package/@positive-numbers/zero.md) ^3.0.0
- [es-logical-or-operator](https://npm.io/package/es-logical-or-operator.md) ^1.0.0
- [@is-(unknown)/is-finite](https://npm.io/package/@is-(unknown)/is-finite.md) ^1.0.0
- [es-logical-not-operator](https://npm.io/package/es-logical-not-operator.md) ^1.0.0
- [@stdlib/constants-float64-sqrt-two](https://npm.io/package/@stdlib/constants-float64-sqrt-two.md) ^0.2.3
- [@not-a-socket-override/switch-in-fp](https://npm.io/package/@not-a-socket-override/switch-in-fp.md) ^3.0.1

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 0.4.7 (latest) — 2026-07-21
- 0.0.2 (countingup-legacy-first-version) — 2026-02-27
- 0.4.6 — 2026-07-21
- 0.4.5 — 2026-03-03
- 0.4.4 — 2026-03-03
- 0.4.3 — 2026-02-05
- 0.4.2 — 2026-02-05
- 0.4.1 — 2026-02-03
- 0.4.0 — 2026-02-03
- 0.3.0 — 2025-12-29
- 0.2.5 — 2024-05-22
- 0.2.4 — 2024-05-22
- 0.2.3 — 2023-01-13
- 0.2.2 — 2023-01-13
- 0.2.1 — 2023-01-13
- … 7 more at https://npm.io/package/countingup/versions

## README

# Countingup
Countingup is a 10x math library. It provides a Counter class to count up and down with customizations. There are also math utilities that you can use with it.
## Installation
Using npm:
```sh
npm install countingup
```

In Node.js
```javascript
const countingup = require('countingup')
```

## Counter class
The ``Counter`` class provides a tool to count numbers.

Initializing
```javascript
const Counter = countingup.Counter
const myCounter = new Counter()
```

Counting
```javascript
myCounter.count()
console.log(myCounter.getCurrentNumber()) // 1
```

Resetting
```javascript
myCounter.reset()
console.log(myCounter.getCurrentNumber()) // 0
```

### Bonus Features
Customizing the Increment
```javascript
myCounter.count()
console.log(myCounter.getCurrentNumber()) // 1
myCounter.count(3)
console.log(myCounter.getCurrentNumber()) // 4
```

Customizing the Direction

This allows you to change the direction so it counts down and subtracts
```javascript
myCounter.reset()
myCounter.count(5)
console.log(myCounter.getCurrentNumber()) // 5
myCounter.count(5, countingup.Counter.DIRECTION.REVERSE) // 0
```
By default it will be forwards (countingup.Counter.DIRECTION.FORWARDS)

Customizing the Starting Number

```javascript
const myCounter2 = new Counter(4)
console.log(myCounter2.getCurrentNumber()) // 4
myCounter2.reset(3)
console.log(myCounter2.getCurrentNumber()) // 3
```

## Math Utilities
Countingup includes a suite of math functions that power the underlying logic and can be used for standalone calculations. These utilities handle both numbers and numeric strings.

### Basic Operations
```js
const { add, subtract, multiply, divide } = require("countingup")

console.log(add(5, 10))       // 15
console.log(subtract(20, 5))  // 15
console.log(multiply(3, 4))   // 12
console.log(divide(100, 4))   // 25
```

### Advanced Operations
```js
const { modulo, pow } = require("countingup")

console.log(modulo(10, 3)) // 1
console.log(pow(2, 3))    // 8
```

## Constants
Countingup provides some USEFUL constants.
```js
const assert = require("assert")
const countingup = require("countingup")

assert(countingup.E === Math.E)
assert(countingup.PI === Math.PI)
assert(countingup.SQRT2 === Math.SQRT2)
assert(countingup.SQRT1_2 === Math.SQRT1_2)
assert(countingup.LN2 === Math.LN2)
assert(countingup.LN10 === Math.LN10)
assert(countingup.LOG2E === Math.LOG2E)
assert(countingup.LOG10E === Math.LOG10E)

assert(countingup.ZERO === 0)
assert(countingup.NaN !== countingup.NaN)
assert(countingup.POSITIVE_INFINITY === Infinity)
assert(countingup.NEGATIVE_INFINITY === -Infinity)
```

## Tests
Countingup has tests. They are not very comprehensive, because they were generated by AI, but they are tests.

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