qtools-library-dot-d 1.0.8 → 1.0.9

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/README.md +1 -0
  2. package/libDotD_Working_Example/README.md +234 -0
  3. package/libDotD_Working_Example/demoModules_DotD/demo1.js +46 -0
  4. package/libDotD_Working_Example/demoModules_DotD/demo2.js +48 -0
  5. package/libDotD_Working_Example/index.js +133 -0
  6. package/libDotD_Working_Example/node_modules/.package-lock.json +29 -0
  7. package/libDotD_Working_Example/node_modules/qtools-asynchronous-pipe-plus/README.md +213 -0
  8. package/libDotD_Working_Example/node_modules/qtools-asynchronous-pipe-plus/package.json +20 -0
  9. package/libDotD_Working_Example/node_modules/qtools-asynchronous-pipe-plus/qtools-asynchronous-pipe-plus.js +278 -0
  10. package/libDotD_Working_Example/node_modules/qtools-asynchronous-pipe-plus/test.js +79 -0
  11. package/libDotD_Working_Example/node_modules/qtools-functional-library/README.md +110 -0
  12. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-clone/package.json +11 -0
  13. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-clone/qtools-clone.js +103 -0
  14. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-clone/test.js +78 -0
  15. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-get-by-property/package.json +11 -0
  16. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-get-by-property/qtools-get-by-property.js +73 -0
  17. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-get-by-property/test.js +129 -0
  18. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-includes-regex/package.json +11 -0
  19. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-includes-regex/qtools-includes-regex.js +54 -0
  20. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-includes-regex/test.js +76 -0
  21. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-log-output/package.json +11 -0
  22. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-log-output/qtools-log-output.js +114 -0
  23. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-log-output/test.js +130 -0
  24. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-map-properties/package.json +11 -0
  25. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-map-properties/qtools-map-properties.js +99 -0
  26. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-map-properties/test.js +118 -0
  27. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-merge/package.json +11 -0
  28. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-merge/qtools-merge.js +147 -0
  29. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-merge/test.js +214 -0
  30. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-new-method-template/package.json +11 -0
  31. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-new-method-template/qtools-new-method-template.js +70 -0
  32. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-new-method-template/test.js +66 -0
  33. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-number-iterator/package.json +11 -0
  34. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-number-iterator/qtools-number-iterator.js +137 -0
  35. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-number-iterator/test.js +68 -0
  36. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-number-keys-to-array/package.json +11 -0
  37. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-number-keys-to-array/qtools-number-keys-to-array.js +131 -0
  38. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-number-keys-to-array/test.js +181 -0
  39. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-object-sure-path/package.json +11 -0
  40. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-object-sure-path/qtools-object-sure-path.js +204 -0
  41. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-object-sure-path/test.js +345 -0
  42. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-pass-through/package.json +11 -0
  43. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-pass-through/qtools-pass-through.js +58 -0
  44. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-pass-through/test.js +66 -0
  45. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-pop/package.json +11 -0
  46. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-pop/qtools-pop.js +175 -0
  47. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-pop/test.js +118 -0
  48. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-print-debug/package.json +11 -0
  49. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-print-debug/qtools-print-debug.js +352 -0
  50. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-print-debug/test.js +77 -0
  51. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-select-properties/package.json +11 -0
  52. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-select-properties/qtools-select-properties.js +132 -0
  53. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-select-properties/test.js +156 -0
  54. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-template-replace/README.md +3 -0
  55. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-template-replace/package.json +11 -0
  56. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-template-replace/qtools-template-replace.js +106 -0
  57. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-template-replace/test.js +168 -0
  58. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-to-key-value-array/package.json +11 -0
  59. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-to-key-value-array/qtools-to-key-value-array.js +83 -0
  60. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-to-key-value-array/test.js +68 -0
  61. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-to-string/package.json +11 -0
  62. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-to-string/qtools-to-string.js +84 -0
  63. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-to-string/test.js +63 -0
  64. package/libDotD_Working_Example/node_modules/qtools-functional-library/package.json +37 -0
  65. package/libDotD_Working_Example/node_modules/qtools-functional-library/qtFunctionalDemo.js +297 -0
  66. package/libDotD_Working_Example/node_modules/qtools-functional-library/qtools-functional-library.js +271 -0
  67. package/libDotD_Working_Example/node_modules/qtools-functional-library/test.js +47 -0
  68. package/libDotD_Working_Example/node_modules/qtools-library-dot-d/README.md +208 -0
  69. package/libDotD_Working_Example/node_modules/qtools-library-dot-d/package.json +15 -0
  70. package/libDotD_Working_Example/node_modules/qtools-library-dot-d/qtools-library-dot-d.js +239 -0
  71. package/libDotD_Working_Example/package-lock.json +37 -0
  72. package/libDotD_Working_Example/package.json +23 -0
  73. package/package.json +1 -1
  74. package/qtools-library-dot-d.js +1 -1
@@ -0,0 +1,345 @@
1
+ 'use strict';
2
+
3
+ //START OF moduleFunction() ============================================================
4
+
5
+ const moduleFunction = function(args) {
6
+ //this module is initialized with parameters spec'd in the main function module
7
+
8
+ const completeStepActual = ({
9
+ verbose = false,
10
+ logErrors = false,
11
+ moduleName
12
+ }) => (methodName, thisStepMessage, thisStepResult, thisStepEvalFunction) => {
13
+ const thisStepPass = thisStepEvalFunction(thisStepResult);
14
+
15
+ if (logErrors && !thisStepPass) {
16
+ console.log(`FAIL TEST: ${thisStepMessage} in ...${moduleName}`);
17
+ }
18
+ if (verbose) {
19
+ console.log(`Result for: ${methodName} ${thisStepMessage} (${thisStepPass?'PASS':'FAIL'}):`);
20
+ console.dir(thisStepResult);
21
+ console.log('\n\n');
22
+ }
23
+
24
+ return passingTests && thisStepPass;
25
+ };
26
+
27
+ const completeStep = completeStepActual(args);
28
+
29
+ let passingTests = true;
30
+
31
+ let thisStepMessage;
32
+ let thisStepResult;
33
+ let thisStepEvalFunction;
34
+ let methodName;
35
+
36
+ //TESTS ============================================================
37
+
38
+
39
+ const testArray = {
40
+ data: {
41
+ studentReport: {
42
+ rows: [
43
+ {
44
+ student: {
45
+ id: '7369',
46
+ firstName: 'Harry',
47
+ middleName: 'Z.',
48
+ lastName: 'Krazy',
49
+ suffix: '',
50
+ gender: 'Male'
51
+ },
52
+ testScores: [
53
+ {
54
+ testId: '10',
55
+ testName: 'MN - Accountability Tests',
56
+ variant: {
57
+ id: '10001',
58
+ name: 'MCA II'
59
+ },
60
+ season: {
61
+ id: '2901',
62
+ name: '2018-2019'
63
+ },
64
+ outline: {
65
+ id: '100001',
66
+ name: 'Math',
67
+ parentId: null,
68
+ level: 1
69
+ },
70
+ gradeLevel: null,
71
+ dateTaken: null,
72
+ scoreType: {
73
+ id: '1009',
74
+ name: 'Scale Score'
75
+ },
76
+ score: null,
77
+ altScore: null,
78
+ performanceScales: []
79
+ },
80
+ {
81
+ testId: '10',
82
+ testName: 'MN - Accountability Tests',
83
+ variant: {
84
+ id: '10005',
85
+ name: 'MCA III'
86
+ },
87
+ season: {
88
+ id: '2901',
89
+ name: '2018-2019'
90
+ },
91
+ outline: {
92
+ id: '100001',
93
+ name: 'Math',
94
+ parentId: null,
95
+ level: 1
96
+ },
97
+ gradeLevel: '05',
98
+ dateTaken:
99
+ 'Sun Mar 03 2019 18:00:00 GMT-0600 (Central Standard Time)',
100
+ scoreType: {
101
+ id: '1009',
102
+ name: 'Scale Score'
103
+ },
104
+ score: 549,
105
+ altScore: null,
106
+ performanceScales: [
107
+ {
108
+ performanceSet: {
109
+ id: '1001',
110
+ name: 'Proficiency'
111
+ },
112
+ performanceValue: 'Partially Meets'
113
+ },
114
+ {
115
+ performanceSet: {
116
+ id: '1005',
117
+ name: 'Career and College Readiness'
118
+ },
119
+ performanceValue: 'N/A'
120
+ }
121
+ ]
122
+ }
123
+ ]
124
+ },
125
+ {
126
+ student: {
127
+ id: '9748',
128
+ firstName: 'Julie',
129
+ middleName: 'T.',
130
+ lastName: 'Blue',
131
+ suffix: '',
132
+ gender: 'Female'
133
+ },
134
+ testScores: [
135
+ {
136
+ testId: '10',
137
+ testName: 'MN - Accountability Tests',
138
+ variant: {
139
+ id: '10001',
140
+ name: 'MCA II'
141
+ },
142
+ season: {
143
+ id: '2901',
144
+ name: '2018-2019'
145
+ },
146
+ outline: {
147
+ id: '100001',
148
+ name: 'Math',
149
+ parentId: null,
150
+ level: 1
151
+ },
152
+ gradeLevel: null,
153
+ dateTaken: null,
154
+ scoreType: {
155
+ id: '1009',
156
+ name: 'Scale Score'
157
+ },
158
+ score: null,
159
+ altScore: null,
160
+ performanceScales: []
161
+ },
162
+ {
163
+ testId: '10',
164
+ testName: 'MN - Accountability Tests',
165
+ variant: {
166
+ id: '10005',
167
+ name: 'MCA III'
168
+ },
169
+ season: {
170
+ id: '2901',
171
+ name: '2018-2019'
172
+ },
173
+ outline: {
174
+ id: '100001',
175
+ name: 'Math',
176
+ parentId: null,
177
+ level: 1
178
+ },
179
+ gradeLevel: '05',
180
+ dateTaken:
181
+ 'Sun Mar 03 2019 18:00:00 GMT-0600 (Central Standard Time)',
182
+ scoreType: {
183
+ id: '1009',
184
+ name: 'Scale Score'
185
+ },
186
+ score: 544,
187
+ altScore: null,
188
+ performanceScales: [
189
+ {
190
+ performanceSet: {
191
+ id: '1001',
192
+ name: 'Proficiency'
193
+ },
194
+ performanceValue: 'Partially Meets'
195
+ },
196
+ {
197
+ performanceSet: {
198
+ id: '1005',
199
+ name: 'Career and College Readiness'
200
+ },
201
+ performanceValue: 'N/A'
202
+ }
203
+ ]
204
+ }
205
+ ]
206
+ },
207
+ {
208
+ student: {
209
+ id: '1387',
210
+ firstName: 'Virtue',
211
+ middleName: 'H.',
212
+ lastName: 'RosiePosie',
213
+ suffix: '',
214
+ gender: 'Female'
215
+ },
216
+ testScores: [
217
+ {
218
+ testId: '10',
219
+ testName: 'MN - Accountability Tests',
220
+ variant: {
221
+ id: '10001',
222
+ name: 'MCA II'
223
+ },
224
+ season: {
225
+ id: '2901',
226
+ name: '2018-2019'
227
+ },
228
+ outline: {
229
+ id: '100001',
230
+ name: 'Math',
231
+ parentId: null,
232
+ level: 1
233
+ },
234
+ gradeLevel: null,
235
+ dateTaken: null,
236
+ scoreType: {
237
+ id: '1009',
238
+ name: 'Scale Score'
239
+ },
240
+ score: null,
241
+ altScore: null,
242
+ performanceScales: []
243
+ },
244
+ {
245
+ testId: '10',
246
+ testName: 'MN - Accountability Tests',
247
+ variant: {
248
+ id: '10005',
249
+ name: 'MCA III'
250
+ },
251
+ season: {
252
+ id: '2901',
253
+ name: '2018-2019'
254
+ },
255
+ outline: {
256
+ id: '100001',
257
+ name: 'Math',
258
+ parentId: null,
259
+ level: 1
260
+ },
261
+ gradeLevel: '05',
262
+ dateTaken:
263
+ 'Sun Mar 03 2019 18:00:00 GMT-0600 (Central Standard Time)',
264
+ scoreType: {
265
+ id: '1009',
266
+ name: 'Scale Score'
267
+ },
268
+ score: 531,
269
+ altScore: null,
270
+ performanceScales: [
271
+ {
272
+ performanceSet: {
273
+ id: '1001',
274
+ name: 'Proficiency'
275
+ },
276
+ performanceValue: 'Does Not Meet'
277
+ },
278
+ {
279
+ performanceSet: {
280
+ id: '1005',
281
+ name: 'Career and College Readiness'
282
+ },
283
+ performanceValue: 'N/A'
284
+ }
285
+ ]
286
+ }
287
+ ]
288
+ }
289
+ ]
290
+ }
291
+ }
292
+ };
293
+
294
+
295
+ //TEST ITEM ------------------------------------------------------
296
+ methodName = 'qtGetSurePath';
297
+ thisStepMessage = 'not yet implemented';
298
+ thisStepResult = testArray[methodName]('data.studentReport.rows', []);
299
+ thisStepEvalFunction = item => item.length==3;
300
+ passingTests =
301
+ completeStep(
302
+ methodName,
303
+ thisStepMessage,
304
+ thisStepResult,
305
+ thisStepEvalFunction
306
+ ) && passingTests;
307
+
308
+
309
+ methodName = 'qtPutSurePath';
310
+ thisStepMessage = 'not yet implemented';
311
+ thisStepResult = testArray[methodName]('data.studentReport.rows[0].student.id', 9999);
312
+ thisStepEvalFunction = item => item.qtGetSurePath('data.studentReport.rows[0].student.id')==9999;
313
+ passingTests =
314
+ completeStep(
315
+ methodName,
316
+ thisStepMessage,
317
+ thisStepResult,
318
+ thisStepEvalFunction
319
+ ) && passingTests;
320
+
321
+
322
+
323
+ methodName = 'qtPutSurePath';
324
+ thisStepMessage = 'avoid prototype polution';
325
+ thisStepResult = testArray[methodName]('__proto__', 9999);
326
+ thisStepEvalFunction = item => item.qtGetSurePath('__proto__')!=9999;
327
+ passingTests =
328
+ completeStep(
329
+ methodName,
330
+ thisStepMessage,
331
+ thisStepResult,
332
+ thisStepEvalFunction
333
+ ) && passingTests;
334
+
335
+
336
+
337
+
338
+ return passingTests;
339
+ };
340
+
341
+ //END OF moduleFunction() ============================================================
342
+
343
+ module.exports = moduleFunction;
344
+ //module.exports = new moduleFunction();
345
+
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "qtools-pass-through",
3
+ "version": "1.0.0",
4
+ "description": "executes a supplied function but never changes the value supplied",
5
+ "main": "qtools-pass-through.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "author": "TQ White II",
10
+ "license": "ISC"
11
+ }
@@ -0,0 +1,58 @@
1
+ 'use strict';
2
+ //START OF moduleFunction() ============================================================
3
+ var moduleFunction = function (args = {}) {
4
+ const { commonFunctions } = args;
5
+
6
+ const addToPrototypeActual = (functionObject) => () =>
7
+ commonFunctions.universalAddToPrototype(commonFunctions, functionObject);
8
+
9
+ //first method definition function ==========================
10
+ const firstMethodFunction = (commonFunctions) => {
11
+ const functionObject = new Map(); // prettier-ignore
12
+
13
+ const methodName = 'qtPassThrough';
14
+ const description = `executes a supplied function; 'this' is the only parameter; if supplied function returns a value, it is returned, else 'this' is returned.`;
15
+ const supportedTypeList = [Object, Array, String, Number, Boolean, Date];
16
+
17
+ const method = () =>
18
+ function (utilityFunction) {
19
+ //if one of the supportedTypeList elements is Object, basically all data types will have this method and type checking is important.
20
+ if (!commonFunctions.isSupportedType(this, supportedTypeList)) {
21
+ // prettier-ignore
22
+ throw new Error(
23
+ `${methodName}(): unsupported data type: '${commonFunctions.toType(this)}' (${methodName} supports ${supportedTypeList.map(item=>item.toString().replace(/.*function (.*?)\(\).*/, '$1')).join(', ')})`
24
+ );
25
+ }
26
+
27
+ const utilityResult = utilityFunction(this);
28
+ if (utilityResult!=undefined) {
29
+ return utilityResult;
30
+ } else {
31
+ return this;
32
+ }
33
+ };
34
+
35
+ functionObject.set(methodName, {
36
+ description,
37
+ supportedTypeList,
38
+ method,
39
+ test: (args) => {
40
+ return require('./test.js')({
41
+ ...args,
42
+ ...{
43
+ moduleName: module.id.replace(module.path, ''),
44
+ },
45
+ });
46
+ },
47
+ });
48
+
49
+ return functionObject;
50
+ };
51
+ this.addToPrototype = addToPrototypeActual(
52
+ firstMethodFunction(commonFunctions),
53
+ );
54
+
55
+ };
56
+ //END OF moduleFunction() ============================================================
57
+ module.exports = moduleFunction;
58
+ //module.exports = new moduleFunction();
@@ -0,0 +1,66 @@
1
+ 'use strict';
2
+
3
+ //START OF moduleFunction() ============================================================
4
+
5
+ const moduleFunction = function(args) {
6
+ //this module is initialized with parameters spec'd in the main function module
7
+
8
+ const completeStepActual = ({verbose=false, logErrors=false, moduleName}) => (
9
+ methodName,
10
+ thisStepMessage,
11
+ thisStepResult,
12
+ thisStepEvalFunction
13
+ ) => {
14
+
15
+ const thisStepPass = thisStepEvalFunction(thisStepResult);
16
+
17
+ if (logErrors && !thisStepPass) {
18
+ console.log(`FAIL TEST: ${thisStepMessage} in ...${moduleName}`);
19
+ }
20
+ if (verbose) {
21
+ console.log(`Result for: ${methodName} (${thisStepPass?'PASS':'FAIL'}):`);
22
+ console.dir(thisStepResult);
23
+ console.log('\n\n');
24
+ }
25
+
26
+ return passingTests && thisStepPass;
27
+ };
28
+
29
+ const completeStep = completeStepActual(args);
30
+
31
+ let passingTests = true;
32
+
33
+ let thisStepMessage;
34
+ let thisStepResult;
35
+ let thisStepEvalFunction;
36
+ let methodName;
37
+
38
+ //TESTS ============================================================
39
+
40
+
41
+ const testArray = [
42
+ 'allocute',
43
+ 'Hello'
44
+ ];
45
+
46
+
47
+ //TEST ITEM ------------------------------------------------------
48
+ methodName='qtTemplateMethod'
49
+ thisStepMessage = "not yet implemented";
50
+ thisStepResult = testArray[methodName]('SUFFIX');
51
+ thisStepEvalFunction = item => item='allocute,Hello : SUFFIX';
52
+ passingTests =
53
+ completeStep(methodName, thisStepMessage, thisStepResult, thisStepEvalFunction) &&
54
+ passingTests;
55
+
56
+
57
+
58
+
59
+ return passingTests;
60
+ };
61
+
62
+ //END OF moduleFunction() ============================================================
63
+
64
+ module.exports = moduleFunction;
65
+ //module.exports = new moduleFunction();
66
+
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "qtools-pop",
3
+ "version": "1.0.0",
4
+ "description": "basically this is pop surePath.",
5
+ "main": "qtools-pop.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "author": "TQ White II",
10
+ "license": "ISC"
11
+ }
@@ -0,0 +1,175 @@
1
+ 'use strict';
2
+ //START OF moduleFunction() ============================================================
3
+ var moduleFunction = function(args = {}) {
4
+ const { commonFunctions } = args;
5
+
6
+ const addToPrototypeActual = functionObject => () =>
7
+ commonFunctions.universalAddToPrototype(commonFunctions, functionObject);
8
+
9
+
10
+
11
+ //first method definition function ==========================
12
+ const firstMethodFunction = commonFunctions => {
13
+ const methodName = 'qtPop';
14
+ const description = `operand.qtPop() pops with an optional default argument`;
15
+ const supportedTypeList = [Array];
16
+
17
+ const method = () =>
18
+ function(defaultValue) {
19
+ const inData = this;
20
+ if (typeof inData.length == 'undefined') {
21
+ throw 'array.qtPop(defaultValue=undefined) works for Arrays only';
22
+ }
23
+ const arrayValue = inData.pop();
24
+ const result =
25
+ typeof arrayValue != 'undefined' ? arrayValue : defaultValue;
26
+ return result;
27
+ };
28
+
29
+ const test = args => {
30
+ return require('./test.js')({
31
+ ...args,
32
+ ...{
33
+ moduleName: module.id.replace(module.path, '')
34
+ }
35
+ });
36
+ };
37
+
38
+ return {
39
+ methodName,
40
+ description,
41
+ supportedTypeList,
42
+ method,
43
+ test
44
+ };
45
+ };
46
+ //second method definition function ==========================
47
+ const secondMethodFunction = commonFunctions => {
48
+ const methodName = 'qtLast';
49
+ const description = `operand.qtLast() return last element but leave it on stack) with an optional default argument`;
50
+ const supportedTypeList = [Array];
51
+
52
+ const method = () =>
53
+ function(defaultValue) {
54
+ const inData = this;
55
+ if (typeof inData.length == 'undefined') {
56
+ throw 'array.qtLast(defaultValue=undefined) works for Arrays only';
57
+ }
58
+ const arrayValue = inData.length?inData[inData.length-1]:void('');
59
+ const result =
60
+ typeof arrayValue != 'undefined' ? arrayValue : defaultValue;
61
+ return result;
62
+ };
63
+
64
+ return {
65
+ methodName,
66
+ description,
67
+ supportedTypeList,
68
+ method
69
+ };
70
+ };
71
+ //third method definition function ==========================
72
+ const thirdMethodFunction = commonFunctions => {
73
+ const methodName = 'qtPush';
74
+ const description = `operand.qtPush(value) pushes to the array and returns the array`;
75
+ const supportedTypeList = [Array];
76
+
77
+ const method = () =>
78
+ function(value) {
79
+ const inData = this;
80
+ if (typeof inData.length == 'undefined') {
81
+ throw 'array.qtPush(defaultValue=undefined) works for Arrays only';
82
+ }
83
+
84
+ inData.push(value);
85
+ return inData;
86
+ };
87
+
88
+ const test = args => {
89
+ return require('./test.js')({
90
+ ...args,
91
+ ...{
92
+ moduleName: module.id.replace(module.path, '')
93
+ }
94
+ });
95
+ };
96
+
97
+ return {
98
+ methodName,
99
+ description,
100
+ supportedTypeList,
101
+ method,
102
+ test
103
+ };
104
+ };
105
+ //fourth method definition function ==========================
106
+ const fourthMethodFunction = commonFunctions => {
107
+ const methodName = 'qtFirst';
108
+ const description = `operand.qtFirst(value) gets element zero or default`;
109
+ const supportedTypeList = [Array];
110
+
111
+ const method = () =>
112
+ function(defaultValue) {
113
+ const inData = this;
114
+ if (typeof inData.length == 'undefined') {
115
+ throw 'array.qtFirst(defaultValue=undefined) works for Arrays only';
116
+ }
117
+ const arrayValue = inData[0]?inData[0]:void('');
118
+ const result =
119
+ typeof arrayValue != 'undefined' ? arrayValue : defaultValue;
120
+ return result;
121
+ };
122
+
123
+ const test = args => {
124
+ return require('./test.js')({
125
+ ...args,
126
+ ...{
127
+ moduleName: module.id.replace(module.path, '')
128
+ }
129
+ });
130
+ };
131
+
132
+ return {
133
+ methodName,
134
+ description,
135
+ supportedTypeList,
136
+ method,
137
+ test
138
+ };
139
+ };
140
+
141
+ const functionObject = new Map(); // prettier-ignore
142
+ const addFunction = definition => {
143
+ const {
144
+ methodName,
145
+ description,
146
+ supportedTypeList,
147
+ method,
148
+ test
149
+ } = definition;
150
+ functionObject.set(methodName, {
151
+ description,
152
+ supportedTypeList,
153
+ method,
154
+ test: args => {
155
+ return require('./test.js')({
156
+ ...args,
157
+ ...{
158
+ moduleName: module.id.replace(module.path, '')
159
+ }
160
+ });
161
+ }
162
+ });
163
+ };
164
+
165
+ addFunction(firstMethodFunction());
166
+ addFunction(secondMethodFunction());
167
+ addFunction(thirdMethodFunction());
168
+ addFunction(fourthMethodFunction());
169
+
170
+ this.addToPrototype = addToPrototypeActual(functionObject);
171
+
172
+ };
173
+ //END OF moduleFunction() ============================================================
174
+ module.exports = moduleFunction;
175
+ //module.exports = new moduleFunction();