{"id":19605134,"url":"https://github.com/a7ul/seekable-timer","last_synced_at":"2025-07-19T23:34:04.910Z","repository":{"id":75754783,"uuid":"117114476","full_name":"a7ul/seekable-timer","owner":"a7ul","description":"A pure Javascript timer with support for seeking.","archived":false,"fork":false,"pushed_at":"2018-01-11T14:59:01.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-23T14:16:51.178Z","etag":null,"topics":["javascript","javascript-library","openlibrary","seek","setinterval","timer"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/a7ul.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-01-11T14:55:05.000Z","updated_at":"2018-01-13T05:34:22.000Z","dependencies_parsed_at":"2023-05-19T08:30:39.260Z","dependency_job_id":null,"html_url":"https://github.com/a7ul/seekable-timer","commit_stats":null,"previous_names":["master-atul/seekable-timer"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/a7ul/seekable-timer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a7ul%2Fseekable-timer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a7ul%2Fseekable-timer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a7ul%2Fseekable-timer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a7ul%2Fseekable-timer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/a7ul","download_url":"https://codeload.github.com/a7ul/seekable-timer/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a7ul%2Fseekable-timer/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266041698,"owners_count":23867944,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","javascript-library","openlibrary","seek","setinterval","timer"],"created_at":"2024-11-11T09:41:19.278Z","updated_at":"2025-07-19T23:34:04.889Z","avatar_url":"https://github.com/a7ul.png","language":"JavaScript","readme":"# Seekable Timer\n\nA pure Javascript timer with support for seeking.\n\nWorks on browser(webpack), electron and node.\n\n## Installation\n```\n yarn add seekable-timer\n```\nor\n```\n npm install --save seekable-timer\n```\n\n## Usage\nA basic example:\n\n```\nconst Timer = require('seekable-timer');\n\nconst timer = new Timer(1000); // This will give a new timer instance with 1000ms step\n\ntimer.setOnTickHandler((timeOffset)=\u003e{\n  console.log(timeOffset, 'ms');\n  if(timeOffset \u003e 15000){ //once timer has passed 15secs since starting\n    timer.stop(); //stops the timer\n  }\n});\n\ntimer.start(); //starts the timer\n```\n\n\nFunctions:\n\n- `timer.start()` - starts or resumes a paused timer. No return value. Here onStartHandler is called.\n- `timer.stop()` - stops the timer. returns the total duration in milliseconds for which the timer ran. Here onStopHandler is called.\n- `timer.pause()` - pauses the timer. returns the current time offset from starting. Here onPauseHandler is called.\nDifference between stop and pause is that pause will not reset the timer offset whereas stop will reset the timer itself.\n- `timer.seekBy(milliseconds)` = seeks the timers by the amount of milliseconds passed. You can pass a positive value to seek to future. Or you can pass a negative value to seek to past.\n\n- \n```\ntimer.setOnTickHandler((timeoffset)=\u003e {\n\n  })\n```\nsets an on onTickHandler that is called on every tick you specified on the initialisation of timer.\n\n- \n```\ntimer.setOnStartHandler((timeoffset)=\u003e {\n\n  })\n```\nsets an on onStartHandler that is called on `timer.start()` of timer.\n\n- \n```\ntimer.setOnPauseHandler((timeoffset)=\u003e {\n    // timeOffset is calculated from the time when we did start.\n  })\n```\n- \n```\ntimer.setOnStopHandler((timeoffset)=\u003e {\n    // timeOffset is calculated from the time when we did start.\n  })\n```\n- \n```\ntimer.setOnSeekHandler((seekedMilliseconds)=\u003e {\n\n  })\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fa7ul%2Fseekable-timer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fa7ul%2Fseekable-timer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fa7ul%2Fseekable-timer/lists"}