{"id":15311547,"url":"https://github.com/bjornstar/timed-number","last_synced_at":"2025-10-08T20:31:59.855Z","repository":{"id":11859582,"uuid":"14418522","full_name":"bjornstar/timed-number","owner":"bjornstar","description":null,"archived":false,"fork":true,"pushed_at":"2014-07-16T08:44:22.000Z","size":319,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-02T08:33:57.459Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"Wizcorp/timed-number","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bjornstar.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-11-15T08:06:07.000Z","updated_at":"2014-07-16T08:39:26.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/bjornstar/timed-number","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bjornstar%2Ftimed-number","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bjornstar%2Ftimed-number/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bjornstar%2Ftimed-number/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bjornstar%2Ftimed-number/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bjornstar","download_url":"https://codeload.github.com/bjornstar/timed-number/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235752273,"owners_count":19039867,"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-10-01T08:33:54.459Z","updated_at":"2025-10-08T20:31:59.522Z","avatar_url":"https://github.com/bjornstar.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/bjornstar/timed-number.png)](https://travis-ci.org/bjornstar/timed-number)\n\ntimed-number\n==========\n\nA little wrapper to help deal with numbers that change over time.\n\nExample usage:\n```javascript\nvar TimedNumber = require('timed-number');\n\nvar hp = {\n\tinterval: 1,\n\tmax: 10,\n\tmin: 0,\n\trate: 1 / 1, // goes up by one every second\n\tval: 3,\n\tinterval: 1 // how often the timed number will tick in seconds.\n};\n\nvar tnHP = new TimedNumber(hp);\n\nfunction logHP() {\n\tconsole.log(tnHP.get());\n}\n\nsetInterval(logHP, 1000);\n```\n\nBy default, the time source operates in seconds. You can change this behavior by overriding the\nTimedNumber's now method.\n\n###Methods:\n####get()\nReturns the value of the TimedNumber at the time returned by now.\n\n####inc( *value* )\nA shortcut to add **value** to the TimedNumber, follows the same rules as set.\n\n####now()\nReturns the current time in seconds. If you want more or less granularity in your TimedNumber, you\ncan override this function.\n\n####set( *value* )\nSets the TimedNumber to the **value** provided. If the value would be outside of the bounds set by\nmax and min, the max or min is set instead.\n\n####nextTick()\nReturns in unix time when the next tick will triggered\n\n####lastTick()\nReturns in unix time when the last tick got triggered\n\n####finalTick()\nReturns in unix time when the final tick will triggered, meaning when the value get to its max/min\n\n\n###Properties:\n####last\nThe last time this number was updated. Defaults to 0.\n\n####max\nThe maximum value this number can be. Defaults to Infinity.\n\n####min\nThe minimum value this number can be. Defaults to -Infinity.\n\n####rate\nThe amount to change the value per tick. Defaults to 0.\n\n####interval\nThe amount of time between ticks, in seconds. Defaults to 1.\n\n####val\nThe value of the number at the time of the last update.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbjornstar%2Ftimed-number","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbjornstar%2Ftimed-number","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbjornstar%2Ftimed-number/lists"}