{"id":13521412,"url":"https://github.com/rwaldron/temporal","last_synced_at":"2025-07-06T16:02:14.998Z","repository":{"id":5280194,"uuid":"6459417","full_name":"rwaldron/temporal","owner":"rwaldron","description":"Non-blocking, temporal task sequencing. For use with robots built with Johnny-Five","archived":false,"fork":false,"pushed_at":"2021-08-15T19:46:49.000Z","size":114,"stargazers_count":84,"open_issues_count":3,"forks_count":12,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-01-10T11:49:44.750Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://johnny-five.io/","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/rwaldron.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-MIT","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-10-30T15:20:07.000Z","updated_at":"2024-01-29T11:15:25.000Z","dependencies_parsed_at":"2022-07-04T20:31:47.268Z","dependency_job_id":null,"html_url":"https://github.com/rwaldron/temporal","commit_stats":null,"previous_names":["rwldrn/temporal"],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rwaldron%2Ftemporal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rwaldron%2Ftemporal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rwaldron%2Ftemporal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rwaldron%2Ftemporal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rwaldron","download_url":"https://codeload.github.com/rwaldron/temporal/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234878692,"owners_count":18900684,"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-01T06:00:34.091Z","updated_at":"2025-01-21T01:18:21.406Z","avatar_url":"https://github.com/rwaldron.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","Libraries and Plugins"],"sub_categories":["Robot Programming Plugins"],"readme":"# temporal\n\n\n[![Build Status](https://travis-ci.org/rwaldron/temporal.svg)](https://travis-ci.org/rwaldron/temporal)\n\nNon-blocking, temporal task sequencing. `temporal` does NOT use `setTimeout` or `setInterval`, however there is a cost for using \"recursive\" `setImmediate` to create an extremely fast, async execution loop. CPU usage is expected to peak when using `temporal`, because the internal ticker needs to execute as fast as possible and as many times per second as possible. It's this speed that allows `temporal` to review the internal schedule for tasks to execute more than once per millisecond, which is needed to create preferential execution cycles for hardware programming. \n\n`temporal` is for writing timing sensitive programs that are expected to be the primary process running on a given system, where the power source itself is tuned to accommodate _that program_ specifically. Concrete examples include: \n\n- walking robots (autonomous and remote control bipeds, quadrupeds or hexapods)\n- driving robots (autonomous and remote control rovers)\n- flying robots (autonomous and remote control single and multi-rotor helicopter)\n- water based robots (underwater rovs, surface boat-likes)\n\n`temporal` allows for sub-millisecond task scheduling through us of the resolution method. \n\n`temporal` is not good for sparse task scheduling. \n\n\n## Presentations\n\n- [EmpireJS](https://dl.dropboxusercontent.com/u/3531958/empirejs/index.html)\n- [CascadiaJS](https://dl.dropboxusercontent.com/u/3531958/cascadiajs/index.html)\n\n\n\n\n## Getting Started\n\n```bash\nnpm install temporal\n```\n\n\n## Examples\n\n```javascript\nvar temporal = require(\"temporal\");\n\ntemporal.on(\"idle\", function() {\n  console.log(\"Temporal is idle\");  \n});\n\n// Wait 500 milliseconds, execute a task\ntemporal.delay(500, function() {\n\n  console.log(\"500ms later...\");\n\n});\n\n// Loop every n milliseconds, executing a task each time\ntemporal.loop(500, function() {\n\n  console.log(\"Every 500ms...\");\n\n  // |this| is a reference to the temporal instance\n  // use it to cancel the loop by calling:\n  //\n  this.stop();\n\n  // The number of times this loop has been executed:\n  this.called; // number\n\n  // The first argument to the callback is the same as |this|\n});\n\n\n// Queue a sequence of tasks: delay, delay\n// Each delay time is added to the prior delay times.\ntemporal.queue([\n  {\n    delay: 500,\n    task: function() {\n      // Executes 500ms after temporal.queue(...) is called\n    }\n  },\n  {\n    delay: 500,\n    task: function() {\n      // Executes 1000ms after temporal.queue(...) is called\n\n      // The last \"delay\" task will emit an \"ended\" event\n    }\n  }\n]);\n\n// Queue a sequence of tasks: delay then loop\n// Each delay time is added to the prior delay times.\ntemporal.queue([\n  {\n    delay: 500,\n    task: function() {\n      // Executes 500ms after temporal.queue(...) is called\n    }\n  },\n  {\n    loop: 100,\n    task: function() {\n      // Executes 600ms after temporal.queue(...) is called\n\n      // Executes every 100ms thereafter.\n    }\n  }\n]);\n```\n\n```javascript\nvar temporal = require(\"temporal\");\n\ntemporal.on(\"idle\", function() {\n  console.log(\"Temporal is idle\");  \n});\n\n// Set temporal resolution to 0.1ms\ntemporal.resolution(0.1);\n\n// Wait 0.7 milliseconds, execute a task\ntemporal.delay(0.7, function() {\n\n  console.log(\"0.7ms later...\");\n\n});\n```\n\n\n## Contributing\nIn lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [grunt](https://github.com/gruntjs/grunt).\n\n\n## License\nSee LICENSE file.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frwaldron%2Ftemporal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frwaldron%2Ftemporal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frwaldron%2Ftemporal/lists"}