{"id":18152224,"url":"https://github.com/bsdelf/recron","last_synced_at":"2025-04-30T08:23:13.905Z","repository":{"id":35689763,"uuid":"218428229","full_name":"bsdelf/recron","owner":"bsdelf","description":"Simple, intuitive and readable cron implementaiton","archived":false,"fork":false,"pushed_at":"2025-03-03T10:56:29.000Z","size":501,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-30T14:22:08.110Z","etag":null,"topics":["cron","cronjob","crontab","interval","periodic","timer","timezone","typescript"],"latest_commit_sha":null,"homepage":"","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/bsdelf.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-10-30T02:38:44.000Z","updated_at":"2025-03-03T10:56:32.000Z","dependencies_parsed_at":"2024-05-09T09:46:34.286Z","dependency_job_id":"afeb0acc-d99b-49cb-b6ca-a1e55eb44f5f","html_url":"https://github.com/bsdelf/recron","commit_stats":{"total_commits":43,"total_committers":2,"mean_commits":21.5,"dds":"0.023255813953488413","last_synced_commit":"581c6f6fda3ae2637bf3f5b3a8f4d6e0edf52a4f"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bsdelf%2Frecron","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bsdelf%2Frecron/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bsdelf%2Frecron/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bsdelf%2Frecron/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bsdelf","download_url":"https://codeload.github.com/bsdelf/recron/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251667058,"owners_count":21624426,"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":["cron","cronjob","crontab","interval","periodic","timer","timezone","typescript"],"created_at":"2024-11-02T02:06:04.848Z","updated_at":"2025-04-30T08:23:13.886Z","avatar_url":"https://github.com/bsdelf.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Recron\n\n![CI status](https://github.com/bsdelf/recron/workflows/CI/badge.svg)\n\nRecron is a simple, intuitive and readable cron implementaiton written in TypeScript and suitable for Node.js and browser usage.\n\n## Highlights\n\n- Object oriented design.\n- Support update schedule on the fly.\n- Support both crontab and interval syntax.\n- Support different time zones in a single cron instance.\n- Tickless scheduler (will be optional in future).\n- Compact and quite readable code base written in TypeScript.\n\n## Usage\n\n```typescript\nimport { Cron } from 'recron';\n\nconst cron = new Cron();\n\n// Start cron scheduler.\ncron.start();\n\n// Use interval syntax.\ncron.schedule('@every 1s', () =\u003e {\n  console.log('every second', new Date());\n});\n\n// Use crontab syntax.\ncron.schedule('*/5 * * * * *', () =\u003e {\n  console.log('at 5th second', new Date());\n});\n\n// Stop cron after 10 seconds.\ncron.schedule(\n  '@every 10s',\n  () =\u003e {\n    cron.stop();\n    console.log('done', new Date());\n  },\n  { oneshot: true }\n);\n```\n\n## Time zone\n\nThe constructor of `Cron` has an optional parameter to let you set time zone.\nIf the `timezone` parameter is unspecified, the default time zone will be detected from [`Intl.DateTimeFormat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/resolvedOptions), it will be your local time zone in general.\n\nAlso, the last parameter of `schedule()` method `options` has an optional `timezone` property,\nwhich can be used to override the default time zone for individual schedule.\n\nNote: time zone only affects crontab, it does not affect the interval usage.\n\n## Reentrant\n\nUnlike other cron implementations,\nreentrant is not allowd in `recron` by default for both safety and convenient.\nTherefore, if the scheduled callback function takes a lot of time to process, it will underrun.\nFor example, given following piece of code:\n\n```typescript\nconst sleep = (ms: number) =\u003e new Promise((resolve) =\u003e setTimeout(resolve, ms));\n\ncron.schedule('@every 1s', async () =\u003e {\n  console.log('overslept', new Date());\n  await sleep(3000);\n});\n```\n\nthe output will be:\n\n```\noverslept 2019-10-31T05:05:27.251Z\noverslept 2019-10-31T05:05:30.253Z\noverslept 2019-10-31T05:05:34.254Z\noverslept 2019-10-31T05:05:37.263Z\noverslept 2019-10-31T05:05:40.275Z\n```\n\nTo disable this feature, set `reentrant` to `true` in options.\nBut be careful, if the providered callback function keeps underrun,\ndue to the unresolved promises,\nthe memory consumption will be increasing,\nand eventually you program will run out-of-memory.\n\n## Crontab Alias\n\n`recron` has following crontab aliases:\n\n| Alias    | Crontab       |\n| -------- | ------------- |\n| @hourly  | 0 \\* \\* \\* \\* |\n| @daily   | 0 0 \\* \\* \\*  |\n| @weekly  | 0 0 \\* \\* 1   |\n| @monthly | 0 0 1 \\* \\*   |\n\nNote: we regard Monday as the first day of the week according to international standard ISO 8601. So `@weekly` means \"at 00:00 on Monday\", not Sunday.\n\n## Interval Syntax\n\nInterval syntax has following specifiers:\n\n| Order | Specifier | Unit        |\n| ----- | --------- | ----------- |\n| 1     | h         | hour        |\n| 2     | m         | minute      |\n| 3     | s         | second      |\n| 4     | ms        | Millisecond |\n\nOne ore more specifiers can be used, as long as they are arranged in ascending order:\n\n- `@every 10s`\n- `@every 30m`\n- `@every 1h30m`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbsdelf%2Frecron","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbsdelf%2Frecron","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbsdelf%2Frecron/lists"}