{"id":13990094,"url":"https://github.com/fraction/set-timer","last_synced_at":"2025-03-21T08:19:01.338Z","repository":{"id":24493228,"uuid":"27898108","full_name":"fraction/set-timer","owner":"fraction","description":"A lightweight abstraction for the JavaScript Timer API.","archived":false,"fork":false,"pushed_at":"2015-11-07T03:15:26.000Z","size":268,"stargazers_count":36,"open_issues_count":0,"forks_count":1,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-03-13T05:13:11.028Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fraction.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-12-12T00:13:59.000Z","updated_at":"2022-08-18T17:45:37.000Z","dependencies_parsed_at":"2022-08-22T09:30:59.672Z","dependency_job_id":null,"html_url":"https://github.com/fraction/set-timer","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fraction%2Fset-timer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fraction%2Fset-timer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fraction%2Fset-timer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fraction%2Fset-timer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fraction","download_url":"https://codeload.github.com/fraction/set-timer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244759953,"owners_count":20505716,"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":[],"created_at":"2024-08-09T13:02:21.722Z","updated_at":"2025-03-21T08:19:01.310Z","avatar_url":"https://github.com/fraction.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"setTimer\n========\n\nA lightweight abstraction for the JavaScript Timer API.\n\n## Installation\n\nInstall setTimer as an [NPM package](https://www.npmjs.org/package/set-timer).\n\n```sh\nnpm install set-timer\n```\n\n## Usage\n\nThe `setTimer` function takes a callback function and an optional options object as arguments.\n\n```javascript\nvar setTimer = require('set-timer');\n\nsetTimer(function() {\n  console.log(\"I'm called immediately!\");\n});\n```\n\nThe options are:\n\n* **Timeout:** Number of milliseconds to wait before the first call (default: `0`).\n* **Limit:** Number of times to call callback (default: `1`). Use `Infinity` to call indefinitely.\n* **Interval:** Number of milliseconds to wait between calls (default: `0`). Ignored unless `limit \u003e 1`.\n* **onClear:** Function to call after timer has been cleared (default: `Function.prototype`).\n\n```javascript\nvar setTimer = require('set-timer');\n\nvar timer = setTimer(function () {\n  console.log(\"I've been called \" + this.calls + \" times!\");\n}, {\n  timeout:  5000,         // Wait 5 seconds before first call.\n  limit: 10,              // Call callback 10 times.\n  interval: 1000,         // Wait 1 second between calls.\n  onClear: function () {  // Call after timer is cleared.\n    console.log(\"Cleared!\");\n  }\n});\n```\n\nTimers are automatically cleared after their call count reaches `options.limit`, but you can clear the timer manually `this.clear()` from inside of scope the callback or `timer.clear()` in the scope of the timer.\n\n## Support\n\nPlease [open an issue](https://github.com/fraction/set-timer/issues/new) for questions and concerns.\n\n## Contributing\n\nFork the project, commit your changes, and [open a pull request](https://github.com/fraction/set-timer/compare/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffraction%2Fset-timer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffraction%2Fset-timer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffraction%2Fset-timer/lists"}