New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

post-task

Package Overview
Dependencies
Maintainers
0
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

post-task

A polyfill for the Scheduler API with a pre-configured progressively-enhanced function helps to split long-running tasks into chunks.

latest
Source
npmnpm
Version
1.2.0
Version published
Maintainers
0
Created
Source

post-task

A pre-configured progressively-enhancement utility function based on the Scheduler API.

If the Scheduler API is available, use it. Otherwise set a timeout as a fallback.

The Scheduler API relies on browser heuristics, while the fallback waits and calls back only after a certain time has passed.

The tasks all return a Promise<void> since the scheduler.postTask returns one.

The interface re-exposes the values accepted for the scheduler.postTask API and forwards them through when that API is available.

The fallbacks are configured as following:

PriorityTimeout delay (ms)
"user-blocking"0
"user-visible"0
"background"150

There is one exception: if a priority of "user-blocking" is passed, and the Scheduler API is not available, the fallback will be queueMicrotask if that function is available, which it usually will be, including in Node.js.

This function is useful for breaking up chunks of work and allowing the event loop to cycle, which is particularly important when focusing on the Interaction to Next Paint web vital and of course the smooth interaction which it tries to measure.

Use

import postTask from "post-task";

// ...
postTask(() => {
  trackEvent("something-happened");
}, "background");

Formats

This package is equally available as ESM and CJS and has a single, default export.

Keywords

scheduler

FAQs

Package last updated on 11 Jan 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts