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 0.2.1 to 1.0.0

2

package.json
{
"name": "main-thread-scheduling",
"version": "0.2.1",
"version": "1.0.0",
"description": "Always responsive apps while staying on the main thread",

@@ -5,0 +5,0 @@ "license": "MIT",

<br>
<br>
<div align="center">
<img width="200px" src="media/logo.png">
<img width="288px" src="media/logo-centered.png">
</div>
<h3 align="center">
<b>main-thread-scheduling</b>
</h3>
<p align="center">
Consistently responsive apps while staying on the main thread
</p>
<br>
<br>
**main-thread-scheduling** — consistently responsive apps while staying on the main thread
## Install

@@ -19,5 +24,5 @@

Making a responsive app is hard. With time apps get more complex and keeping your app responsive becomes even harder. It's possible to overcome this by using Web Workers but if you tried it you know that it's very hard to do in reality.
It's hard to make an app responsive. With time apps get more complex and keeping your app responsive becomes even harder. Web Workers can help, but if you have tried it, you know it's a lot of work.
This library keeps everything on the main thread. This allows for a very small and simple API that can be integrated easily in existing code bases.
This library keeps everything on the main thread. This allows for a very small and simple API that can be integrated easily in existing code base.

@@ -27,5 +32,6 @@ Here a few more advantages:

- Utilizes the new `navigator.scheduling.isInputPending()` method (when available). Fallbacks to a good enough alternative otherwise.
- This isn't a weekend project. I have been working on this code for months. If you want to dive more deeply read the [in-depth](./docs/in-depth.md) doc.
- Not a weekend project. I have been working on this code for months. If you want to dive deeper, you can read the [in-depth](./docs/in-depth.md) doc.
- 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).
- Aiming for high-quality with [my open-source principles](https://github.com/astoilkov/me/blob/master/essays/My%20open-source%20principles.md)
- Consistently responsive. You can have hundred of tasks pending but the library will always execute just a single one.
- Aiming for high-quality with [my open-source principles](https://astoilkov.com/my-open-source-principles)

@@ -38,3 +44,3 @@ ## API

The complexity of the entire library is hidden behind this method. You will have great app performance by calling a single method.
The complexity of the entire library is hidden behind this method. You can have great app performance by calling a single method.

@@ -74,6 +80,6 @@ ```ts

Currently there are only two priorities available: `background` and `user-visible`:
- `background` – use this for background tasks. Every background task is run for 5ms – this ensures that the CPU fan of your user won't turn on.
- `user-visible` – use this for things that needs to display to the user as fast as possible. Every `user-visible` task is run for 50ms – this gives you a nice cycle of doing heavy work and letting the browser render pending changes.
- `background` – use this for background tasks. Every background task is run for 5ms.
- `user-visible` – use this for things that need to display to the user as fast as possible. Every `user-visible` task is run for 50ms – this gives you a nice cycle of doing heavy work and letting the browser render pending changes.
If you have a use case for a third priority see the issue [here]().
If you have a use case for a third priority, you can write in [this issue](https://github.com/astoilkov/main-thread-scheduling/issues/1).

@@ -84,2 +90,2 @@ ## Alternatives

React has an implementation for scheduling tasks – [react/scheduler](https://github.com/facebook/react/tree/3c7d52c3d6d316d09d5c2479c6851acecccc6325/packages/scheduler). They plan to make it more generic but I don't know the timeline for this.
React has an implementation for scheduling tasks – [react/scheduler](https://github.com/facebook/react/tree/3c7d52c3d6d316d09d5c2479c6851acecccc6325/packages/scheduler). They plan to make it more generic but I don't know their timeline.
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