run-first-only 1.0.0 → 2.0.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 +7 -7
- package/index.js +5 -5
- package/package.json +5 -6
- package/History.md +0 -5
package/Readme.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[![NPM version][npm-image]][npm-url]
|
|
2
|
-
[![Build Status][
|
|
3
|
-
[![Dependency Status][
|
|
2
|
+
[![Build Status][build-image]][build-url]
|
|
3
|
+
[![Dependency Status][deps-image]][deps-url]
|
|
4
4
|
|
|
5
5
|
# run-first-only
|
|
6
6
|
|
|
@@ -44,11 +44,11 @@ MIT © [Damian Krzeminski](https://furkot.com)
|
|
|
44
44
|
|
|
45
45
|
[async.memoize]: http://caolan.github.io/async/docs.html#memoize
|
|
46
46
|
|
|
47
|
-
[npm-image]: https://img.shields.io/npm/v/run-first-only
|
|
47
|
+
[npm-image]: https://img.shields.io/npm/v/run-first-only
|
|
48
48
|
[npm-url]: https://npmjs.org/package/run-first-only
|
|
49
49
|
|
|
50
|
-
[
|
|
51
|
-
[
|
|
50
|
+
[build-url]: https://github.com/pirxpilot/run-first-only/actions/workflows/check.yaml
|
|
51
|
+
[build-image]: https://img.shields.io/github/actions/workflow/status/pirxpilot/run-first-only/check.yaml?branch=main
|
|
52
52
|
|
|
53
|
-
[
|
|
54
|
-
[
|
|
53
|
+
[deps-image]: https://img.shields.io/librariesio/release/npm/run-first-only
|
|
54
|
+
[deps-url]: https://libraries.io/npm/run-first-only
|
package/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
module.exports = runOnce;
|
|
2
2
|
|
|
3
3
|
function runOnce(asyncFn) {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
let queue = [];
|
|
5
|
+
let results;
|
|
6
|
+
|
|
7
|
+
return worker;
|
|
6
8
|
|
|
7
9
|
function worker(next) {
|
|
8
10
|
if (results) {
|
|
@@ -12,13 +14,11 @@ function runOnce(asyncFn) {
|
|
|
12
14
|
queue.push(next);
|
|
13
15
|
|
|
14
16
|
if (queue.length === 1) {
|
|
15
|
-
asyncFn(function() {
|
|
17
|
+
asyncFn(function () {
|
|
16
18
|
results = arguments;
|
|
17
19
|
queue.forEach(worker);
|
|
18
20
|
queue = undefined;
|
|
19
21
|
});
|
|
20
22
|
}
|
|
21
23
|
}
|
|
22
|
-
|
|
23
|
-
return worker;
|
|
24
24
|
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "run-first-only",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Execute only first call of the async function.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Damian Krzeminski",
|
|
7
7
|
"email": "pirxpilot@furkot.om",
|
|
8
8
|
"url": "https://furkot.com"
|
|
9
9
|
},
|
|
10
|
-
"repository": "pirxpilot/run-first-only",
|
|
10
|
+
"repository": "github:pirxpilot/run-first-only",
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"keywords": [
|
|
13
13
|
"run-first-only",
|
|
@@ -17,9 +17,8 @@
|
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {},
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"jshint": "
|
|
21
|
-
"
|
|
22
|
-
"should": "^11.2.1"
|
|
20
|
+
"@pirxpilot/jshint": "~3",
|
|
21
|
+
"should": "~13"
|
|
23
22
|
},
|
|
24
23
|
"scripts": {
|
|
25
24
|
"test": "make check"
|
|
@@ -27,4 +26,4 @@
|
|
|
27
26
|
"files": [
|
|
28
27
|
"index.js"
|
|
29
28
|
]
|
|
30
|
-
}
|
|
29
|
+
}
|