{"id":41830443,"url":"https://github.com/cafjs/caf_delay","last_synced_at":"2026-01-25T08:36:40.639Z","repository":{"id":57192664,"uuid":"457968377","full_name":"cafjs/caf_delay","owner":"cafjs","description":"Library to delay the invocation of CA methods","archived":false,"fork":false,"pushed_at":"2023-04-18T22:34:06.000Z","size":28,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-08-08T22:51:23.038Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cafjs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE-2.0.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-02-10T22:29:20.000Z","updated_at":"2022-02-10T22:30:15.000Z","dependencies_parsed_at":"2023-01-23T17:16:30.930Z","dependency_job_id":null,"html_url":"https://github.com/cafjs/caf_delay","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/cafjs/caf_delay","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cafjs%2Fcaf_delay","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cafjs%2Fcaf_delay/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cafjs%2Fcaf_delay/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cafjs%2Fcaf_delay/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cafjs","download_url":"https://codeload.github.com/cafjs/caf_delay/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cafjs%2Fcaf_delay/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28749604,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-25T08:31:04.260Z","status":"ssl_error","status_checked_at":"2026-01-25T08:30:28.859Z","response_time":113,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":"2026-01-25T08:36:39.617Z","updated_at":"2026-01-25T08:36:40.627Z","avatar_url":"https://github.com/cafjs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Caf.js\n\nCo-design cloud assistants with your web app and IoT devices.\n\nSee https://www.cafjs.com\n\n## Caf.js library to delay method invocation\n\n[![Build Status](https://github.com/cafjs/caf_delay/actions/workflows/push.yml/badge.svg)](https://github.com/cafjs/caf_delay/actions/workflows/push.yml)\n\nQueues methods to be executed some time in the future.\n\nSets periodic method invocations that could continue until cancelled, or when they reach a fixed number of completions.\n\n## API\n\nSee {@link module:caf_delay/proxy_delay}.\n\nAn example that calls the method `__ca_increment__` periodically (just for `nTimes`).\n\n```\nexports.methods = {\n    ...\n    async scheduleRepeat(delay, delta, interval, nTimes) {\n        const repeater = this.$.delay.newRepeater(interval, nTimes);\n        const id = this.$.delay.scheduleWithOffset(\n            delay, '__ca_increment__', [delta], repeater, true\n        );\n        return [null, id];\n    },\n    async cancel(id) {\n        this.$.delay.cancel(id);\n        return this.getState();\n    },\n    async getPending() {\n        return [null, this.$.delay.getPending()];\n    }\n    async __ca_increment__(delta, id) {\n        this.$.log.debug(`inc delta:${delta} id:${id}`);\n        this.state.counter = this.state.counter + delta;\n        return [];\n    },\n    ...\n```\n\nThe arguments `delay` and `interval` are in seconds, and they represent the time before the first `__ca_increment__()` invocation, and the time between invocations after that. Instead of a time offset, we can also trigger actions with UTC time with  `schedule()`.\n\nThe last `true` argument to `scheduleWithOffset()` ensures that an id identifying the scheduled task is the last argument to `__ca_increment__`. This id was also returned by `scheduleWithOffset()`, and can be used to cancel pending actions.\n\nTo query the status of scheduled actions for this CA use `getPending()`.\n\nThere are no guarantees that methods execute exactly the required number of times, or timely. Really late tasks can be ignored by setting `ignoreAfterInSec` (defaults to 24 hours), otherwise they will eventually execute at least once.\n\nThe internal cron checks for ready tasks every `delayIntervalCheckInSec`, and this defaults to once a second, setting a practical minimum for time resolution.\n\n## Configuration\n\n### framework.json\n\nSee {@link module:caf_delay/plug_delay}\n\n### ca.json\n\nSee {@link module:caf_delay/plug_ca_delay}\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcafjs%2Fcaf_delay","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcafjs%2Fcaf_delay","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcafjs%2Fcaf_delay/lists"}