{"id":15069876,"url":"https://github.com/simsieg/sleepjs","last_synced_at":"2026-03-16T07:01:15.129Z","repository":{"id":30523704,"uuid":"125242931","full_name":"simsieg/sleepjs","owner":"simsieg","description":"Asynchronous sleep with better time functions and typescript support","archived":false,"fork":false,"pushed_at":"2023-01-06T03:38:11.000Z","size":904,"stargazers_count":12,"open_issues_count":11,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-10-05T08:34:31.774Z","etag":null,"topics":["async","async-await","javascript","js","milliseconds","node","node-js","nodejs","npm","npm-package","pause","promise","sleep","sleep-functions","time","wait","yarn"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/simsieg.png","metadata":{"files":{"readme":"readme.md","changelog":null,"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":"2018-03-14T16:36:12.000Z","updated_at":"2023-09-14T02:45:07.000Z","dependencies_parsed_at":"2023-01-14T17:08:15.648Z","dependency_job_id":null,"html_url":"https://github.com/simsieg/sleepjs","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/simsieg%2Fsleepjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simsieg%2Fsleepjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simsieg%2Fsleepjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simsieg%2Fsleepjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simsieg","download_url":"https://codeload.github.com/simsieg/sleepjs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248259849,"owners_count":21074207,"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":["async","async-await","javascript","js","milliseconds","node","node-js","nodejs","npm","npm-package","pause","promise","sleep","sleep-functions","time","wait","yarn"],"created_at":"2024-09-25T01:45:18.094Z","updated_at":"2026-03-16T07:01:09.955Z","avatar_url":"https://github.com/simsieg.png","language":"TypeScript","readme":"# SleepJS\n\n[![Build Status](https://travis-ci.org/simsieg/sleepjs.svg?branch=master)](https://travis-ci.org/simsieg/sleepjs) [![Coverage Status](https://coveralls.io/repos/github/simsieg/sleepjs/badge.svg?branch=master)](https://coveralls.io/github/simsieg/sleepjs?branch=master) [![Downloads](https://img.shields.io/npm/dm/sleepjs.svg)](https://img.shields.io/npm/dm/sleepjs.svg)  \u003cbr /\u003e\n\nAsynchronus sleep functions with typescript support.\n\n## Installation\n\nInstall sleepjs with npm:\n\n```bash\nnpm install sleepjs\n```\n\nOr with yarn:\n\n```bash\nyarn add sleepjs\n```\n\n## Usage\n\nThe default function sleeps for a time given in milliseconds.\nBut also different sleep functions can be required.\n\n### Async / Await\n\nThe sleep timer can be awaited with async / await.\n\n```javascript\nconst { sleep } = require('sleepjs')\n\nconst myFunction = async () =\u003e {\n  await sleep(500)\n  console.info('It is 500 ms later now')\n}\n\nmyFunction()\n```\n\n### Promise\n\nThe Promise returns the value of slept milliseconds when it resolves.\n\n```javascript\nconst { sleepMinutes } = require('sleepjs')\n\nfunction myFunction () {\n  return sleepMinutes(5)\n    .then(time =\u003e {console.info(`${time} ms later`)})\n}\n\nmyFunction() // Will print: '300000 ms later'\n```\n\n### Concurrent\n\nDifferent sleep instances can be run and awaited concurrently with `Promise.all`.\n\n```javascript\nconst { sleep } = require('sleepjs')\n\nasync function myFunction () {\n  await Promise.all([sleep(100), sleep(100), sleep(200)])\n}\n\nmyFunction() // Will take only slightly more than 200 ms\n```\n\n## Functions\n\nSleepjs includes several functions to wrap common sleep times:\n\n```javascript\nconst { sleep } = require('sleepjs')\nconst { sleepMilliseconds } = require('sleepjs') // Same as sleep\nconst { sleepSeconds } = require('sleepjs')\nconst { sleepMinutes } = require('sleepjs')\nconst { sleepHours } = require('sleepjs')\nconst { sleepDays } = require('sleepjs')\n```\n\nImport with typescript is also possible.\n\n```typescript\nimport {\n  sleep,\n  sleepMilliseconds,\n  sleepSeconds,\n  sleepMinutes,\n  sleepHours,\n  sleepDays,\n} from 'sleepjs'\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimsieg%2Fsleepjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimsieg%2Fsleepjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimsieg%2Fsleepjs/lists"}