{"id":19880983,"url":"https://github.com/ckaznable/shared-tick","last_synced_at":"2025-03-01T02:46:08.333Z","repository":{"id":65185275,"uuid":"586147116","full_name":"ckaznable/shared-tick","owner":"ckaznable","description":"Run function in same setInterval","archived":false,"fork":false,"pushed_at":"2023-01-09T02:35:13.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-12T08:13:48.694Z","etag":null,"topics":["no-dependencies","setinterval","setinterval-timer","tick","typescript","typescript-library","vanilla-js"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/shared-tick","language":"TypeScript","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/ckaznable.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":"2023-01-07T05:09:04.000Z","updated_at":"2023-03-17T13:37:31.000Z","dependencies_parsed_at":"2023-02-08T08:30:37.444Z","dependency_job_id":null,"html_url":"https://github.com/ckaznable/shared-tick","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ckaznable%2Fshared-tick","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ckaznable%2Fshared-tick/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ckaznable%2Fshared-tick/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ckaznable%2Fshared-tick/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ckaznable","download_url":"https://codeload.github.com/ckaznable/shared-tick/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241309105,"owners_count":19941725,"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":["no-dependencies","setinterval","setinterval-timer","tick","typescript","typescript-library","vanilla-js"],"created_at":"2024-11-12T17:12:56.710Z","updated_at":"2025-03-01T02:46:08.315Z","avatar_url":"https://github.com/ckaznable.png","language":"TypeScript","readme":"[![npm version](https://img.shields.io/npm/v/shared-tick?color=g)](https://www.npmjs.com/package/shared-tick)\n\n# SharedTick.js\n\nRun function in same `setInterval`\n\n## Installation\n\nuse npm\n```\nnpm install shared-tick --save\n```\n\nuse yarn\n```\nyarn add shared-tick\n```\n\nuse pnpm\n```\npnpm install shared-tick\n```\n\n## Framework\n\n|Framework|Repository|\n|:---|:---:|\n| Vue 3 | [vue-use-shared-tick](https://github.com/ckaznable/vue-use-shared-tick) |\n| React | [react-use-shared-tick](https://github.com/ckaznable/react-use-shared-tick) |\n\n## Usage\n\nrun function per second\n\n```js\nimport { runTick } from 'shared-tick'\n\nconst onTick = () =\u003e {\n  // do something per second\n}\n\nrunTick({onTick})\n```\n\nrun function per 3 second\n\n```js\nimport { runTick } from 'shared-tick'\n\nconst onTick = () =\u003e {\n  // do something per second\n}\n\nrunTick({onTick, tick: 3000})\n```\n\nstop runner\n\n```js\nimport { stopTickRunner, runTick } from \"shared-tick\"\n\nconst id = runTick({...})\nstopTickRunner(id)\n```\n\nrestart runner\n\n```js\nimport { stopTickRunner, startTickRunner, runTick } from \"shared-tick\"\n\nconst id = runTick({...})\nstopTickRunner(id)\n\n// restart runner after 5sec\nsetTimeout(() =\u003e startTickRunner(id), 5000)\n```\n\n## API\n\n### runTick\n\n```js\nrunTick(config)\n```\n\n### Parameter\n\n| Field | Type | Default | Requirement |Description |\n|---|:---:|---|---|---|\n| tick | `number` | `1000` | `No` | Running interval time |\n| id |`symbol`| `Symbol()` | `No` | Identifying objects |\n| onTick | `(t: number) =\u003e void` | `No` | `Yes` | Runner function, The first parameter is the current timestamp |\n\n### stopTickRunner\n\n```js\nstopTickRunner(id: symbol)\n```\n\n### stopTickRunner\n\n```js\nstartTickRunner(id: symbol)\n```\n\n\n## License\nThe files included in this repository are licensed under the MIT license.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fckaznable%2Fshared-tick","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fckaznable%2Fshared-tick","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fckaznable%2Fshared-tick/lists"}