Registry / observability / tiny-tim

tiny-tim

JSON →
library0.0.4jsnpmunverified

A minimal, zero-dependency timer utility for Node.js and the browser. Current stable version 0.0.4 (unreleased release cadence). Tiny-tim provides a simple timer that returns elapsed time in configurable units (ms, s, m, h) with optional suffix. Its key differentiator is extreme small size (156 bytes minified) and simplicity, offering a single function that creates a reusable stopwatch. Compiled with babili for both ES6+ and CommonJS environments. No dependencies, suitable for lightweight instrumentation.

npm install tiny-tim
INSTALL
IMPORT
SIG · TINY-TIM
T
tiny-tim
observabilityjavascriptv0.0.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
✓ import timer from 'tiny-tim'
✗ const timer = require('tiny-tim').default
Default export is a function. ESM import works directly; CommonJS require returns the function itself, not a module with default property.
default
✓ const timer = require('tiny-tim')
✗ import { timer } from 'tiny-tim'
CommonJS require returns the timer function directly. ESM default import matches this pattern.

Creates a reusable timer, demonstrates returning elapsed time with suffix as string and without suffix as number.

import timer from 'tiny-tim'; // Create a timer in seconds with suffix const stopwatch = timer('s', true); setTimeout(() => { const elapsed = stopwatch(); console.log(elapsed); // '10s' }, 10000); // Reuse the same timer setTimeout(() => { console.log(stopwatch()); // '15s' }, 15000); // Create timer in milliseconds without suffix const msTimer = timer(); setTimeout(() => { console.log(msTimer()); // 1000 (number) }, 1000);
Debug
Known issues
gotchaTimer function returns either a string (with suffix) or a number (without suffix). Developers may expect consistent types.
fix
Check the type of the returned value if relying on specific data type.
affects: >=0.0.0
gotchaThe timer is not paused or reset externally; calling the returned function stops the timer and returns the elapsed time. Subsequent calls return the same value (timer dead after first call).
fix
Recreate the timer for a new measurement; cannot restart an existing timer.
affects: >=0.0.0
gotchaUnits are single-letter strings. Using full words like 'seconds' will be treated as unrecognized unit, defaulting to milliseconds silently.
fix
Use only 'ms', 's', 'm', or 'h'.
affects: >=0.0.0
gotchaNo error thrown for invalid units; timer silently defaults to milliseconds.
fix
Validate unit string before passing to timer().
affects: >=0.0.0
Errors
Common errors & fixes
timer is not a function
Importing as named import instead of default import in ESM.
fix
Use 'import timer from "tiny-tim"' instead of 'import { timer } from "tiny-tim"'.
require(...).default is not a function
Trying to access .default on CommonJS require result, which already returns the function.
fix
Use 'const timer = require("tiny-tim")' directly without .default.
Cannot find module 'tiny-tim'
Package not installed or missing from node_modules.
fix
Run 'npm install tiny-tim' in your project root.
Upgrade
Version history
0.0.4latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
25 hits · last 30 days
node
22
OpenAI (training)
1
Resources
tiny-tim — npm install tiny-tim · libregistry