{"id":15683631,"url":"https://github.com/doowb/alarm","last_synced_at":"2025-05-07T13:46:43.455Z","repository":{"id":57175438,"uuid":"90064490","full_name":"doowb/alarm","owner":"doowb","description":"Set an alarm that will call the given function at the specified time.","archived":false,"fork":false,"pushed_at":"2017-05-11T03:15:28.000Z","size":11,"stargazers_count":10,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-27T21:37:40.548Z","etag":null,"topics":["nexttick","schedule","scheduler","setimmediate","settimeout","timeout","timer"],"latest_commit_sha":null,"homepage":"https://doowb.com","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/doowb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/contributing.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-05-02T18:20:46.000Z","updated_at":"2021-04-12T21:58:49.000Z","dependencies_parsed_at":"2022-09-03T11:01:07.446Z","dependency_job_id":null,"html_url":"https://github.com/doowb/alarm","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doowb%2Falarm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doowb%2Falarm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doowb%2Falarm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doowb%2Falarm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/doowb","download_url":"https://codeload.github.com/doowb/alarm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252890198,"owners_count":21820338,"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":["nexttick","schedule","scheduler","setimmediate","settimeout","timeout","timer"],"created_at":"2024-10-03T17:07:53.292Z","updated_at":"2025-05-07T13:46:43.429Z","avatar_url":"https://github.com/doowb.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# alarm [![NPM version](https://img.shields.io/npm/v/alarm.svg?style=flat)](https://www.npmjs.com/package/alarm) [![NPM monthly downloads](https://img.shields.io/npm/dm/alarm.svg?style=flat)](https://npmjs.org/package/alarm)  [![NPM total downloads](https://img.shields.io/npm/dt/alarm.svg?style=flat)](https://npmjs.org/package/alarm) [![Linux Build Status](https://img.shields.io/travis/doowb/alarm.svg?style=flat\u0026label=Travis)](https://travis-ci.org/doowb/alarm)\n\n\u003e Set an alarm that will call the given function at the specified time.\n\n## Install\n\nInstall with [npm](https://www.npmjs.com/):\n\n```sh\n$ npm install --save alarm\n```\n\nInstall with [yarn](https://yarnpkg.com):\n\n```sh\n$ yarn add alarm\n```\n\n## Usage\n\n```js\nvar alarm = require('alarm');\n```\n\n## API\n\n### [alarm](index.js#L21)\n\nSet an alarm that will execute the provided function at the specified time.\n\n**Params**\n\n* `date` **{Date}**: a Date object or a string that can be passed to the Date constructor.\n* `fn` **{Function}**: Function to execute at the specified time.\n* `returns` **{Function}**: Returns a function that can be called to cancel the alarm.\n\n**Example**\n\n```js\n// 2 seconds from now\nvar now = new Date();\nvar date = new Date(+now + 2000);\nalarm(date, function() {\n  console.log('Hello, world!');\n});\n```\n\n### [.recurring](index.js#L53)\n\nSet a recurring alarm that will execute the provide function even X milliseconds.\n\n**Params**\n\n* `ms` **{Number}**: Number of milliseconds to specify how often to execute the function.\n* `fn` **{Function}**: Function to execute every X milliseconds.\n* `returns` **{Function}**: Returns a function that may be called to cancel the recurring alarm.\n\n**Example**\n\n```js\nvar count = 0;\nvar cancel = alarm.recurring(1000, function() {\n  console.log((count++) + ' BEEP BEEP BEEP!');\n  if (count \u003e= 5) {\n    cancel();\n  }\n});\n```\n\n## About\n\n### Contributing\n\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).\n\nPlease read the [contributing guide](.github/contributing.md) for advice on opening issues, pull requests, and coding standards.\n\n### Building docs\n\n_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_\n\nTo generate the readme, run the following command:\n\n```sh\n$ npm install -g verbose/verb#dev verb-generate-readme \u0026\u0026 verb\n```\n\n### Running tests\n\nRunning and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:\n\n```sh\n$ npm install \u0026\u0026 npm test\n```\n\n### Author\n\n**Brian Woodward**\n\n* [github/doowb](https://github.com/doowb)\n* [twitter/doowb](https://twitter.com/doowb)\n\n### License\n\nCopyright © 2017, [Brian Woodward](https://doowb.com).\nReleased under the [MIT License](LICENSE).\n\n***\n\n_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on May 10, 2017._","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoowb%2Falarm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdoowb%2Falarm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoowb%2Falarm/lists"}