necessary 10.0.3 → 10.0.4
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 +33 -33
- package/lib/utilities/asynchronous.js +19 -19
- package/package.json +1 -1
- package/src/utilities/asynchronous.js +18 -18
package/README.md
CHANGED
|
@@ -60,13 +60,13 @@ The miscellaneous functions are a special case. They can be treated as above but
|
|
|
60
60
|
|
|
61
61
|
The first two `get()` and `post()` functions make use of the third `request()` function, which is more generic and can be used for arbitrary HTTP requests.
|
|
62
62
|
|
|
63
|
-
* The `get()` function sends a `GET` request, taking `host`, `uri`, `query` and `
|
|
63
|
+
* The `get()` function sends a `GET` request, taking `host`, `uri`, `query` and `operation` arguments, together with an optional `headers` argument after the `query` argument.
|
|
64
64
|
|
|
65
65
|
The `query` argument should be a plain old JavaScript object, the names and values of which are encoded and concatenated to form the query string.
|
|
66
66
|
|
|
67
67
|
The `headers` argument should also be a plain old JavaScript object. If it does not have an `accept` property then one wil be provided with the value `application/json`.
|
|
68
68
|
|
|
69
|
-
The `
|
|
69
|
+
The `operation` argument is expected to be a function taking `contnet` and `statusCode` arguments. If the `accept` property of the main `headers` argument is set to `application/json` then the operation's `content` argument can be assumed to be JSON, or `null` if the request body cannot be parsed as such. The `statusCode` argument will be the response status code, for example `200` for a successful `OK` response.
|
|
70
70
|
|
|
71
71
|
```
|
|
72
72
|
const host = "...",
|
|
@@ -147,7 +147,7 @@ const offEXT = onEXT(process.exit);
|
|
|
147
147
|
offEXT();
|
|
148
148
|
```
|
|
149
149
|
|
|
150
|
-
* The `prompt()` function is meant for use in shell applications. It takes a plain old JavaScript `options` object and a `callback` function as
|
|
150
|
+
* The `prompt()` function is meant for use in shell applications. It takes a plain old JavaScript `options` object and a `callback` function as its first and second arguments, respectively:
|
|
151
151
|
|
|
152
152
|
```
|
|
153
153
|
const hidden = true,
|
|
@@ -835,14 +835,14 @@ Ideally the `host` argument should not include a trailing forward slash whereas
|
|
|
835
835
|
- `eventually()`
|
|
836
836
|
- `repeatedly()`
|
|
837
837
|
|
|
838
|
-
These functions generally take either a
|
|
838
|
+
These functions generally take either a operatio or an array of operations, functions that mutate a context essentially, rather than returning a value, followed by a `done()` function and an optional `context` argument. They all pass a `next()` function to the operations followed by the `done()` function, the `context` and then an `index` argument. Operations are given access to the `done()` function which can be called instead of the `next()` function in order to terminate early.
|
|
839
839
|
|
|
840
|
-
* The `whilst()` function takes a single
|
|
840
|
+
* The `whilst()` function takes a single operation, which it calls each time the operation invokes the given `next()` function or until the operation invokes the given `done()` function. The operation can also force termination by returning a truthy value, in which case it must *not* call the given `next()` or `done()` functions. In the example below the operation will be executed ten times:
|
|
841
841
|
|
|
842
842
|
```
|
|
843
843
|
const context = {}; ///
|
|
844
844
|
|
|
845
|
-
const
|
|
845
|
+
const operation = (next, done, context, index) => {
|
|
846
846
|
const terminate = (index === 9);
|
|
847
847
|
|
|
848
848
|
if (terminate) {
|
|
@@ -854,17 +854,17 @@ const callback = (next, done, context, index) => {
|
|
|
854
854
|
}
|
|
855
855
|
}
|
|
856
856
|
|
|
857
|
-
whilst(
|
|
857
|
+
whilst(operation, () => {
|
|
858
858
|
/// done
|
|
859
859
|
}, context);
|
|
860
860
|
```
|
|
861
861
|
|
|
862
|
-
* The `forEach()` function takes an array as the first argument followed by a single
|
|
862
|
+
* The `forEach()` function takes an array as the first argument followed by a single operation, which it calls for each element of the array unless the operation invokes the given `done()` function. If the `done()` function is never invoked by the operation, it is called once each of the array elements has been passed to the operation, provided the operationinvokes the given `next ()` function each time. In the example below the operation will be executed four times:
|
|
863
863
|
|
|
864
864
|
```
|
|
865
865
|
const context = {};
|
|
866
866
|
|
|
867
|
-
const
|
|
867
|
+
const operation = (element, next, done, context, index) => {
|
|
868
868
|
const terminate = (element === 3);
|
|
869
869
|
|
|
870
870
|
if (terminate) {
|
|
@@ -878,56 +878,56 @@ const callback = (element, next, done, context, index) => {
|
|
|
878
878
|
|
|
879
879
|
const array = [0, 1, 2, 3, 4, 5];
|
|
880
880
|
|
|
881
|
-
forEach(array,
|
|
881
|
+
forEach(array, operation, () => {
|
|
882
882
|
/// done
|
|
883
883
|
}, context);
|
|
884
884
|
```
|
|
885
885
|
|
|
886
|
-
* The `sequence()` function takes an array of
|
|
886
|
+
* The `sequence()` function takes an array of operations, which it calls in turn unless the operation invokes the given `done()` function. If the `done()` function is never invoked by a operation, it is called once each of the operations have been called, provided each operation invokes the given `next ()` function. In the example below each of the operations bar the last is executed:
|
|
887
887
|
|
|
888
888
|
```
|
|
889
889
|
const context = {};
|
|
890
890
|
|
|
891
|
-
const
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
891
|
+
const firstOperation = (next, done, context, index) => { next(); },
|
|
892
|
+
secondOperation = (next, done, context, index) => { next(); },
|
|
893
|
+
thirdOperation = (next, done, context, index) => { done(); },
|
|
894
|
+
lastOperation = (next, done, context, index) => { next(); },
|
|
895
|
+
operation = [
|
|
896
|
+
firstOperation,
|
|
897
|
+
secondOperation,
|
|
898
|
+
thirdOperation,
|
|
899
|
+
lastOperation
|
|
900
900
|
];
|
|
901
901
|
|
|
902
|
-
sequence(
|
|
902
|
+
sequence(operations, () => {
|
|
903
903
|
/// done
|
|
904
904
|
}, context);
|
|
905
905
|
```
|
|
906
906
|
|
|
907
|
-
* The `eventually()` function takes an array of
|
|
907
|
+
* The `eventually()` function takes an array of operations, each of which it calls immediately without waiting for the operations to invoke the given `next()` functions. When each of the operations has invoked the given `next()` function, it will call the `done()` function. Note that in this case invoking the `done()` function from within a operation will not halt the execution of other operations, it is passed as an argument only for the sake of convention. In the example below each of the operations is executed:
|
|
908
908
|
|
|
909
909
|
```
|
|
910
910
|
const context = {};
|
|
911
911
|
|
|
912
|
-
const
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
912
|
+
const firstOperation = (next, done, context, index) => { next(); },
|
|
913
|
+
secondOperation = (next, done, context, index) => { next(); },
|
|
914
|
+
thirdOperation = (next, done, context, index) => { done(); },
|
|
915
|
+
operations = [
|
|
916
|
+
firstOperation,
|
|
917
|
+
secondOperation,
|
|
918
|
+
thirdOperation
|
|
919
919
|
];
|
|
920
920
|
|
|
921
|
-
eventually(
|
|
921
|
+
eventually(operations, () => {
|
|
922
922
|
/// done
|
|
923
923
|
}, context);
|
|
924
924
|
```
|
|
925
|
-
* The `repeatedly()` function takes a single
|
|
925
|
+
* The `repeatedly()` function takes a single operation and a `length` parameter, immediately calling the operation a `length` number of times without waiting for it to invoke the given `next()` function each time. When the operation has invoked the given `next()` function a `length` number of times, it will call the `done()` function. Note that in this case invoking the `done()` function from within the operation will not halt its execution the requisite number of times, it is passed as an argument only for the sake of convention. In the example below the operation is executed ten times:
|
|
926
926
|
|
|
927
927
|
```
|
|
928
928
|
const context = {};
|
|
929
929
|
|
|
930
|
-
const
|
|
930
|
+
const operation = (next, done, context, index) => {
|
|
931
931
|
...
|
|
932
932
|
|
|
933
933
|
next();
|
|
@@ -935,7 +935,7 @@ const callback = (next, done, context, index) => {
|
|
|
935
935
|
|
|
936
936
|
const length = 10;
|
|
937
937
|
|
|
938
|
-
repeatedly(
|
|
938
|
+
repeatedly(operation, length, () => {
|
|
939
939
|
// done
|
|
940
940
|
}, context);
|
|
941
941
|
```
|
|
@@ -10,18 +10,18 @@ exports.repeatedly = repeatedly;
|
|
|
10
10
|
exports.forwardsForEach = forwardsForEach;
|
|
11
11
|
exports.backwardsForEach = backwardsForEach;
|
|
12
12
|
exports.default = void 0;
|
|
13
|
-
function whilst(
|
|
13
|
+
function whilst(operation, done, context) {
|
|
14
14
|
var count = -1;
|
|
15
15
|
function next() {
|
|
16
16
|
count++;
|
|
17
|
-
var index = count, terminate =
|
|
17
|
+
var index = count, terminate = operation(next, done, context, index);
|
|
18
18
|
if (terminate) {
|
|
19
19
|
done();
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
next();
|
|
23
23
|
}
|
|
24
|
-
function forEach(array,
|
|
24
|
+
function forEach(array, operation, done, context) {
|
|
25
25
|
var length = array.length; ///
|
|
26
26
|
var count = -1;
|
|
27
27
|
function next() {
|
|
@@ -31,13 +31,13 @@ function forEach(array, callback, done, context) {
|
|
|
31
31
|
done();
|
|
32
32
|
} else {
|
|
33
33
|
var index = count, element = array[index];
|
|
34
|
-
|
|
34
|
+
operation(element, next, done, context, index);
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
next();
|
|
38
38
|
}
|
|
39
|
-
function sequence(
|
|
40
|
-
var length =
|
|
39
|
+
function sequence(operations, done, context) {
|
|
40
|
+
var length = operations.length; ///
|
|
41
41
|
var count = -1;
|
|
42
42
|
function next() {
|
|
43
43
|
count++;
|
|
@@ -45,13 +45,13 @@ function sequence(callbacks, done, context) {
|
|
|
45
45
|
if (terminate) {
|
|
46
46
|
done();
|
|
47
47
|
} else {
|
|
48
|
-
var index = count,
|
|
49
|
-
|
|
48
|
+
var index = count, operation = operations[index];
|
|
49
|
+
operation(next, done, context, index);
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
next();
|
|
53
53
|
}
|
|
54
|
-
function eventually(
|
|
54
|
+
function eventually(operations, done, context) {
|
|
55
55
|
var next = function next() {
|
|
56
56
|
count++;
|
|
57
57
|
var terminate = count === length;
|
|
@@ -59,13 +59,13 @@ function eventually(callbacks, done, context) {
|
|
|
59
59
|
done();
|
|
60
60
|
}
|
|
61
61
|
};
|
|
62
|
-
var length =
|
|
62
|
+
var length = operations.length; ///
|
|
63
63
|
var count = 0;
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
operations.forEach(function(operation, index) {
|
|
65
|
+
operation(next, done, context, index);
|
|
66
66
|
});
|
|
67
67
|
}
|
|
68
|
-
function repeatedly(
|
|
68
|
+
function repeatedly(operation, length, done, context) {
|
|
69
69
|
var next = function next() {
|
|
70
70
|
count++;
|
|
71
71
|
var terminate = count === length;
|
|
@@ -75,10 +75,10 @@ function repeatedly(callback, length, done, context) {
|
|
|
75
75
|
};
|
|
76
76
|
var count = 0;
|
|
77
77
|
for(var index = 0; index < length; index++){
|
|
78
|
-
|
|
78
|
+
operation(next, done, context, index);
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
|
-
function forwardsForEach(array,
|
|
81
|
+
function forwardsForEach(array, operation, done, context) {
|
|
82
82
|
var length = array.length; ///
|
|
83
83
|
var count = -1;
|
|
84
84
|
function next() {
|
|
@@ -88,12 +88,12 @@ function forwardsForEach(array, callback, done, context) {
|
|
|
88
88
|
done();
|
|
89
89
|
} else {
|
|
90
90
|
var index = count, element = array[index];
|
|
91
|
-
|
|
91
|
+
operation(element, next, done, context, index);
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
next();
|
|
95
95
|
}
|
|
96
|
-
function backwardsForEach(array,
|
|
96
|
+
function backwardsForEach(array, operation, done, context) {
|
|
97
97
|
var length = array.length; ///
|
|
98
98
|
var count = length;
|
|
99
99
|
function next() {
|
|
@@ -103,7 +103,7 @@ function backwardsForEach(array, callback, done, context) {
|
|
|
103
103
|
done();
|
|
104
104
|
} else {
|
|
105
105
|
var index = count, element = array[index];
|
|
106
|
-
|
|
106
|
+
operation(element, next, done, context, index);
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
next();
|
|
@@ -119,4 +119,4 @@ var _default = {
|
|
|
119
119
|
};
|
|
120
120
|
exports.default = _default;
|
|
121
121
|
|
|
122
|
-
//# sourceMappingURL=data:application/json;charset=utf-8;base64,
|
|
122
|
+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlsaXRpZXMvYXN5bmNocm9ub3VzLmpzIl0sInNvdXJjZXNDb250ZW50IjpbIlwidXNlIHN0cmljdFwiO1xyXG5cclxuZXhwb3J0IGZ1bmN0aW9uIHdoaWxzdChvcGVyYXRpb24sI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Q0FBQztJQUNILENBQUM7SUFFREQsSUFBSTtBQUNOLENBQUM7ZUFFYyxDQUFDO0lBQ2RYLE1BQU0sRUFBTkEsTUFBTTtJQUNOQyxPQUFPLEVBQVBBLE9BQU87SUFDUEMsUUFBUSxFQUFSQSxRQUFRO0lBQ1JDLFVBQVUsRUFBVkEsVUFBVTtJQUNWQyxVQUFVLEVBQVZBLFVBQVU7SUFDVkMsZUFBZSxFQUFmQSxlQUFlO0lBQ2ZDLGdCQUFnQixFQUFoQkEsZ0JBQWdCO0FBQ2xCLENBQUMifQ==
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
export function whilst(
|
|
3
|
+
export function whilst(operation, done, context) {
|
|
4
4
|
let count = -1;
|
|
5
5
|
|
|
6
6
|
function next() {
|
|
7
7
|
count++;
|
|
8
8
|
|
|
9
9
|
const index = count, ///
|
|
10
|
-
terminate =
|
|
10
|
+
terminate = operation(next, done, context, index);
|
|
11
11
|
|
|
12
12
|
if (terminate) {
|
|
13
13
|
done();
|
|
@@ -17,7 +17,7 @@ export function whilst(callback, done, context) {
|
|
|
17
17
|
next();
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
export function forEach(array,
|
|
20
|
+
export function forEach(array, operation, done, context) {
|
|
21
21
|
const length = array.length; ///
|
|
22
22
|
|
|
23
23
|
let count = -1;
|
|
@@ -33,15 +33,15 @@ export function forEach(array, callback, done, context) {
|
|
|
33
33
|
const index = count, ///
|
|
34
34
|
element = array[index];
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
operation(element, next, done, context, index);
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
next();
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
export function sequence(
|
|
44
|
-
const length =
|
|
43
|
+
export function sequence(operations, done, context) {
|
|
44
|
+
const length = operations.length; ///
|
|
45
45
|
|
|
46
46
|
let count = -1;
|
|
47
47
|
|
|
@@ -54,17 +54,17 @@ export function sequence(callbacks, done, context) {
|
|
|
54
54
|
done();
|
|
55
55
|
} else {
|
|
56
56
|
const index = count, ///
|
|
57
|
-
|
|
57
|
+
operation = operations[index];
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
operation(next, done, context, index);
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
next();
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
export function eventually(
|
|
67
|
-
const length =
|
|
66
|
+
export function eventually(operations, done, context) {
|
|
67
|
+
const length = operations.length; ///
|
|
68
68
|
|
|
69
69
|
let count = 0;
|
|
70
70
|
|
|
@@ -78,12 +78,12 @@ export function eventually(callbacks, done, context) {
|
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
operations.forEach((operation, index) => {
|
|
82
|
+
operation(next, done, context, index);
|
|
83
83
|
});
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
export function repeatedly(
|
|
86
|
+
export function repeatedly(operation, length, done, context) {
|
|
87
87
|
let count = 0;
|
|
88
88
|
|
|
89
89
|
function next() {
|
|
@@ -97,11 +97,11 @@ export function repeatedly(callback, length, done, context) {
|
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
for (let index = 0; index < length; index++) {
|
|
100
|
-
|
|
100
|
+
operation(next, done, context, index);
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
export function forwardsForEach(array,
|
|
104
|
+
export function forwardsForEach(array, operation, done, context) {
|
|
105
105
|
const length = array.length; ///
|
|
106
106
|
|
|
107
107
|
let count = -1;
|
|
@@ -117,14 +117,14 @@ export function forwardsForEach(array, callback, done, context) {
|
|
|
117
117
|
const index = count, ///
|
|
118
118
|
element = array[index];
|
|
119
119
|
|
|
120
|
-
|
|
120
|
+
operation(element, next, done, context, index);
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
next();
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
export function backwardsForEach(array,
|
|
127
|
+
export function backwardsForEach(array, operation, done, context) {
|
|
128
128
|
const length = array.length; ///
|
|
129
129
|
|
|
130
130
|
let count = length;
|
|
@@ -140,7 +140,7 @@ export function backwardsForEach(array, callback, done, context) {
|
|
|
140
140
|
const index = count, ///
|
|
141
141
|
element = array[index];
|
|
142
142
|
|
|
143
|
-
|
|
143
|
+
operation(element, next, done, context, index);
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
|