everytask
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

📦 Everytask

npm version Everytask is released under the MIT license.

The API for sheduling tasks with the event loop is very counter intuitive. It's sometimes hard to choose between Promise.resolve().then(), setTimeout() and queueMicrotask(). Don't get me started with the differences between node and the browser.

This library aims to provide a clear isomorphic API to schdelule tasks without having to deal with all the nuances.

Installation

yarn add everytask

Usage

import * as tasks from 'everytask';

tasks.task(() => console.log('called fourth'));
tasks.microtask(() => console.log('called third'));
tasks.macrotask(() => console.log('called second'));
tasks.synchonouse(() => console.log('called first'));

Tests

The package is 100% tested on node as well as on safari, firefox and chrome ( using jest the awesome playwright package ).

In order to reproduce the tests type the command below:

yarn build & yarn test

Credit

  • This package is heavility inspired from the HTTP 204 video below. While writing the package I found out that there where some errors in the video that are fixed in this package. (Source: https://www.youtube.com/watch?v=8eHInw9_U8k)

Readme

Keywords

none

Package Sidebar

Install

npm i everytask

Weekly Downloads

3

Version

1.0.1

License

MIT

Unpacked Size

14.8 kB

Total Files

12

Last publish

Collaborators

  • iliasbhal