@parasrp/delay 1.0.0 â 1.1.0
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 +78 -0
- package/package.json +15 -15
package/README.md
CHANGED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# @parasrp/delay
|
|
2
|
+
|
|
3
|
+
[](https://opensource.org/licenses/MIT)
|
|
4
|
+

|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
A lightweight, promise-based JavaScript utility to pause execution for a specified duration. Perfect for adding timeouts, staggering API calls, or building simple animations.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## ⨠Features
|
|
12
|
+
|
|
13
|
+
- đĒļ **Lightweight & Fast**: Zero overhead, minimal footprint.
|
|
14
|
+
- đ¤ **Promise-based**: Works seamlessly with `async/await`.
|
|
15
|
+
- đĻ **Zero Dependencies**: Keeps your node_modules clean.
|
|
16
|
+
- đ **Universal**: Works in Node.js, browsers, and modern JS environments.
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## đĻ Installation
|
|
21
|
+
|
|
22
|
+
Install the package via npm:
|
|
23
|
+
```bash
|
|
24
|
+
npm install @parasrp/delay
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Install the package via yarn:
|
|
28
|
+
```bash
|
|
29
|
+
yarn add @parasrp/delay
|
|
30
|
+
```
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## ⨠Features
|
|
34
|
+
You can use @parasrp/delay with both CommonJS and ES Modules.
|
|
35
|
+
|
|
36
|
+
ES6 Modules:
|
|
37
|
+
```js
|
|
38
|
+
import delay from "@parasrp/delay";
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
CommonJS:
|
|
42
|
+
```js
|
|
43
|
+
const delay = require("@parasrp/delay");
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## Examples
|
|
49
|
+
|
|
50
|
+
Using async/await:
|
|
51
|
+
```js
|
|
52
|
+
async function countdown() {
|
|
53
|
+
console.log("Starting countdown...");
|
|
54
|
+
|
|
55
|
+
for (let i = 5; i > 0; i--) {
|
|
56
|
+
console.log(i);
|
|
57
|
+
await delay(1000); // Waits for 1 second
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
console.log("Go!");
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
countdown();
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Using .then():
|
|
67
|
+
```js
|
|
68
|
+
console.log("Start waiting...");
|
|
69
|
+
|
|
70
|
+
delay(1000).then(() => {
|
|
71
|
+
console.log("Finished waiting 1000 milliseconds");
|
|
72
|
+
});
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## đ¤ Author
|
|
76
|
+
**Paras R Poshiya**
|
|
77
|
+
* [GitHub](https://github.com/parasposhiya)
|
|
78
|
+
* [GitLab](https://gitlab.com/parasposhiya)
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@parasrp/delay",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "sleep function",
|
|
5
|
-
"author": "Paras R Poshiya",
|
|
6
|
-
"keywords": [
|
|
7
|
-
"sleep",
|
|
8
|
-
"delay"
|
|
9
|
-
],
|
|
10
|
-
"license": "MIT",
|
|
11
|
-
"main": "index.js",
|
|
12
|
-
"type": "module",
|
|
13
|
-
"exports": {
|
|
14
|
-
".": "./index.js"
|
|
15
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@parasrp/delay",
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "sleep function",
|
|
5
|
+
"author": "Paras R Poshiya",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"sleep",
|
|
8
|
+
"delay"
|
|
9
|
+
],
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"main": "index.js",
|
|
12
|
+
"type": "module",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": "./index.js"
|
|
15
|
+
}
|
|
16
16
|
}
|