1.0.9 ā€¢ Published 2 years ago

@hikyu/async v1.0.9

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

Async

Useful package šŸ“‚ for some async stuff like sleep šŸ’¤

šŸ“‚ Zipped under 1kb with updates.

npm.io npm.io npm.io

Install

npm i @hikyu/async

Usage

I will use the deconstructed šŸš§ require for demonstration

// Simple require
const async = require('@hikyu/async');
sleep.sleep();

// Deconstructed require with custom names
const { sleep: wait } = require('@hikyu/async');
wait();

// Deconstructed require
const { sleep, .. } = require('@hikyu/async');
sleep();

Functions

General

Sleep

console.log("Sleep for 3 seconds šŸ˜“");

// Wait for 2 seconds
await sleep();

// Wait for 1 second
await sleep(1000)

console.log("I'm done sleeping šŸ‘‹");

Requests

Get

// Only Https at the moment.
await get('api.example.com/todo/1'); // > json output

Post

// Only Https at the moment.
await post('api.example.com/todo/create'); // > json output

onChange

// console.logs every change happened on the request
onChange('api.example.com/activity/new', 'GET', console.log, 5000);

// Interval time defaults to 10000
// onChange('api.example.com/activity/new', 'POST', yourFunction);
1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago