{"id":19009109,"url":"https://github.com/gamtiq/chronoman","last_synced_at":"2025-04-22T22:46:28.684Z","repository":{"id":10004696,"uuid":"12039618","full_name":"gamtiq/chronoman","owner":"gamtiq","description":"Utility class to simplify use of timers created by setTimeout","archived":false,"fork":false,"pushed_at":"2020-05-06T20:05:46.000Z","size":2187,"stargazers_count":15,"open_issues_count":3,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-13T06:16:35.225Z","etag":null,"topics":["action","chrono","control","execute","interval","manage","management","period","periodic","recurrent","repeat","repeater","repeating","run","setinterval","settimeout","time","timeout","timer","utility"],"latest_commit_sha":null,"homepage":"https://gamtiq.github.io/chronoman/","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/gamtiq.png","metadata":{"files":{"readme":"README.md","changelog":"History.md","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":"2013-08-11T17:32:28.000Z","updated_at":"2022-05-15T03:19:13.000Z","dependencies_parsed_at":"2022-08-30T16:11:24.995Z","dependency_job_id":null,"html_url":"https://github.com/gamtiq/chronoman","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gamtiq%2Fchronoman","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gamtiq%2Fchronoman/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gamtiq%2Fchronoman/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gamtiq%2Fchronoman/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gamtiq","download_url":"https://codeload.github.com/gamtiq/chronoman/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250337910,"owners_count":21414102,"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":["action","chrono","control","execute","interval","manage","management","period","periodic","recurrent","repeat","repeater","repeating","run","setinterval","settimeout","time","timeout","timer","utility"],"created_at":"2024-11-08T19:06:37.503Z","updated_at":"2025-04-22T22:46:28.667Z","avatar_url":"https://github.com/gamtiq.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# chronoman\n\n[![NPM version](https://badge.fury.io/js/chronoman.png)](http://badge.fury.io/js/chronoman)\n[![Build Status](https://secure.travis-ci.org/gamtiq/chronoman.png?branch=master)](http://travis-ci.org/gamtiq/chronoman)\n[![Built with Grunt](https://gruntjs.com/cdn/builtwith.png)](http://gruntjs.com/)\n\nUtility class to simplify use of timers created by `setTimeout`.\n\n### Features\n\n* Support for one-time (like `setTimeout`) or recurrent (like `setInterval`) timers.\n* It is possible to repeat action indefinitely (`recurrent` property),\n  specified number of times (`repeatQty` property) or depending on\n  result of control function (`repeatTest` property).\n* Time period (timeout) can be: a fixed value, a random value, an item selected from a list\n  depending on action's execution number, or a value returned from specified function.\n* Action that is called can be a function or an object specifying function and its call's context.\n* Action result is saved in timer's field for further access.\n* Timer's start time, stop time and action execution times are saved in\n  `startTime`, `stopTime` and `executeTime` properties correspondingly.\n\n```js\nvar timer = new Timer({\n    period: [100, 200, 300, 400, 500, {start: 100, end: 500}],\n    repeatQty: 100,\n    passToAction: true,\n    action: function(tmr) {\n        console.log(\"#\", tmr.getExecutionQty() + 1, \":\", new Date());\n    },\n    active: true\n});\n...\ntimer.stop();\n```\n\n## Installation\n\n### Node\n\n    npm install chronoman\n\n### [Bower](https://bower.io)\n\n    bower install chronoman\n\n### AMD, \u0026lt;script\u0026gt;\n\nUse `dist/chronoman.js` or `dist/chronoman.min.js` (minified version).\n\n## Usage\n\n### ECMAScript 6/2015\n\n```js\nimport Timer from \"chronoman\";\n```\n\n### Node\n\n```js\nvar Timer = require(\"chronoman\").Timer;\n```\n\n### AMD\n\n```js\ndefine([\"path/to/dist/chronoman.js\"], function(chronoman) {\n    var Timer = chronoman.Timer;\n    ...\n});\n```\n\n### Bower, \u0026lt;script\u0026gt;\n\n```html\n\u003c!-- Use bower_components/chronoman/dist/chronoman.js if the library was installed by Bower --\u003e\n\u003cscript type=\"text/javascript\" src=\"path/to/dist/chronoman.js\"\u003e\u003c/script\u003e\n\u003cscript type=\"text/javascript\"\u003e\n    // сhronoman is available via Chronoman field of window object\n    var Timer = Chronoman.Timer;\n    ...\n\u003c/script\u003e\n```\n\n### Example\n\n```js\nvar tmrOne = new Timer({\n    period: function(timer) {\n        return 1000 + (timer.getExecutionQty() * 100);\n    },\n    action: function(timer) {\n        console.log(\"---\u003e Timer one. \", timer);\n        if (! tmrThree.isActive()) {\n            tmrThree.start();\n        }\n    }\n});\n\nvar tmrTwo = new Timer();\ntmrTwo.setPeriod([2000, {start: 1000, end: 1500}])\n    .setRepeatQty(9)\n    .setPassToAction(true)\n    .setAction({\n        i: 0,\n        execute: function(timer) {\n            var nI = ++this.i;\n            console.log(\"Timer two. #\", nI, timer);\n            tmrOne.setActive(nI % 2 === 1);\n        }\n    });\n\nvar tmrThree = new Timer()\n                    .setPeriod(3000)\n                    .setRepeatTest(function() {\n                        return tmrTwo.isActive();\n                    });\ntmrThree.onExecute = function() {\n    console.log(\"* Timer three. #\", this.getExecutionQty() + 1);\n};\n\ntmrTwo.start();\n```\n\nSee `test/chronoman.js` for additional examples.\n\n\n## API\n\nSee [`docs`](https://gamtiq.github.io/chronoman/).\n\n## Related projects\n\n* [NumGen](https://github.com/gamtiq/numgen)\n* [povtor](https://github.com/gamtiq/povtor)\n\n## Inspiration\n\nThis module is inspired by [qooxdoo](http://qooxdoo.org)'s `qx.event.Timer` class.\n\n## Licence\n\nCopyright (c) 2013-2020 Denis Sikuler  \nLicensed under the MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgamtiq%2Fchronoman","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgamtiq%2Fchronoman","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgamtiq%2Fchronoman/lists"}