@hikyu/async
v1.0.9
Published
Useful package ๐ for some async stuff like sleep ๐ค
Readme
Async
Useful package ๐ for some async stuff like sleep ๐ค
๐ Zipped under 1kb with updates.
Install
npm i @hikyu/asyncUsage
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 outputPost
// Only Https at the moment.
await post('api.example.com/todo/create'); // > json outputonChange
// 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);
