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 6.0.0 to 7.0.0

6

package.json
{
"name": "main-thread-scheduling",
"version": "6.0.0",
"description": "Faster apps using a simple API instead of Web Workers",
"version": "7.0.0",
"description": "Fast and consistently responsive apps using a single function call",
"license": "MIT",

@@ -12,3 +12,3 @@ "repository": "astoilkov/main-thread-scheduling",

"email": "hello@astoilkov.com",
"url": "http://astoilkov.com"
"url": "https://astoilkov.com"
},

@@ -15,0 +15,0 @@ "keywords": [

@@ -11,3 +11,3 @@ <br>

<p align="center">
Faster apps using a simple API instead of Web Workers
Fast and consistently responsive apps using a single function call
</p>

@@ -42,2 +42,4 @@

A real-world showcase of searching in 10k files and getting results instantly — https://twitter.com/antoniostoilkov/status/1539576912498118656.
## Use Cases

@@ -61,3 +63,3 @@

Why rely on some open-source library to ensure a good performance for my app?
- **Not a weekend project.** I've already been using it for over a year in the core of two of my products — [Nota](https://nota.md) and [iBar](https://ibar.app).
- **Not a weekend project.** Actively maintained for over a year — see [contributors](https://github.com/astoilkov/main-thread-scheduling/graphs/contributors) page. I've been using it in my own products for over two years — [Nota](https://nota.md) and [iBar](https://ibar.app). [Flux.ai](https://flux.ai/) are also using it in their product (software for designing hardware circuits).
- **This is the future.** Browsers are probably going to support scheduling tasks on the main thread in the future. Here is the [spec](https://github.com/WICG/scheduling-apis). This library will still be relevant in the future — [explanation](#scheduler-yield-alternative).

@@ -121,3 +123,3 @@ - **Simple.** 90% of the time you only need the `yieldOrContinue(priority)` function. The API has two more functions for more advanced cases.

**Web Workers** are a great fit if you have: 1) heavy algorithm (e.g. image processing), 2) heavy process (runs for a long time, big part of the app lifecycle). However, in reality, it's rare to see people using them. That's because they require significant investment of time due to the complexity that can't be avoided when working with CPU threads regardless of the programming language. This library can be used as a gateway before transitioning to Web Workers. In reality, a lot of the times, you would discover the doing it on the main thread is good enough.
**Web Workers** are a great fit if you have: 1) heavy algorithm (e.g. image processing), 2) heavy process (runs for a long time, big part of the app lifecycle). However, in reality, it's rare to see people using them. That's because they require significant investment of time due to the complexity that can't be avoided when working with CPU threads regardless of the programming language. This library can be used as a gateway before transitioning to Web Workers. In most cases, you would discover the doing it on the main thread is good enough.

@@ -124,0 +126,0 @@ <div id="scheduler-yield-alternative"></div>

@@ -18,2 +18,8 @@ import state from './state';

export default async function yieldControl(priority) {
// - in Node.js context return immediately
// - this way we also support test environments (without jsdom added)
// - support for scheduling in Node.js is still under consideration for future versions
if (typeof requestAnimationFrame === 'undefined') {
return;
}
cancelPromiseEscape(promiseEscapeId);

@@ -20,0 +26,0 @@ const task = createTask(priority);

@@ -6,2 +6,8 @@ import yieldControl from './yieldControl';

export default function yieldOrContinue(priority) {
// - in Node.js context return immediately
// - this way we also support test environments (without jsdom added)
// - support for scheduling in Node.js is still under consideration for future versions
if (typeof requestAnimationFrame === 'undefined') {
return Promise.resolve();
}
if (isTimeToYield(priority)) {

@@ -8,0 +14,0 @@ return yieldControl(priority);

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