qtools-library-dot-d 1.0.12 → 1.0.13

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 (74) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -0
  3. package/package.json +2 -2
  4. package/libDotD_Working_Example/README.md +0 -234
  5. package/libDotD_Working_Example/demoModules_DotD/demo1.js +0 -46
  6. package/libDotD_Working_Example/demoModules_DotD/demo2.js +0 -48
  7. package/libDotD_Working_Example/index.js +0 -133
  8. package/libDotD_Working_Example/node_modules/.package-lock.json +0 -29
  9. package/libDotD_Working_Example/node_modules/qtools-asynchronous-pipe-plus/README.md +0 -213
  10. package/libDotD_Working_Example/node_modules/qtools-asynchronous-pipe-plus/package.json +0 -20
  11. package/libDotD_Working_Example/node_modules/qtools-asynchronous-pipe-plus/qtools-asynchronous-pipe-plus.js +0 -278
  12. package/libDotD_Working_Example/node_modules/qtools-asynchronous-pipe-plus/test.js +0 -79
  13. package/libDotD_Working_Example/node_modules/qtools-functional-library/README.md +0 -110
  14. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-clone/package.json +0 -11
  15. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-clone/qtools-clone.js +0 -103
  16. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-clone/test.js +0 -78
  17. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-get-by-property/package.json +0 -11
  18. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-get-by-property/qtools-get-by-property.js +0 -73
  19. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-get-by-property/test.js +0 -129
  20. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-includes-regex/package.json +0 -11
  21. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-includes-regex/qtools-includes-regex.js +0 -54
  22. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-includes-regex/test.js +0 -76
  23. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-log-output/package.json +0 -11
  24. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-log-output/qtools-log-output.js +0 -114
  25. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-log-output/test.js +0 -130
  26. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-map-properties/package.json +0 -11
  27. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-map-properties/qtools-map-properties.js +0 -99
  28. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-map-properties/test.js +0 -118
  29. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-merge/package.json +0 -11
  30. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-merge/qtools-merge.js +0 -147
  31. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-merge/test.js +0 -214
  32. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-new-method-template/package.json +0 -11
  33. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-new-method-template/qtools-new-method-template.js +0 -70
  34. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-new-method-template/test.js +0 -66
  35. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-number-iterator/package.json +0 -11
  36. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-number-iterator/qtools-number-iterator.js +0 -137
  37. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-number-iterator/test.js +0 -68
  38. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-number-keys-to-array/package.json +0 -11
  39. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-number-keys-to-array/qtools-number-keys-to-array.js +0 -131
  40. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-number-keys-to-array/test.js +0 -181
  41. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-object-sure-path/package.json +0 -11
  42. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-object-sure-path/qtools-object-sure-path.js +0 -204
  43. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-object-sure-path/test.js +0 -345
  44. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-pass-through/package.json +0 -11
  45. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-pass-through/qtools-pass-through.js +0 -58
  46. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-pass-through/test.js +0 -66
  47. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-pop/package.json +0 -11
  48. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-pop/qtools-pop.js +0 -175
  49. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-pop/test.js +0 -118
  50. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-print-debug/package.json +0 -11
  51. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-print-debug/qtools-print-debug.js +0 -352
  52. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-print-debug/test.js +0 -77
  53. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-select-properties/package.json +0 -11
  54. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-select-properties/qtools-select-properties.js +0 -132
  55. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-select-properties/test.js +0 -156
  56. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-template-replace/README.md +0 -3
  57. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-template-replace/package.json +0 -11
  58. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-template-replace/qtools-template-replace.js +0 -106
  59. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-template-replace/test.js +0 -168
  60. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-to-key-value-array/package.json +0 -11
  61. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-to-key-value-array/qtools-to-key-value-array.js +0 -83
  62. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-to-key-value-array/test.js +0 -68
  63. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-to-string/package.json +0 -11
  64. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-to-string/qtools-to-string.js +0 -84
  65. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-to-string/test.js +0 -63
  66. package/libDotD_Working_Example/node_modules/qtools-functional-library/package.json +0 -37
  67. package/libDotD_Working_Example/node_modules/qtools-functional-library/qtFunctionalDemo.js +0 -297
  68. package/libDotD_Working_Example/node_modules/qtools-functional-library/qtools-functional-library.js +0 -271
  69. package/libDotD_Working_Example/node_modules/qtools-functional-library/test.js +0 -47
  70. package/libDotD_Working_Example/node_modules/qtools-library-dot-d/README.md +0 -208
  71. package/libDotD_Working_Example/node_modules/qtools-library-dot-d/package.json +0 -15
  72. package/libDotD_Working_Example/node_modules/qtools-library-dot-d/qtools-library-dot-d.js +0 -239
  73. package/libDotD_Working_Example/package-lock.json +0 -37
  74. package/libDotD_Working_Example/package.json +0 -23
@@ -1,213 +0,0 @@
1
- ### qtools-asynchronous-pipe
2
-
3
- asynchronousPipe() takes an array of asynchronous functions and executes
4
- them in sequence. As each completes, the next is called with the return
5
- result of the previous function.
6
-
7
- The purpose of the package is to create a joint scope for a series of
8
- asynchronous operations.
9
-
10
- There are two main functions:
11
-
12
- ```
13
- const asynchronousPipePlus=require('qtools-asynchronous-pipe-plus')(); // Note function execution
14
- const pipeRunner = asynchronousPipePlus.pipeRunner;
15
- const taskListPlus = asynchronousPipePlus.taskListPlus;
16
- ```
17
-
18
- It is executed like this:
19
-
20
- ```
21
- const taskList = new taskListPlus();
22
-
23
- taskList.push(someWorkListFunction);
24
-
25
- pipeRunner(taskList.getList(), initialValue, [callback])
26
- ```
27
-
28
- The parameters are:
29
-
30
- taskList:         an array of functions (This can be a normal Array())
31
- initialValue: optional initial value passed to the first function
32
- callback: optional function called after all the other functions are finished
33
-
34
- The workList functions must have the signature:
35
-
36
- (args, next)={
37
- const result= "some functionOf(args), probably the result of an I/O function";
38
- next(err, result); //mandatory
39
- }
40
-
41
- taskListPlus() returns, in addition to push() and getList(), several functions to control the parameters passed between process steps. These are undocumented for now:
42
-
43
- *returnGlobalArgs, getArgsValue, enforceScope, reduceToLocalScope, restoreGlobalScope*
44
-
45
- There is another taskListPlus() function that I used like crazy back in the day whose function is also, for now, undocumented: *addFromDelegate*.
46
-
47
- #### UPDATE 6/7/19
48
-
49
- There is a special value of err, **skipRestOfPipe**, eg:
50
-
51
- ```
52
- next('skipRestOfPipe', result);
53
- ```
54
-
55
- This will do as the symbol says, skip the rest of the pipe. It serves
56
- the role of 'break' in loops. Practically speaking, it immediately calls the
57
- callback function with the current value of result with the error value of 'skipRestOfPipe'.
58
-
59
- It is often good to have special code in the final callback to change a
60
- skipRestOfPipe error status for the next callback in case it's not an
61
- asynchronousPipe and treats it as an error.
62
-
63
- Eg,
64
-
65
- ```
66
- callback(err=='skipRestOfPipe'?'':err, result)
67
- ```
68
-
69
- The optional callback function is called as:
70
-
71
- callback(err, result);
72
-
73
- pipeRunner() does not return anything.
74
-
75
- #### UPDATE: v1.04 (6/6/24)
76
-
77
- There are two new utility functions:
78
-
79
- asynchronousPipePlus.mergeArgs
80
- asynchronousPipePlus.forwardArgs
81
-
82
- These fabricate a callback that makes the args object available
83
- to the rest of the process sequence.
84
-
85
- **mergeArgs is used when a result is expected.** The result is added
86
- to the 'args' object using a string parameter as the property name:
87
-
88
- const mergeArgs = (args, next, propertyName) => (err, result) =>
89
- next(err, {
90
- ...args,
91
- ...(propertyName ? { [propertyName]: result } : result)
92
- });
93
-
94
- It is called like this:
95
-
96
- taskList.push((args, next) => {
97
- const {argsForFunction}=args;
98
- asyncFuncWithCallback(
99
- argsForFunction,
100
- mergeArgs(args, next, 'propertyNameForResult')
101
- );
102
- });
103
-
104
-
105
- taskList.push((args, next) => {
106
- const {propertyNameForResult, otherArgIfAny}=args;
107
-
108
- // ...
109
- });
110
-
111
- **forwardArgs is used when no result parameter is expected:**
112
-
113
- const forwardArgs = ({ next, args }) => err => next(err, args);
114
-
115
- taskList.push((args, next) => {
116
- const {argsForFunction}=args;
117
- asyncFuncWithCallback(
118
- argsForFunction,
119
- forwardArgs({ next, args })
120
- );
121
- });
122
-
123
-
124
- taskList.push((args, next) => {
125
- const {otherArgIfAny}=args;
126
-
127
- // ...
128
- });
129
-
130
- ### ===================================
131
-
132
- ### Misc Example from test.js
133
-
134
- #!/usr/local/bin/node
135
- 'use strict';
136
-
137
- const asynchronousPipePlus = new require('qtools-asynchronous-pipe-plus')();
138
- const pipeRunner = asynchronousPipePlus.pipeRunner;
139
- const taskListPlus = asynchronousPipePlus.taskListPlus;
140
-
141
- const pipeFunction = (inData, callback) => {
142
- const taskList = new taskListPlus();
143
-
144
- taskList.push((args, next) => {
145
- const localCallback = (err, localResult1) => {
146
- if (err == 'someParticularError') {
147
- next('skipRestOfPipe', err);
148
- return;
149
- }
150
- console.dir({ 'only inboundData so far': args });
151
-
152
- args.localResult1 = localResult1;
153
- next(err, args);
154
- };
155
- localCallback('', 'localResult1_value');
156
- });
157
-
158
-
159
- taskList.push((args, next) => {
160
- const localCallback = (err, localResult3) => {
161
- args.localResult3 = localResult3;
162
- next(err, args);
163
- };
164
- console.dir({ 'shows localResult1 and inboundData': args });
165
- localCallback('', 'localResult3_value');
166
- });
167
-
168
- taskList.push(
169
- (args, next) => {
170
- const localCallback = (err, localResult2) => {
171
- args.localResult2 = localResult2;
172
- next(err, args);
173
- };
174
- console.dir({ 'shows localResult1 only': args });
175
- localCallback('', 'localResult2_value');
176
- },
177
- ['localResult1']
178
- );
179
-
180
- taskList.push(taskList.restoreGlobalScope());
181
-
182
- taskList.push((args, next) => {
183
- const localCallback = (err, localResult3) => {
184
- args.localResult3 = localResult3;
185
- next(err, args);
186
- };
187
- console.dir({ 'shows all incoming values, 1, 2, hiding test': args });
188
- localCallback('', 'localResult3_value');
189
- });
190
-
191
- taskList.push(
192
- (args, next) => {
193
- const localCallback = (err, localResult4) => {
194
- args.localResult4 = localResult4;
195
- next(err, args);
196
- };
197
- console.dir({ 'shows localResult1 and inboundData': args });
198
- localCallback('', 'localResult2_value');
199
- },
200
- ['localResult3', 'inboundData']
201
- );
202
-
203
- const initialData = typeof inData != 'undefined' ? inData : {};
204
- pipeRunner(taskList.getList(), initialData, (err, finalResult) => {
205
- console.dir({ 'final: shows localResult3, inboundData, and localResult4': finalResult });
206
- callback(err, finalResult);
207
- });
208
-
209
- };
210
-
211
- pipeFunction({ inboundData: 'inboundData_value' }, (err, result) => {
212
- console.log('if you do not see errors, it works');
213
- });
@@ -1,20 +0,0 @@
1
- {
2
- "name": "qtools-asynchronous-pipe-plus",
3
- "version": "1.0.5",
4
- "description": "Asynchronous-pipe for the future. Includes taskListPlus and utility functions I have learned to like\"",
5
- "main": "qtools-asynchronous-pipe-plus.js",
6
- "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
8
- },
9
- "repository": {
10
- "type": "git",
11
- "url": "git+https://github.com/tqwhite/qtools-asynchronous-pipe-plus.git"
12
- },
13
- "author": "TQ White II",
14
- "licenses": [
15
- {
16
- "type": "MIT",
17
- "url": "https://github.com/evangelion1204/multi-ini/blob/master/LICENSE"
18
- }
19
- ]
20
- }
@@ -1,278 +0,0 @@
1
- 'use strict';
2
-
3
- //START OF moduleFunction() ============================================================
4
-
5
- var moduleFunction = function(args) {
6
- /*
7
-
8
- asynchronousPipe() takes an array of asynchronous functions and executes them
9
- in sequence. As each completes, the next is called with the return result of the
10
- previous function.
11
-
12
- The parameters are:
13
-
14
- workList: an array of functions
15
- initialValue: optional initial value passed to the first function
16
- callback: optional function called after all the other functions are finished
17
-
18
- The workList functions must have the signature:
19
-
20
- (args, next)={
21
- const result= "some functionOf(args), probably the result of an I/O function";
22
- next(err, result); //mandatory
23
- }
24
-
25
- As of 6/7/19, there is a special value of err, skipRestOfPipe, eg:
26
-
27
- next('skipRestOfPipe', result);
28
-
29
- This will do as the symbol says, skip the rest of the pipe. It serves the role of 'continue'
30
- in loops. Practically speaking, it calls the callback with the current value of result and no error.
31
- It is often good to have special code for in the final callback to
32
- change the error status for the next callback in case it's not asynchronousPipe and
33
- treats it as an error. Eg, callback(err=='skipRestOfPipe'?'':err, result)
34
-
35
- The optional callback function is called as:
36
-
37
- callback(err, result);
38
-
39
- asynchronousPipe() does not return anything.
40
-
41
- */
42
-
43
-
44
- // --------------------------------------------------------------------------------
45
- // INTERNAL UTILITIES
46
-
47
- const mergeArgs = (args, next, propertyName) => (err, result) =>
48
- next(err, {
49
- ...args,
50
- ...(propertyName ? { [propertyName]: result } : result)
51
- });
52
-
53
- const forwardArgs = ({ next, args }) => err => next(err, args);
54
-
55
- const isArray=item=>(typeof item=='object' && typeof item.length=='number');
56
-
57
- const logger=message=>{
58
- const suffix='[asynchronousPipe.js]';
59
- if (typeof message=='string'){
60
- console.log(`${message} ${suffix}`)
61
- }
62
- else{
63
-
64
- console.log(`${suffix} =======`)
65
- console.dir(message);
66
- console.log(`======= ${suffix}`)
67
- }
68
-
69
- }
70
-
71
- // asyncPipe(workList, [initialValue,] callback);
72
- const asynchronousPipe = (...args) => {
73
- const workList = args[0];
74
- const callback = args[args.length - 1];
75
-
76
- let initial;
77
- if (args.length == 3) {
78
- initial = args[1];
79
- }
80
-
81
- const recursion = (err, result, workListInx) => {
82
- if (err) {
83
- if (err == 'skipRestOfPipe') {
84
- callback('skipRestOfPipe', result);
85
- return;
86
- } else {
87
- callback(err, result);
88
- return;
89
- }
90
- }
91
-
92
- if (workListInx > workList.length - 1) {
93
- if (typeof callback == 'function') {
94
- callback('', result);
95
- }
96
- return;
97
- }
98
- workList[workListInx](result, (err, result) => {
99
- recursion(err, result, workListInx + 1);
100
- });
101
- };
102
- recursion('', initial, 0);
103
- };
104
-
105
- const taskListPlus = function() {
106
- const taskList = [];
107
- const hiddenArgsName = `asyncPipeHideFromScope${new Date().getTime()}`;
108
-
109
- const addOptions = options => {
110
- if (options.debug) {
111
- switch (options.debug) {
112
- case 'properties':
113
- //{debug:'properties', label:'identifier'}
114
- taskList.push((args, next) => {
115
- logger(
116
- `\nLIST: args (${options.label ? options.label : ''}) =======`
117
- );
118
- logger(Object.keys(args));
119
- logger('======= args\n');
120
- });
121
- break;
122
- case 'fileMarker':
123
- //{debug:'fileMarker', label:'identifier'}
124
- taskList.push((args, next) => {
125
- logger(
126
- `\n=-========= (${
127
- options.label ? options.label : ''
128
- }) =======\n`
129
- );
130
- });
131
- break;
132
- }
133
- }
134
- };
135
-
136
- this.push = function(item, propertyList, options) {
137
- if (isArray(propertyList)) {
138
- taskList.push(this.reduceToLocalScope(propertyList));
139
- }
140
-
141
- if (options) {
142
- addOptions(options);
143
- }
144
- taskList.push(item);
145
- this.length = taskList.length;
146
- };
147
-
148
- this.addFromDelegate = function(
149
- targetFunction,
150
- propertyList,
151
- options = {}
152
- ) {
153
- if (isArray(propertyList)) {
154
- taskList.push(this.reduceToLocalScope(propertyList));
155
- }
156
-
157
- targetFunction();
158
- };
159
-
160
- this.getList = function() {
161
- //returns this tasklist for use with pipeRunner()
162
- return taskList;
163
- };
164
-
165
- const isScopeBad = (
166
- args,
167
- list,
168
- strict = false,
169
- originatingLine = 'no originating line given'
170
- ) => {
171
- const missing = list.filter(name => typeof args[name] == 'undefined');
172
- const extra = Object.keys(args).filter(name => !list.includes(name));
173
- let result = '';
174
-
175
- const missingString = missing.join(', ');
176
- if (missingString && missingString != `${hiddenArgsName}`) {
177
- result = `isScopeBad() found missing parameters: ${missingString} `;
178
- }
179
-
180
- const extraString = extra
181
- .join(', ')
182
- .replace(new RegExp(`(, )*${hiddenArgsName}*`), '');
183
- if (strict && extraString && extraString != hiddenArgsName) {
184
- result += `isScopeBad() found extra parameters: ${extraString} `;
185
- }
186
-
187
- if (result) {
188
- result = `${result} ${originatingLine}`;
189
- logger(result);
190
- }
191
- return result ? result : false;
192
- };
193
-
194
- this.returnGlobalArgs = args => {
195
- const newArgs = Object.assign({}, args[hiddenArgsName], args);
196
- delete newArgs[hiddenArgsName];
197
- return newArgs;
198
- };
199
-
200
- this.getArgsValue = (args, nameList) => {
201
- //extracts values from scope whether hidden or not
202
- return nameList.reduce((result, name) => {
203
- result[name] = args[hiddenArgsName][name]
204
- ? args[hiddenArgsName][name]
205
- : args[name];
206
- return result;
207
- }, {});
208
- };
209
-
210
- this.enforceScope = (propertyList, strict = true) => {
211
- //error if args has properties not allowed for local scope
212
- let e = new Error();
213
- const originatingLine = e.stack.split('\n')[2];
214
- taskList.push((args, next) => {
215
- next(isScopeBad(args, propertyList, strict, originatingLine), args);
216
- });
217
- };
218
-
219
- this.reduceToLocalScope = requiredPropertyList => (args, next) => {
220
- //changes (adds or substracts) elements from local scope
221
- const localCallback = (err, cleanedArgs) => {
222
- next(err, cleanedArgs);
223
- };
224
-
225
- if (args[hiddenArgsName]) {
226
- const tmpArgs = Object.assign({}, args[hiddenArgsName], args);
227
- delete tmpArgs[hiddenArgsName];
228
- args = tmpArgs; //prevent recursing down globalArgs
229
- }
230
-
231
- const validFiles = true;
232
- const cleanedArgs = {};
233
-
234
- requiredPropertyList.forEach(item => {
235
- cleanedArgs[item] = args[item];
236
- });
237
-
238
- const missingElements = requiredPropertyList
239
- .filter(item => typeof cleanedArgs[item] == 'undefined')
240
- .join(', ');
241
-
242
- Object.defineProperty(cleanedArgs, hiddenArgsName, {
243
- value: args,
244
- writable: false,
245
- enumerable: false
246
- });
247
-
248
-
249
- localCallback(
250
- missingElements
251
- ? `MISSING ELEMENTS: ${missingElements} (by reduceToLocalScope())`
252
- : '',
253
- cleanedArgs
254
- );
255
- };
256
- this.restoreGlobalScope = () => (args, next) => {
257
- //returns all properties to the scope
258
- const newArgs = Object.assign({}, args[hiddenArgsName], args);
259
- delete newArgs[hiddenArgsName];
260
- next('', newArgs);
261
- };
262
- return this;
263
- };
264
-
265
- return {
266
- pipeRunner:asynchronousPipe,
267
- asynchronousPipe,
268
- taskListPlus,
269
- mergeArgs,
270
- forwardArgs
271
- };
272
- };
273
-
274
- //END OF moduleFunction() ============================================================
275
-
276
- module.exports = moduleFunction;
277
- //module.exports = new moduleFunction();
278
-
@@ -1,79 +0,0 @@
1
- #!/usr/local/bin/node
2
- 'use strict';
3
-
4
- const asynchronousPipePlus = new require('qtools-asynchronous-pipe-plus')();
5
- const pipeRunner = asynchronousPipePlus.pipeRunner;
6
- const taskListPlus = asynchronousPipePlus.taskListPlus;
7
-
8
- const pipeFunction = (inData, callback) => {
9
- const taskList = new taskListPlus();
10
-
11
- taskList.push((args, next) => {
12
- const localCallback = (err, localResult1) => {
13
- if (err == 'someParticularError') {
14
- next('skipRestOfPipe', err);
15
- return;
16
- }
17
- console.dir({ 'only inboundData so far': args });
18
-
19
- args.localResult1 = localResult1;
20
- next(err, args);
21
- };
22
- localCallback('', 'localResult1_value');
23
- });
24
-
25
-
26
- taskList.push((args, next) => {
27
- const localCallback = (err, localResult3) => {
28
- args.localResult3 = localResult3;
29
- next(err, args);
30
- };
31
- console.dir({ 'shows localResult1 and inboundData': args });
32
- localCallback('', 'localResult3_value');
33
- });
34
-
35
- taskList.push(
36
- (args, next) => {
37
- const localCallback = (err, localResult2) => {
38
- args.localResult2 = localResult2;
39
- next(err, args);
40
- };
41
- console.dir({ 'shows localResult1 only': args });
42
- localCallback('', 'localResult2_value');
43
- },
44
- ['localResult1']
45
- );
46
-
47
- taskList.push(taskList.restoreGlobalScope());
48
-
49
- taskList.push((args, next) => {
50
- const localCallback = (err, localResult3) => {
51
- args.localResult3 = localResult3;
52
- next(err, args);
53
- };
54
- console.dir({ 'shows all incoming values, 1, 2, hiding test': args });
55
- localCallback('', 'localResult3_value');
56
- });
57
-
58
- taskList.push(
59
- (args, next) => {
60
- const localCallback = (err, localResult4) => {
61
- args.localResult4 = localResult4;
62
- next(err, args);
63
- };
64
- console.dir({ 'shows localResult1 and inboundData': args });
65
- localCallback('', 'localResult2_value');
66
- },
67
- ['localResult3', 'inboundData']
68
- );
69
-
70
- const initialData = typeof inData != 'undefined' ? inData : {};
71
- pipeRunner(taskList.getList(), initialData, (err, finalResult) => {
72
- console.dir({ 'final: shows localResult3, inboundData, and localResult4': finalResult });
73
- callback(err, finalResult);
74
- });
75
- };
76
-
77
- pipeFunction({ inboundData: 'inboundData_value' }, (err, result) => {
78
- console.log('if you do not see errors, it works');
79
- });
@@ -1,110 +0,0 @@
1
- ## **qtools-functional-library**
2
-
3
- This is a collection of tools that allow chained operations on various Javascript datatypes.
4
-
5
- In each case, the primary operand is `this`. In most cases, the function takes an argument with parameters to guide the operation.
6
-
7
- Everything else remains compatible.
8
-
9
- **EG,**
10
-
11
- ```
12
- const qt=require('qtools-functional-library');
13
-
14
- qt.help(); // this information and more
15
-
16
- const demo=({a:{b:"Hi from b"}})
17
-
18
- const one=demo
19
-     .qtGetSurePath('a.b')
20
-     .qtDump();//produces 'Hi from b [thisFilename.js]'
21
-
22
- console.log(one); //produces '[object Object]'
23
- ```
24
-
25
- ### **Version 2:**
26
-
27
- qtPassThrough <u>no longer</u> *always* returns the inbound 'this'. If the supplied function
28
- returns a value, that is passed on. This way, any ad hoc function can affect the result chain.
29
-
30
- Version 2.0.1 9/23/24 - removed deep clone in favor of spread operator (which didn't exist when this was written). Should have no effect on functionality.
31
-
32
- EG,
33
-
34
- ```
35
- 'xxx'
36
- .qtPassThrough(item=>item.toUpperCase())
37
- .qtDump(); // -> 'XXX'
38
- ```
39
-
40
- ### **Non-chain utilities:**
41
-
42
- - **qt.help**: Shows this information and more.
43
- - **qt.log**: Writes log entry with suffix identifying the file that generated the output. (See qtLog below for chained version.)
44
-
45
- ### **Get/Set values from an Array:**
46
-
47
- - **qtGetByProperty**: Operates on an array of objects. Retrieves one or more elements based on the value of an object property specified by a dotted path.
48
-
49
- - **qtPop**: Pops the last value off an array. If a default is supplied and there is nothing left on the list, that will be returned. Really good for ArrayOfObjects.qtPop({}).
50
-
51
- - **qtPush**: Pushes a value onto an array and returns the array (unlike normal .push() which returns the length of the array)
52
-
53
- - **qtLast**: Delivers the element that would have been pop'd but does not change the array. Default if none exists.
54
-
55
- - **qtFirst**: Delivers the element zero if it exists but does not change the array. Default if none exists.
56
-
57
- - **qtIncludesRegex**: Operations on a simple array of strings. Retrieves one or more elements based on an regEx match.
58
-
59
- ### **Get/Set values in an Object (or array of Objects)**
60
-
61
- - **qtGetSurePath**: Gets the value of a property based on a dotted string path. No crash if intermediate elements are missing. Provides default. Predates and is prettier to use than optional chaining and supports setting the value.
62
-
63
- - **qtSetSurePath** Sets the value of a property based on a dotted string path. Creates intermediate elements if they are missing.
64
-
65
- - **qtSelectProperties**: Given an Object and an Array of Strings, filters the properties into a new Object with defaults "[{}].qtSelectProperties(outFileDefinition, {moreDefaultValues:{Value:"xxx"}}))" for missing elements. Does the same for an Array of Objects.
66
-
67
- - **qtMapProperties**: Given an Object and a one level Object whose properties are functions, applies each function to the corresponding element. Does the same for an array of Objects.
68
-
69
- ### **Array/Object Conversions:**
70
-
71
- - **qtClone**: Does a deep clone of an object or array.- qtNumberKeysToArray: Converts an object with properties that are numbers to an array, including subordinate properties.
72
-
73
- - **qtToKeyValueArray**: Converts an object to an array of objects of the form, ie, `{["1"]:'one', ["2"]:'two'} => ['one', 'two']`
74
-
75
- - **qtMerge**: Deep merge of two objects including array propterties.
76
-
77
- - **qtToString**: Joins an array with prefix, suffix and separator. Pretty much the same as .join().
78
-
79
- ### **Array/Object Template Replacement:**
80
-
81
- - **qtTemplateReplace**: Takes Object and a `<!template!>` String ()either can be 'this' or the argument). Substitutes from the object properties into the string. If the 'this' is an array of Objects, it does it to all of them.
82
-
83
- ### **Output:**
84
-
85
- - **qtDump**: Prints 'this' and returns it. Good for debugging complicated chains.
86
-
87
- - **qtLog**: Logs message by applying 'this' into the argument which is a <!template!> string. Appends calling file name.
88
-
89
- ### **Misc:**
90
-
91
- - **qtPassThrough**: Sits in a declarative chain and executes an arbitrary function. Returns function result if not undefined, 'this' otherwise. 'this' is available to the function.
92
-
93
- - **qtIterate**: Operates on a number. EG, (5).qtStart(7).qtIncrement(3).qtIterate(item=>item*100)
94
-
95
- ### **Output:**
96
-
97
- 2.0.3 - fixed old error where qtFirst() did not work at all.
98
- 1.1.16 - fixed bug where intermediate path element could be undefined and cause a crash.
99
-
100
- ### **Other Cool Qtools**
101
-
102
- [qtools-asynchronous-pipe-plus](https://www.npmjs.com/package/qtools-asynchronous-pipe-plus)
103
- [qtools-config-file-processor](https://www.npmjs.com/package/qtools-config-file-processor)
104
- [qtools-format-columns](https://www.npmjs.com/package/qtools-format-columns)
105
- [qtools-functional-library](https://www.npmjs.com/package/qtools-functional-library)
106
- [qtools-object-flattener](https://www.npmjs.com/package/qtools-object-flattener)
107
- [qtools-parse-command-line](https://www.npmjs.com/package/qtools-parse-command-line)
108
- [qtools-secure-container](https://www.npmjs.com/package/qtools-secure-container)
109
- [qtools-template-replace-for-files](https://www.npmjs.com/package/qtools-template-replace-for-files)
110
- [qtools-transform-text](https://www.npmjs.com/package/qtools-transform-text)