concurrency.js 0.0.3 → 0.0.5

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.
Files changed (41) hide show
  1. package/.todo +1 -1
  2. package/README.md +86 -105
  3. package/demos/concurrency.async.js +22 -0
  4. package/demos/concurrency.process.js +24 -0
  5. package/demos/concurrency.threaded.js +25 -0
  6. package/demos/libmap.js +30 -0
  7. package/index.js +12 -46
  8. package/package.json +8 -4
  9. package/tasks.async.js +72 -0
  10. package/tasks.process.js +65 -0
  11. package/tasks.thread.js +92 -0
  12. package/test/test.process.js +85 -0
  13. package/test/test.promise.js +86 -0
  14. package/test/test.thread.js +86 -0
  15. package/worker.js +24 -0
  16. package/worker_process.js +29 -0
  17. package/demos/cluster.js +0 -22
  18. package/demos/demos.cluster.js +0 -66
  19. package/demos/demos.js +0 -21
  20. package/demos/demos.process.js +0 -37
  21. package/demos/demos.threads.async.js +0 -22
  22. package/demos/demos.threads.js +0 -40
  23. package/docs/Concurrency.js.Process.jpg +0 -0
  24. package/docs/Concurrency.js.Process.pdf +0 -0
  25. package/docs/Concurrency.js.Threads.jpg +0 -0
  26. package/docs/Concurrency.js.Threads.pdf +0 -0
  27. package/index.mjs +0 -39
  28. package/src/worker.cluster.js +0 -122
  29. package/src/worker.cluster.threads.js +0 -20
  30. package/src/worker.process.js +0 -128
  31. package/src/worker.thread.async.js +0 -84
  32. package/src/worker.threads.js +0 -181
  33. package/test/_.test-template.js +0 -44
  34. package/test/demos.cluster.js +0 -46
  35. package/test/demos.process.js +0 -42
  36. package/test/demos.threads.js +0 -43
  37. package/test/test_demos_cluster.js +0 -78
  38. package/test/test_demos_process.js +0 -53
  39. package/test/test_demos_promise.js +0 -36
  40. package/test/test_demos_threads.js +0 -40
  41. package/test/test_demos_threads_async.js +0 -68
@@ -1,43 +0,0 @@
1
- /**
2
- *
3
- * Package: concurrency.js
4
- * Author: Ganesh B
5
- * Description: npm module to work with concurrency - worker threads and worker processes easily using simple functions and script files
6
- * Install: npm i --save
7
- * Github: https://github.com/ganeshkbhat/concurrency
8
- * npmjs Link: https://www.npmjs.com/package/concurrency.js
9
- * File: test.demos.cluster.js
10
- * File Description:
11
- *
12
- */
13
-
14
- /* eslint no-console: 0 */
15
-
16
-
17
- 'use strict';
18
-
19
- const path = require("path");
20
- let { _concurrencyThreads } = require("../index.js");
21
-
22
- // _concurrencyThreads(path.join("C:\\Users\\GB\\Documents\\projects\\requireurl\\concurrency\\src\\worker.threads.js"), { data: { url: "https://www.google.com", message: "Testing data" } });
23
-
24
- async function concurrency() {
25
- var responses;
26
- async function testPromise() {
27
- try {
28
- responses = await _concurrencyThreads(__filename, {
29
- data: {
30
- message: "Testing data",
31
- url: "https://www.google.com"
32
- },
33
- childData: "Testing child data"
34
- });
35
- return responses;
36
- } catch (e) {
37
- return e;
38
- }
39
- };
40
- return await testPromise();
41
- }
42
-
43
- module.exports.concurrency = concurrency();
@@ -1,78 +0,0 @@
1
- // /**
2
- // *
3
- // * Package: concurrency.js
4
- // * Author: Ganesh B
5
- // * Description: npm module to work with concurrency - worker threads and worker processes easily using simple functions and script files
6
- // * Install: npm i --save
7
- // * Github: https://github.com/ganeshkbhat/concurrency
8
- // * npmjs Link: https://www.npmjs.com/package/concurrency.js
9
- // * File: test.demos.cluster.js
10
- // * File Description:
11
- // *
12
- // */
13
-
14
- // /* eslint no-console: 0 */
15
-
16
- // 'use strict';
17
-
18
-
19
- // const expect = require('chai').expect;
20
- // const path = require("path");
21
-
22
- // const { _concurrencyClusters } = require("../index.js");
23
-
24
- // describe('test-.js::concurrency.js: [Test A] Test Suite for concurrency.js cluster in main repo directory', function () {
25
-
26
- // it('[Test A] Test for cluster function demos', async function () {
27
-
28
- // var response = await require("./demos.cluster").concurrency;
29
- // // console.log(response);
30
-
31
- // expect(200).to.equal(200);
32
-
33
- // // // "1":[{"closeChild":true,"pid":7468,"childMessageData":[{"id":"1","pid":9744,"message":{"message":"Testing parent data","url":"https://www.google.com"}},{"closeChild":true}],"result":[]}]
34
- // // expect(JSON.stringify(response.message["1"][0]["closeChild"])).to.equal(true);
35
- // // expect(JSON.stringify(response.message["1"][0]["childMessageData"][0]["id"])).to.equal(1);
36
- // // expect(JSON.stringify(response.message["1"][0]["childMessageData"][0]["message"])).to.equal({ "message": "Testing parent data", "url": "https://www.google.com" });
37
-
38
- // // // "2":[{"closeChild":true,"pid":13784,"childMessageData":[{"id":"2","pid":9744,"message":{"message":"Testing parent data","url":"https://www.google.com"}},{"closeChild":true}],"result":[]}]
39
- // // expect(JSON.stringify(response.message["2"][0]["closeChild"])).to.equal(true);
40
- // // expect(JSON.stringify(response.message["2"][0]["childMessageData"][0]["id"])).to.equal(1);
41
- // // expect(JSON.stringify(response.message["2"][0]["childMessageData"][0]["message"])).to.equal({ "message": "Testing parent data", "url": "https://www.google.com" });
42
-
43
- // // // "3":[{"closeChild":true,"pid":872,"childMessageData":[{"id":"3","pid":9744,"message":{"message":"Testing parent data","url":"https://www.google.com"}},{"closeChild":true}],"result":[]}]
44
- // // expect(JSON.stringify(response.message["3"][0]["closeChild"])).to.equal(true);
45
- // // expect(JSON.stringify(response.message["3"][0]["childMessageData"][0]["id"])).to.equal(1);
46
- // // expect(JSON.stringify(response.message["3"][0]["childMessageData"][0]["message"])).to.equal({ "message": "Testing parent data", "url": "https://www.google.com" });
47
-
48
- // // // "4": [{"closeChild":true,"pid":11732,"childMessageData":[{"id":"4","pid":9744,"message":{"message":"Testing parent data","url":"https://www.google.com"}},{"closeChild":true}],"result":[]}]
49
- // // expect(JSON.stringify(response.message["4"][0]["closeChild"])).to.equal(true);
50
- // // expect(JSON.stringify(response.message["4"][0]["childMessageData"][0]["id"])).to.equal(1);
51
- // // expect(JSON.stringify(response.message["4"][0]["childMessageData"][0]["message"])).to.equal({ "message": "Testing parent data", "url": "https://www.google.com" });
52
-
53
- // // // "5":[{"closeChild":true,"pid":7468,"childMessageData":[{"id":"5","pid":9744,"message":{"message":"Testing parent data","url":"https://www.google.com"}},{"closeChild":true}],"result":[]}]
54
- // // expect(JSON.stringify(response.message["5"][0]["closeChild"])).to.equal(true);
55
- // // expect(JSON.stringify(response.message["5"][0]["childMessageData"][0]["id"])).to.equal(1);
56
- // // expect(JSON.stringify(response.message["5"][0]["childMessageData"][0]["message"])).to.equal({ "message": "Testing parent data", "url": "https://www.google.com" });
57
-
58
- // // // "6":[{"closeChild":true,"pid":13784,"childMessageData":[{"id":"6","pid":9744,"message":{"message":"Testing parent data","url":"https://www.google.com"}},{"closeChild":true}],"result":[]}]
59
- // // expect(JSON.stringify(response.message["6"][0]["closeChild"])).to.equal(true);
60
- // // expect(JSON.stringify(response.message["6"][0]["childMessageData"][0]["id"])).to.equal(1);
61
- // // expect(JSON.stringify(response.message["6"][0]["childMessageData"][0]["message"])).to.equal({ "message": "Testing parent data", "url": "https://www.google.com" });
62
-
63
- // // // "7":[{"closeChild":true,"pid":872,"childMessageData":[{"id":"7","pid":9744,"message":{"message":"Testing parent data","url":"https://www.google.com"}},{"closeChild":true}],"result":[]}]
64
- // // expect(JSON.stringify(response.message["7"][0]["closeChild"])).to.equal(true);
65
- // // expect(JSON.stringify(response.message["7"][0]["childMessageData"][0]["id"])).to.equal(1);
66
- // // expect(JSON.stringify(response.message["7"][0]["childMessageData"][0]["message"])).to.equal({ "message": "Testing parent data", "url": "https://www.google.com" });
67
-
68
- // // // "8": [{"closeChild":true,"pid":11732,"childMessageData":[{"id":"8","pid":9744,"message":{"message":"Testing parent data","url":"https://www.google.com"}},{"closeChild":true}],"result":[]}]
69
- // // expect(JSON.stringify(response.message["8"][0]["closeChild"])).to.equal(true);
70
- // // expect(JSON.stringify(response.message["8"][0]["childMessageData"][0]["id"])).to.equal(1);
71
- // // expect(JSON.stringify(response.message["8"][0]["childMessageData"][0]["message"])).to.equal({ "message": "Testing parent data", "url": "https://www.google.com" });
72
-
73
- // // // "result":[]
74
- // // expect(JSON.stringify(response.result)).to.equal(JSON.stringify([]));
75
-
76
- // });
77
-
78
- // });
@@ -1,53 +0,0 @@
1
- /**
2
- *
3
- * Package: concurrency.js
4
- * Author: Ganesh B
5
- * Description: npm module to work with concurrency - worker threads and worker processes easily using simple functions and script files
6
- * Install: npm i --save
7
- * Github: https://github.com/ganeshkbhat/concurrency
8
- * npmjs Link: https://www.npmjs.com/package/concurrency.js
9
- * File: test.demos.process.js
10
- * File Description:
11
- *
12
- */
13
-
14
- /* eslint no-console: 0 */
15
-
16
- 'use strict';
17
-
18
-
19
- const expect = require('chai').expect;
20
- const path = require("path");
21
- const { _concurrencyProcesses } = require("../index.js");
22
-
23
-
24
- describe('test-.js::concurrency.js: [Test A] Test Suite for concurrency.js .process in main repo directory', function () {
25
-
26
- it('[Test A] Test for process function demos', async function () {
27
- var responses = await require("./demos.process").concurrency;
28
-
29
- //
30
- // { "message": [
31
- // { "closeChild": true, "pid": 14676,
32
- // "childMessageData": [
33
- // { "pid": 3828, "message": "Master Process PID:3828: Hello from Master Process" },
34
- // { "pid": 3828, "message": { "message": "Testing data", "url": "https://www.google.com" } },
35
- // { "closeChild": true }],
36
- // "result": []
37
- // }],
38
- // "result": []
39
- // }
40
- //
41
-
42
- expect(!!responses.message).to.equal(true);
43
- expect(responses.message.length).to.equal(1);
44
- expect(!!responses.result).to.equal(true);
45
- expect(responses.message[0].childMessageData.length).to.equal(3);
46
- expect(!!responses.message[0].result).to.equal(true);
47
- expect(Object.keys(responses.message[0].childMessageData[0]).length).to.equal(2);
48
- expect(Object.keys(responses.message[0].childMessageData[1]).length).to.equal(2);
49
- expect(Object.keys(responses.message[0].childMessageData[2]).length).to.equal(1);
50
- expect(!!responses.message[0].closeChild).to.equal(true);
51
- });
52
-
53
- });
@@ -1,36 +0,0 @@
1
- /**
2
- *
3
- * Package:
4
- * Author: Ganesh B
5
- * Description:
6
- * Install: npm i --save
7
- * Github: https://github.com/ganeshkbhat/concurrency
8
- * npmjs Link: https://www.npmjs.com/package/concurrency.js
9
- * File: index.js
10
- * File Description:
11
- *
12
- */
13
-
14
- /* eslint no-console: 0 */
15
-
16
- 'use strict';
17
-
18
-
19
- const expect = require('chai').expect;
20
-
21
-
22
- describe('test-.js::concurrency.js: [Test A] Test Suite for a simple promise', function () {
23
-
24
- it('[Test A] Test for promise tests', async function () {
25
- var result;
26
- function testPromise(resolve, reject) {
27
- return new Promise(function (resolve, reject) {
28
- resolve({ msg: "testing" });
29
- });
30
- }
31
- result = await testPromise();
32
- expect(result.msg).to.equal("testing");
33
- });
34
-
35
- });
36
-
@@ -1,40 +0,0 @@
1
- // /**
2
- // *
3
- // * Package: concurrency.js
4
- // * Author: Ganesh B
5
- // * Description: npm module to work with concurrency - worker threads and worker processes easily using simple functions and script files
6
- // * Install: npm i --save
7
- // * Github: https://github.com/ganeshkbhat/concurrency
8
- // * npmjs Link: https://www.npmjs.com/package/concurrency.js
9
- // * File: test.demos.threads.js
10
- // * File Description:
11
- // *
12
- // */
13
-
14
-
15
- /* eslint no-console: 0 */
16
-
17
- 'use strict';
18
-
19
-
20
- const expect = require('chai').expect;
21
- const path = require("path");
22
- var spawn = require("child_process").spawn;
23
-
24
- const { _concurrencyThreads } = require("../index.js");
25
-
26
-
27
- describe('test-.js::concurrency.js: [Test A] Test Suite for concurrency.js .threads in main repo directory', function () {
28
-
29
- it('[Test A] Test for threads _concurrencyThreads', async function () {
30
- let responses = await require("./demos.threads").concurrency;
31
-
32
- expect(Object.keys(responses).length).to.equal(2);
33
- expect(responses.message.length).to.equal(1);
34
- // expect(Object.keys(responses.message[0]).length).to.equal(2);
35
- expect(Object.keys(responses.message[0]).length).to.equal(5);
36
- });
37
-
38
- });
39
-
40
-
@@ -1,68 +0,0 @@
1
- // /**
2
- // *
3
- // * Package: concurrency.js
4
- // * Author: Ganesh B
5
- // * Description: npm module to work with concurrency - worker threads and worker processes easily using simple functions and script files
6
- // * Install: npm i --save
7
- // * Github: https://github.com/ganeshkbhat/concurrency
8
- // * npmjs Link: https://www.npmjs.com/package/concurrency.js
9
- // * File: test.demos.threads.js
10
- // * File Description:
11
- // *
12
- // */
13
-
14
- // /* eslint no-console: 0 */
15
-
16
- // 'use strict';
17
-
18
-
19
- // const expect = require('chai').expect;
20
- // const path = require("path");
21
- // const { _concurrencyThreads } = require("../index.js");
22
-
23
- // describe('test-.js::concurrency.js: [Test A] Test Suite for concurrency.js .threads in main repo directory', function () {
24
-
25
- // it('[Test A] Test for ', function (done) {
26
- // var responses;
27
- // let threads = _concurrencyThreadsAsync("C:\\Users\\GB\\Documents\\projects\\requireurl\\concurrency\\demos\\demos.threads.js", {
28
- // data: {
29
- // message: "Testing parent data",
30
- // url: "https://www.google.com"
31
- // }, childData: "Test data from child"
32
- // });
33
-
34
- // /**
35
- // {
36
- // "message":[
37
- // {"pid":3764,"message":"\"Hello from child. - Thread: 3764","threadId":1},
38
- // {"closeChild":true,"pid":3764,
39
- // "childMessageData":[
40
- // {"pid":3764,"message":"Hello, world! - Server: 3764"},
41
- // {"closeChild":true}
42
- // ],
43
- // "result":[],
44
- // "threadId":1
45
- // }
46
- // ],
47
- // "result":[]
48
- // }
49
- // */
50
-
51
- // expect(threads).to.equal({
52
- // "message": [
53
- // { "pid": 3764, "message": "\"Hello from child. - Thread: 3764", "threadId": 1 },
54
- // {
55
- // "closeChild": true, "pid": 3764,
56
- // "childMessageData": [
57
- // { "pid": 3764, "message": "Hello, world! - Server: 3764" },
58
- // { "closeChild": true }
59
- // ],
60
- // "result": [],
61
- // "threadId": 1
62
- // }],
63
- // "result": []
64
- // });
65
- // done();
66
- // });
67
- // });
68
-