Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

main-thread-scheduling

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

main-thread-scheduling - npm Package Compare versions

Comparing version 14.1.1 to 14.2.0

8

package.json
{
"name": "main-thread-scheduling",
"version": "14.1.1",
"version": "14.2.0",
"description": "Fast and consistently responsive apps using a single function call",

@@ -35,3 +35,7 @@ "license": "MIT",

"worker",
"web worker"
"web worker",
"Core Web Vitals",
"INP",
"Interaction to Next Paint",
"performance"
],

@@ -38,0 +42,0 @@ "module": "index.js",

@@ -36,2 +36,3 @@ <br>

- Your users' computer fans don't spin.
- Your [INP (Interaction to Next Paint)](https://web.dev/articles/inp) is in green.
- It's easy to plug it into your existing codebase.

@@ -38,0 +39,0 @@

@@ -15,18 +15,19 @@ import ricTracker from './ricTracker';

canWorkMore(task) {
const isInputPending = navigator.scheduling?.isInputPending?.() === true;
return !isInputPending && this.#calculateDeadline(task) - Date.now() > 0;
return !this.#isInputPending() && this.#calculateDeadline(task) - Date.now() > 0;
}
async nextWorkCycle(task) {
if (task.type === 'frame-based') {
await Promise.race([frameTracker.waitAfterFrame(), waitHiddenTask()]);
}
else if (task.type === 'idle-based') {
if (ricTracker.available) {
await ricTracker.waitIdleCallback();
do {
if (task.type === 'frame-based') {
await Promise.race([frameTracker.waitAfterFrame(), waitHiddenTask()]);
}
else {
// todo: use waitHiddenTask() with a timeout
await frameTracker.waitAfterFrame();
else if (task.type === 'idle-based') {
if (ricTracker.available) {
await ricTracker.waitIdleCallback();
}
else {
// todo: use waitHiddenTask() with a timeout
await frameTracker.waitAfterFrame();
}
}
}
} while (this.#isInputPending());
this.#workCycleStart = Date.now();

@@ -50,2 +51,5 @@ }

}
#isInputPending() {
return navigator.scheduling?.isInputPending?.() === true;
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc