{"id":16760478,"url":"https://github.com/ryanve/often","last_synced_at":"2025-07-25T17:38:55.041Z","repository":{"id":57313766,"uuid":"69532979","full_name":"ryanve/often","owner":"ryanve","description":"Async recursive JavaScript timers","archived":false,"fork":false,"pushed_at":"2016-10-25T02:12:13.000Z","size":8,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-15T21:51:22.844Z","etag":null,"topics":["async-recursive-timers","javascript","timers"],"latest_commit_sha":null,"homepage":"https://npm.im/often","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ryanve.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":"2016-09-29T05:13:00.000Z","updated_at":"2024-02-04T22:55:09.000Z","dependencies_parsed_at":"2022-09-20T23:20:36.573Z","dependency_job_id":null,"html_url":"https://github.com/ryanve/often","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanve%2Foften","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanve%2Foften/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanve%2Foften/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanve%2Foften/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ryanve","download_url":"https://codeload.github.com/ryanve/often/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243847056,"owners_count":20357317,"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":["async-recursive-timers","javascript","timers"],"created_at":"2024-10-13T04:23:38.868Z","updated_at":"2025-03-16T09:17:04.323Z","avatar_url":"https://github.com/ryanve.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# often\nAsync recursive timers\n\n```sh\nnpm install often --save\n```\n\n```sh\nvar often = require('often')\n```\n\n## API\n### `often(fn=undefined)`\n- Get an `often` instance with `fn` as recursion function\n- All methods are chainable\n\n### `.wait(ms=0)`\nSet interval to wait between recursions\n\n### `.start(ms=0)`\nStart recursing after optional ms delay\n\n### `.stop()`\nImmediately stop recursing\n\n### `.done()`\nImmediately stop recursing and void instance\n\n### `.use(fn=undefined)`\nReplace the recursion function\n\n### `.clear()` **internal**\nClear active timer\n\n### `.clean()` **internal**\nNullify [properties](#properties)\n\n### `.init(fn=undefined)` **internal**\nInitialize instance\n\n### Properties\n- `._function`: `fn`|null\n- `._recur`: boolean|null\n- `._timer`: integer|null\n- `._trial`: integer|null\n- `._wait`: `ms`|null\n\n## Examples\n### Poll condition\n```js\nvar often = require('often')\n\noften(function() {\n  console.log(new Date)\n  if ('someCondition') {\n    this.done()\n  }\n}).wait(1000).start()\n```\n\n### Limit attempts\n```js\nvar often = require('often')\n\noften(function() {\n  console.info(this)\n  if (this._trial === 3) {\n    this.stop()\n    console.warn(this)\n  }\n}).start(1000).wait(200)\n```\n\n### Decay task\n```js\nvar often = require('often')\n\noften(function() {\n  if ('Not Ready Yet') {\n    this.wait(1000 + this._wait)\n    console.info('Slowing down')\n  } else {\n    console.info('Ready!')\n  }\n}).start()\n```\n\n### Heartbeat\n```js\nvar often = require('often')\nvar energy = require('energy')\nvar emitter = energy()\nvar heartbeat = often(function() {\n  emitter.emit('heartbeat')\n}).wait(1000).start()\n\nemitter.on('heartbeat', function() {\n  console.log('I run every second')\n})\n```\n\n## Develop\n```sh\ngit clone https://github.com/ryanve/often.git\ncd often\nnpm install\nnpm test\n```\n\n## License\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryanve%2Foften","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fryanve%2Foften","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryanve%2Foften/lists"}