{"id":20135545,"url":"https://github.com/raisely/tiny-timestamp","last_synced_at":"2025-07-23T09:34:10.025Z","repository":{"id":69521267,"uuid":"318125904","full_name":"raisely/tiny-timestamp","owner":"raisely","description":"Unique small timestamps","archived":false,"fork":false,"pushed_at":"2020-12-03T08:51:41.000Z","size":15,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-03-02T22:41:37.115Z","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":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/raisely.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-12-03T08:31:35.000Z","updated_at":"2020-12-04T01:47:04.000Z","dependencies_parsed_at":"2023-02-26T05:00:49.558Z","dependency_job_id":null,"html_url":"https://github.com/raisely/tiny-timestamp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/raisely/tiny-timestamp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raisely%2Ftiny-timestamp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raisely%2Ftiny-timestamp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raisely%2Ftiny-timestamp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raisely%2Ftiny-timestamp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/raisely","download_url":"https://codeload.github.com/raisely/tiny-timestamp/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raisely%2Ftiny-timestamp/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266655348,"owners_count":23963553,"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","status":"online","status_checked_at":"2025-07-23T02:00:09.312Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"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":"2024-11-13T21:15:27.771Z","updated_at":"2025-07-23T09:34:10.004Z","avatar_url":"https://github.com/raisely.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TinyTimstamp\n\nUnique small timestamps.\n\nHandy for cross referencing logs or error reports, especially if your users tend to send you\nscreenshots and you don't want to be transcribing long codes.\n\nIt encodes a timestamp based on `process.hrtime()` to create unique identifiers.\nSee below for how this is handled\n\n```\nnpm install tiny-timestamp\n```\n\n```javascript\nconst { decodeStamp, tinyStamp, toISOString } = require('tiny-timestamp');\n\nconst value = tinyStamp();\nconst originalTime = decodeStamp(value);\n\nconsole.log(value); // '2tLJTc:s9V'\nconsole.log(originalTime); // [ 1606876750, 123451 ]\nconsole.log(toISOString(value)); // '2020-12-02T02:39:10.000123451'\n\n// You can shorten identifiers by setting a repeat interval\n// and any precision above that period will be discarded\n\nconst month = 60 * 60 * 24 * 30; // in seconds\nconst shorterValue = tinyStamp({\n\trepeatableInterval: month,\n\ttime: originalTime,\n});\nconsole.log(shorterValue); // -eXc:s9V\n\n// You won't be able to get back the exact original time\nconsole.log(decodeStamp(shorterValue)); // [ 2428750, 123451 ]\nconsole.log(toISOString(shorterValue)); // '1970-01-29T02:39:10.000123451'\n```\n\n### Under the hood\n\n`hrtime()` produces a time in nanoseconds, though it's not guaranteed to have\nnanosecond precision, the precision should be good enough to give a low likelihood\nof collision between two identifiers.\n\nHowever, because `hrtime()` is calculated in seconds from some arbitrary time, on it's own it\ncan't produce a good unique identifier. tinyStamp replaces the seconds value from hrtime\nwith the seconds since the UNIX epoch.\n\nIn other words\n\n```\nconst arbitraryTime = process.hrtime();\nconst fixedTime = [parseInt(new Date() / 1000), arbitraryTime[1]];\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraisely%2Ftiny-timestamp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fraisely%2Ftiny-timestamp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraisely%2Ftiny-timestamp/lists"}