Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 0 additions & 56 deletions .github/workflows/build.yml

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ jobs:
key: pnpm-store-${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml')}}
restore-keys: |
pnpm-store-${{ runner.os }}-
- name: Build
run: pnpm run build
- name: 'Test'
run: pnpm run test
- name: Report vitest coverage
if: always()
uses: davelosert/vitest-coverage-report-action@v2
- name: Lint
run: pnpm run lint
- name: Codecov
uses: codecov/codecov-action@v5
with:
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ coverage
*.njsproj
*.sln
*.sw?
.temp
.temp
.npmrc
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# CHANGELOG

## [2.0.1] 01-23-2026

**This patch is a cleanup patch as the project is considered "done"**

### :rocket: Performance

- Shortened logic
- Reduced number of function calls

### :bug: Fixed

- missing optional argument in `off` type declaration.

### :shit: Removed

- Unnecessary CI and dev dependencies to make the download size of `package.json` smaller.

## [2.0.0] 01-22-2026

### :boom: Breaking
Expand Down
19 changes: 13 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</p>
</p>

`mini-timer` is the smallest event driven timer without any dependencies that quickly and comfortably counts time for you.
`mini-timer` is a tiny (570 bytes gzipped) event driven timer without any dependencies that quickly and comfortably counts time for you.

```powershell
pnpm i mini-timer
Expand All @@ -26,14 +26,21 @@ The goal of this package is to provide the smallest possible timer package that
## Usage

The timer requires 2 (optional 3) arguments that define the start and end point with the increment between steps.
The increment define also how long each time iteration is to count. The sign of the increment defines if the timer
counter up (+) or down (-).
The increment also defines how long each time iteration is per update. The sign of the increment defines whether the timer
counts up (+) or down (-).

```typescript
import timer, { type Timer } from 'mini-timer'

// Standard timer: From 0, count ever 1000ms (1s) indefinitely
const t = timer(0, 1000)

// Standard countdown: From 10s count every second to 0
const t = timer(10_000, -1000, 0)

// From 0, count every 100ms until 10,000ms
const t = timer(0, 100, 10000)

```

### Events
Expand All @@ -51,12 +58,12 @@ t.on('pause', () => console.log("Pause"))
t.on('finish', (elapsed) => console.log("Preemptively finished at", elapsed))

t.start()
// Do stuff for a long time
// <code>
t.pause()
// Again...
// <code>
t.resume()

// The timer will stop when it reaches 0, but we can stop it preemptively
// The timer will stop when it reaches to (0), but we can stop it preemptively
t.stop() // The default event of stop is "finish".

// Now, clean everything up with "off"
Expand Down
31 changes: 0 additions & 31 deletions esbuild.config.js

This file was deleted.

13 changes: 0 additions & 13 deletions eslint.config.ts

This file was deleted.

5 changes: 3 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,12 @@ declare module 'mini-timer' {
events: Map<TimerEvent, Set<TimerListener>>
/**
* Removes an event handler for a specific timer event.
* Removes all event handlers if no handler is specified.
*
* @param event - The timer event to stop listening for.
* @param handler - The handler function to remove.
* @param handler - (optional) The handler function to remove.
*/
off: (event: TimerEvent, handler: TimerListener) => void
off: (event: TimerEvent, handler?: TimerListener) => void
/**
* Registers an event handler for a specific timer event.
*
Expand Down
13 changes: 3 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mini-timer",
"version": "2.0.0",
"version": "2.0.1",
"description": "The tiniest timer to tick!",
"types": "./index.d.ts",
"main": "./dist/index.js",
Expand All @@ -13,7 +13,7 @@
}
},
"scripts": {
"build": "node esbuild.config.js",
"build": "tsdown",
"lint": "eslint src --fix",
"format": "npx prettier --write */**.ts",
"test": "vitest"
Expand All @@ -39,15 +39,8 @@
"sideEffects": false,
"packageManager": "pnpm@10.28.1",
"devDependencies": {
"@size-limit/file": "^12.0.0",
"@size-limit/preset-app": "^12.0.0",
"@vitest/coverage-v8": "^4.0.18",
"esbuild": "^0.27.2",
"eslint": "^9.39.2",
"eslint-config-shiny": "^4.3.1",
"jiti": "^2.6.1",
"size-limit": "^12.0.0",
"typescript": "^5.9.3",
"tsdown": "^0.20.1",
"vite": "^7.3.1",
"vitest": "^4.0.18"
}
Expand Down
Loading