@e280/stz 0.0.0-31 → 0.0.0-32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -35,7 +35,7 @@ const map = new MapG<number, string>([
|
|
|
35
35
|
// "rofl"
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
### nap
|
|
38
|
+
### 🍏 nap
|
|
39
39
|
> sleep for some milliseconds
|
|
40
40
|
|
|
41
41
|
```ts
|
|
@@ -45,7 +45,7 @@ await nap(900)
|
|
|
45
45
|
// wait for 900 milliseconds
|
|
46
46
|
```
|
|
47
47
|
|
|
48
|
-
### defer
|
|
48
|
+
### 🍏 defer
|
|
49
49
|
> defer the resolve/reject of a promise to the outside
|
|
50
50
|
|
|
51
51
|
```ts
|
|
@@ -155,20 +155,20 @@ fn()
|
|
|
155
155
|
console.log(count) // 1
|
|
156
156
|
```
|
|
157
157
|
|
|
158
|
-
### 🍏 `deadline(100,
|
|
158
|
+
### 🍏 `deadline(100, fn)`
|
|
159
159
|
> throws an error if the async function takes too long
|
|
160
160
|
|
|
161
161
|
```ts
|
|
162
162
|
import {deadline} from "@e280/stz"
|
|
163
163
|
|
|
164
|
-
const fn = deadline(100,
|
|
164
|
+
const fn = deadline(100, async() => {
|
|
165
165
|
|
|
166
166
|
// example deliberately takes too long
|
|
167
167
|
await nap(200)
|
|
168
168
|
})
|
|
169
169
|
|
|
170
170
|
await fn()
|
|
171
|
-
// DeadlineError: deadline exceeded
|
|
171
|
+
// DeadlineError: deadline exceeded (0.1 seconds)
|
|
172
172
|
```
|
|
173
173
|
|
|
174
174
|
### 🍏 `repeat(fn)`
|