{"_id":"@adam-rocska/timeout","name":"@adam-rocska/timeout","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@adam-rocska/timeout","author":{"name":"Ádám László Rocska","url":"https://adam-rocska.github.io"},"version":"1.0.0","description":"A lightweight TypeScript utility to create a Promise that resolves after a specified delay.","keywords":["typescript","javascript","promise","timeout","delay","async","await","node","browser","utility"],"browserslist":["last 3 years"],"main":"./dist/cjs/index.js","module":"./dist/es/index.mjs","types":"./dist/cjs/index.d.ts","publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"repository":{"type":"git","url":"git+https://github.com/adam-rocska/timeout-typescript.git"},"bugs":{"url":"https://github.com/adam-rocska/timeout-typescript/issues"},"funding":[{"type":"github","url":"https://github.com/sponsors/adam-rocska"}],"license":"MIT","devDependencies":{"@arethetypeswrong/cli":"^0.18.1","@swc/jest":"^0.2.38","@types/jest":"^29.5.14","@types/node":"^22.15.21","@typescript-eslint/eslint-plugin":"^8.32.1","@typescript-eslint/parser":"^8.32.1","bunchee":"^6.5.2","eslint":"^8.57.1","eslint-config-next":"15.3.2","eslint-plugin-node":"^11.1.0","jest":"^29.7.0","pnpm":"^10.11.0","rimraf":"^6.0.1","semver":"^7.7.2","typescript":"^5.8.3"},"jest":{"moduleDirectories":["node_modules"],"moduleNameMapper":{"^@adam-rocska/timeout$":"<rootDir>/src/index.ts","^!(.*)":"<rootDir>/$1"},"transform":{"^.+\\.(t|j)sx?$":["@swc/jest"]},"testPathIgnorePatterns":["/node_modules/"],"collectCoverageFrom":["src/**/*.ts"],"testTimeout":1000},"scripts":{"clean":"rimraf dist","build":"bunchee","test":"jest --env node","check":"pnpm eslint && pnpm attw --pack"},"_id":"@adam-rocska/timeout@1.0.0","homepage":"https://github.com/adam-rocska/timeout-typescript#readme","_integrity":"sha512-jZHK4Jpbr8rsdHUKZrnKVCoaBIjCSjUvezbDQzid2kJJFZ5jrzXd+mIyEOjbGJCqfc5MRpT2nkcOcybFio5b4w==","_resolved":"/tmp/4407d6a92e4ed1ba6ebf8f94ac55006a/adam-rocska-timeout-1.0.0.tgz","_from":"file:adam-rocska-timeout-1.0.0.tgz","_nodeVersion":"20.19.1","_npmVersion":"10.8.2","dist":{"integrity":"sha512-jZHK4Jpbr8rsdHUKZrnKVCoaBIjCSjUvezbDQzid2kJJFZ5jrzXd+mIyEOjbGJCqfc5MRpT2nkcOcybFio5b4w==","shasum":"6e1aa9381afc4e13219901b756b01700c637fc5d","tarball":"https://registry.npmjs.org/@adam-rocska/timeout/-/timeout-1.0.0.tgz","fileCount":6,"unpackedSize":7061,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@adam-rocska%2ftimeout@1.0.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIB8Iv2muENBFgZPGL6dQqBgb+06DOLiPuKWq42qEO71ZAiAeA6iQRw4zmVsTyjrT72kU3MOopV/Ocdwv55FdIUlQRA=="}]},"_npmUser":{"name":"adam-rocska","email":"rocska.adam@gmail.com"},"directories":{},"maintainers":[{"name":"adam-rocska","email":"rocska.adam@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/timeout_1.0.0_1747843351481_0.12417954885559124"},"_hasShrinkwrap":false}},"time":{"created":"2025-05-21T16:02:31.376Z","1.0.0":"2025-05-21T16:02:31.689Z","modified":"2025-05-21T16:02:32.256Z"},"maintainers":[{"name":"adam-rocska","email":"rocska.adam@gmail.com"}],"description":"A lightweight TypeScript utility to create a Promise that resolves after a specified delay.","homepage":"https://github.com/adam-rocska/timeout-typescript#readme","keywords":["typescript","javascript","promise","timeout","delay","async","await","node","browser","utility"],"repository":{"type":"git","url":"git+https://github.com/adam-rocska/timeout-typescript.git"},"author":{"name":"Ádám László Rocska","url":"https://adam-rocska.github.io"},"bugs":{"url":"https://github.com/adam-rocska/timeout-typescript/issues"},"license":"MIT","readme":"# @adam-rocska/timeout\n\nA lightweight TypeScript/JavaScript utility that creates a Promise resolving after a specified number of milliseconds. Ideal for introducing delays in asynchronous workflows.\n\n## Features\n\n- **Simple Delay**: Creates a Promise that resolves after a specified time (in milliseconds).\n- **TypeScript Support**: Fully typed for a better developer experience.\n- **Lightweight**: Zero runtime dependencies and minimal footprint.\n- **Browser and Node.js Support**: Compatible with modern browsers (last 3 years) and Node.js (v14+).\n- **Well-Tested**: Includes unit tests to ensure reliable resolution after the specified delay.\n\n## Installation\n\nInstall the package via npm or pnpm:\n\n```bash\nnpm install @adam-rocska/timeout\n```\n\nor\n\n```bash\npnpm add @adam-rocska/timeout\n```\n\n## Usage\n\nThe `timeout` function takes a number of milliseconds and returns a `Promise<void>` that resolves after the specified delay.\n\n### Example: Basic Usage\n\n```javascript\nimport { timeout } from '@adam-rocska/timeout';\n\nasync function main() {\n  console.log('Starting...');\n  await timeout(2000); // Wait for 2 seconds\n  console.log('2 seconds later!');\n}\n\nmain();\n```\n\n### Parameters\n\n| Parameter | Type     | Description                                      | Default |\n| --------- | -------- | ------------------------------------------------ | ------- |\n| `ms`      | `number` | Time to wait (in milliseconds) before resolving. | -       |\n\n### Returns\n\n- **Resolves**: `Promise<void>` - Resolves after the specified delay.\n\n## Types\n\nThe library includes TypeScript definitions for type safety.\n\n```typescript\nexport declare const timeout: (ms: number) => Promise<void>;\n```\n\n## API\n\n### `timeout(ms: number): Promise<void>`\n\nCreates a Promise that resolves after the specified number of milliseconds.\n\n## Requirements\n\n- **Node.js**: Version 14 or higher (due to async/await and modern JavaScript features).\n- **Browsers**: Supports browsers from the last 3 years (aligned with `browserslist`).\n- **TypeScript**: Optional, for type safety (version 5.8 or higher recommended).\n\n## Development\n\nTo contribute or test the library locally:\n\n1. Clone the repository:\n   ```bash\n   git clone https://github.com/adam-rocska/timeout-typescript.git\n   ```\n2. Install dependencies using pnpm:\n   ```bash\n   pnpm install\n   ```\n3. Run tests:\n   ```bash\n   pnpm test\n   ```\n4. Build the library:\n   ```bash\n   pnpm build\n   ```\n5. Check code quality and types:\n   ```bash\n   pnpm check\n   ```\n\nThe library uses Jest for testing, ESLint for linting, and `bunchee` for building ES and CommonJS modules.\n\n## Testing\n\nThe library includes unit tests covering:\n- Resolution of the Promise after the specified delay.\n\nRun `pnpm test` to execute the test suite.\n\n## License\n\nThis project is licensed under the [MIT License](LICENSE).\n\n## Contributing\n\nContributions are welcome! Please open an issue or submit a pull request on the [GitHub repository](https://github.com/adam-rocska/timeout-typescript).\n\n## Support\n\nIf you encounter issues or have questions, please file an issue on the [GitHub Issues page](https://github.com/adam-rocska/timeout-typescript/issues).\n\n## Funding\n\nSupport the development of this project via [GitHub Sponsors](https://github.com/sponsors/adam-rocska).\n\n## Author\n\nCreated by [Ádám László Rocska](https://adam-rocska.github.io).","readmeFilename":"README.md","_rev":"1-bb558b3cd94c4c36471cfc37fafa8e3c"}