{"id":26481,"library":"tiny-tim","title":"tiny-tim","description":"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.","status":"active","version":"0.0.4","language":"javascript","source_language":"en","source_url":"https://github.com/sdgluck/tiny-tim","tags":["javascript","timer","tiny","profile","stopwatch","stop","watch","tim"],"install":[{"cmd":"npm install tiny-tim","lang":"bash","label":"npm"},{"cmd":"yarn add tiny-tim","lang":"bash","label":"yarn"},{"cmd":"pnpm add tiny-tim","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Default export is a function. ESM import works directly; CommonJS require returns the function itself, not a module with default property.","wrong":"const timer = require('tiny-tim').default","symbol":"default","correct":"import timer from 'tiny-tim'"},{"note":"CommonJS require returns the timer function directly. ESM default import matches this pattern.","wrong":"import { timer } from 'tiny-tim'","symbol":"default","correct":"const timer = require('tiny-tim')"}],"quickstart":{"code":"import timer from 'tiny-tim';\n\n// Create a timer in seconds with suffix\nconst stopwatch = timer('s', true);\n\nsetTimeout(() => {\n  const elapsed = stopwatch();\n  console.log(elapsed); // '10s'\n}, 10000);\n\n// Reuse the same timer\nsetTimeout(() => {\n  console.log(stopwatch()); // '15s'\n}, 15000);\n\n// Create timer in milliseconds without suffix\nconst msTimer = timer();\nsetTimeout(() => {\n  console.log(msTimer()); // 1000 (number)\n}, 1000);","lang":"javascript","description":"Creates a reusable timer, demonstrates returning elapsed time with suffix as string and without suffix as number."},"warnings":[{"fix":"Check the type of the returned value if relying on specific data type.","message":"Timer function returns either a string (with suffix) or a number (without suffix). Developers may expect consistent types.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Recreate the timer for a new measurement; cannot restart an existing timer.","message":"The 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).","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use only 'ms', 's', 'm', or 'h'.","message":"Units are single-letter strings. Using full words like 'seconds' will be treated as unrecognized unit, defaulting to milliseconds silently.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Validate unit string before passing to timer().","message":"No error thrown for invalid units; timer silently defaults to milliseconds.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'0.0.4':19 '156':51 'babili':67 'browser':15 'byte':52 'cadenc':22 'commonj':72 'compil':65 'configur':35 'creat':61 'current':16 'depend':8,75 'differenti':46 'elaps':32 'environ':73 'es6':70 'extrem':48 'function':59 'h':40 'instrument':79 'javascript':80 'key':45 'lightweight':78 'm':39 'minifi':53 'minim':5 'ms':37 'node.js':12 'offer':56 'option':42 'profil':83 'provid':26 'releas':21 'return':31 'reusabl':63 'simpl':28 'simplic':55 'singl':58 'size':50 'small':49 'stabl':17 'stop':85 'stopwatch':64,84 'suffix':43 'suitabl':76 'tim':3,25,87 'time':33 'timer':9,29,81 'tini':2,24,82 'tiny-tim':1,23 'unit':36 'unreleas':20 'util':10 'version':18 'watch':86 'zero':7 'zero-depend':6","created_at":"2026-05-01T13:50:12.304749+00:00","updated_at":"2026-05-01T13:50:12.304749+00:00","problems":[{"fix":"Use 'import timer from \"tiny-tim\"' instead of 'import { timer } from \"tiny-tim\"'.","cause":"Importing as named import instead of default import in ESM.","error":"timer is not a function"},{"fix":"Use 'const timer = require(\"tiny-tim\")' directly without .default.","cause":"Trying to access .default on CommonJS require result, which already returns the function.","error":"require(...).default is not a function"},{"fix":"Run 'npm install tiny-tim' in your project root.","cause":"Package not installed or missing from node_modules.","error":"Cannot find module 'tiny-tim'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/sdgluck/tiny-tim","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/tiny-tim","openapi_spec":null,"status_page":null,"smithery":null,"categories":["observability"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-05-01","next_check":"2026-07-30","install_tag":null}}