# @wentian/lazy-task

> 用于处理不重要且需要执行的任务,执行环境需要较高的浏览器版本

Latest version **1.0.7** (published 2023-09-28) · ISC license · 0 weekly downloads

## Install

```sh
npm install @wentian/lazy-task
pnpm add @wentian/lazy-task
yarn add @wentian/lazy-task
bun add @wentian/lazy-task
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.7 |
| Published | 2023-09-28 |
| First published | 2023-09-25 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 8.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | donghym@yonyou.com |
| Maintainers | wentian |

## Links

- npm: https://www.npmjs.com/package/@wentian/lazy-task
- npm.io page: https://npm.io/package/@wentian/lazy-task

## Recent versions

- 1.0.7 (latest) — 2023-09-28
- 1.0.6 — 2023-09-28
- 1.0.5 — 2023-09-28
- 1.0.4 — 2023-09-28
- 1.0.3 — 2023-09-26
- 1.0.2 — 2023-09-26
- 1.0.1 — 2023-09-26
- 1.0.0 — 2023-09-25

## README

<!--
 * @Author: donghym
 * @Date: 2023-09-08 16:16:58
 * @LastEditors: donghym
 * @Description: 
 * @LastEditTime: 2023-09-08 16:44:36
 * @FilePath: /lazyTask/readme.md
-->
### 用于处理不重要且需要执行的任务

##### 原理
js脚本只能在一个线程里运行
我们看到的页面是能是一个屏幕里面的数据，这里面如果涉及到已有数据计算，那么就需要花费时间，如果这个时间很长，那么用户就会感觉到卡顿
我们可以把任务拆分，让任务分层运行，当需要的时候再进行计算，这样就解决了卡顿的问题
我们可以把任务分为3层
- 1. 常任务
- 2. 次任务
常任务是js主线程里面依次执行的
次级任务是常任务执行完之后执行,不影响页面执行，此时最好搭配后端校验,避免产生不必要的错误数据
##### 实现
任务 - {常任务:【1，2，3，4】，次任务:【1，2，3，4】}
常任务依次执行，遇到添加的常任务 则次插入常任务列表
次任务依次执行，遇到添加的常任务 则优先执行常任务，在执行次任务

---
_Source: https://npm.io/package/@wentian/lazy-task · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
