qtools-library-dot-d 1.0.11 → 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 (75) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +2 -1
  3. package/package.json +2 -2
  4. package/qtools-library-dot-d.js +1 -1
  5. package/libDotD_Working_Example/README.md +0 -234
  6. package/libDotD_Working_Example/demoModules_DotD/demo1.js +0 -46
  7. package/libDotD_Working_Example/demoModules_DotD/demo2.js +0 -48
  8. package/libDotD_Working_Example/index.js +0 -133
  9. package/libDotD_Working_Example/node_modules/.package-lock.json +0 -29
  10. package/libDotD_Working_Example/node_modules/qtools-asynchronous-pipe-plus/README.md +0 -213
  11. package/libDotD_Working_Example/node_modules/qtools-asynchronous-pipe-plus/package.json +0 -20
  12. package/libDotD_Working_Example/node_modules/qtools-asynchronous-pipe-plus/qtools-asynchronous-pipe-plus.js +0 -278
  13. package/libDotD_Working_Example/node_modules/qtools-asynchronous-pipe-plus/test.js +0 -79
  14. package/libDotD_Working_Example/node_modules/qtools-functional-library/README.md +0 -110
  15. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-clone/package.json +0 -11
  16. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-clone/qtools-clone.js +0 -103
  17. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-clone/test.js +0 -78
  18. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-get-by-property/package.json +0 -11
  19. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-get-by-property/qtools-get-by-property.js +0 -73
  20. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-get-by-property/test.js +0 -129
  21. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-includes-regex/package.json +0 -11
  22. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-includes-regex/qtools-includes-regex.js +0 -54
  23. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-includes-regex/test.js +0 -76
  24. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-log-output/package.json +0 -11
  25. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-log-output/qtools-log-output.js +0 -114
  26. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-log-output/test.js +0 -130
  27. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-map-properties/package.json +0 -11
  28. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-map-properties/qtools-map-properties.js +0 -99
  29. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-map-properties/test.js +0 -118
  30. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-merge/package.json +0 -11
  31. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-merge/qtools-merge.js +0 -147
  32. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-merge/test.js +0 -214
  33. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-new-method-template/package.json +0 -11
  34. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-new-method-template/qtools-new-method-template.js +0 -70
  35. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-new-method-template/test.js +0 -66
  36. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-number-iterator/package.json +0 -11
  37. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-number-iterator/qtools-number-iterator.js +0 -137
  38. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-number-iterator/test.js +0 -68
  39. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-number-keys-to-array/package.json +0 -11
  40. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-number-keys-to-array/qtools-number-keys-to-array.js +0 -131
  41. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-number-keys-to-array/test.js +0 -181
  42. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-object-sure-path/package.json +0 -11
  43. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-object-sure-path/qtools-object-sure-path.js +0 -204
  44. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-object-sure-path/test.js +0 -345
  45. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-pass-through/package.json +0 -11
  46. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-pass-through/qtools-pass-through.js +0 -58
  47. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-pass-through/test.js +0 -66
  48. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-pop/package.json +0 -11
  49. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-pop/qtools-pop.js +0 -175
  50. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-pop/test.js +0 -118
  51. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-print-debug/package.json +0 -11
  52. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-print-debug/qtools-print-debug.js +0 -352
  53. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-print-debug/test.js +0 -77
  54. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-select-properties/package.json +0 -11
  55. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-select-properties/qtools-select-properties.js +0 -132
  56. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-select-properties/test.js +0 -156
  57. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-template-replace/README.md +0 -3
  58. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-template-replace/package.json +0 -11
  59. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-template-replace/qtools-template-replace.js +0 -106
  60. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-template-replace/test.js +0 -168
  61. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-to-key-value-array/package.json +0 -11
  62. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-to-key-value-array/qtools-to-key-value-array.js +0 -83
  63. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-to-key-value-array/test.js +0 -68
  64. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-to-string/package.json +0 -11
  65. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-to-string/qtools-to-string.js +0 -84
  66. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-to-string/test.js +0 -63
  67. package/libDotD_Working_Example/node_modules/qtools-functional-library/package.json +0 -37
  68. package/libDotD_Working_Example/node_modules/qtools-functional-library/qtFunctionalDemo.js +0 -297
  69. package/libDotD_Working_Example/node_modules/qtools-functional-library/qtools-functional-library.js +0 -271
  70. package/libDotD_Working_Example/node_modules/qtools-functional-library/test.js +0 -47
  71. package/libDotD_Working_Example/node_modules/qtools-library-dot-d/README.md +0 -208
  72. package/libDotD_Working_Example/node_modules/qtools-library-dot-d/package.json +0 -15
  73. package/libDotD_Working_Example/node_modules/qtools-library-dot-d/qtools-library-dot-d.js +0 -239
  74. package/libDotD_Working_Example/package-lock.json +0 -37
  75. package/libDotD_Working_Example/package.json +0 -23
@@ -1,118 +0,0 @@
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
- const emptyArray = [];
46
-
47
-
48
- //TEST ITEM ------------------------------------------------------
49
- methodName='qtPop'
50
- thisStepMessage = "did not get the most recently added element";
51
- thisStepResult = testArray[methodName]();
52
- thisStepEvalFunction = item => item=='Hello';
53
- passingTests =
54
- completeStep(methodName, thisStepMessage, thisStepResult, thisStepEvalFunction) &&
55
- passingTests;
56
-
57
-
58
-
59
- //TEST ITEM ------------------------------------------------------
60
- methodName='qtPop'
61
- thisStepMessage = "did not get the most recently added element";
62
- thisStepResult = emptyArray[methodName]('default value');
63
- thisStepEvalFunction = item => item=='default value';
64
- passingTests =
65
- completeStep(methodName, thisStepMessage, thisStepResult, thisStepEvalFunction) &&
66
- passingTests;
67
-
68
-
69
-
70
- //TEST ITEM ------------------------------------------------------
71
- methodName='qtLast'
72
- thisStepMessage = "did not get the most recently added element";
73
- thisStepResult = testArray[methodName]();
74
- thisStepEvalFunction = item => (item=='Hello' && item.length==2);
75
- passingTests =
76
- completeStep(methodName, thisStepMessage, thisStepResult, thisStepEvalFunction) &&
77
- passingTests;
78
-
79
-
80
-
81
- //TEST ITEM ------------------------------------------------------
82
- methodName='qtLast'
83
- thisStepMessage = "did not get the most recently added element";
84
- thisStepResult = emptyArray[methodName]('default value');
85
- thisStepEvalFunction = item => (item=='default value' && item.length==2);
86
- passingTests =
87
- completeStep(methodName, thisStepMessage, thisStepResult, thisStepEvalFunction) &&
88
- passingTests;
89
-
90
- //TEST ITEM ------------------------------------------------------
91
- methodName='qtPush'
92
- thisStepMessage = "element was not added";
93
- thisStepResult = emptyArray[methodName]('test value');
94
- thisStepEvalFunction = item => (item=>item.qtPop()=='test value');
95
- passingTests =
96
- completeStep(methodName, thisStepMessage, thisStepResult, thisStepEvalFunction) &&
97
- passingTests;
98
-
99
- //TEST ITEM ------------------------------------------------------
100
- methodName='qtFirst'
101
- thisStepMessage = "element was not added";
102
- thisStepResult = testArray[methodName]();
103
- thisStepEvalFunction = item => (item=='allocute' && item.length==2);
104
- passingTests =
105
- completeStep(methodName, thisStepMessage, thisStepResult, thisStepEvalFunction) &&
106
- passingTests;
107
-
108
-
109
-
110
-
111
- return passingTests;
112
- };
113
-
114
- //END OF moduleFunction() ============================================================
115
-
116
- module.exports = moduleFunction;
117
- //module.exports = new moduleFunction();
118
-
@@ -1,11 +0,0 @@
1
- {
2
- "name": "qtools-print-debug",
3
- "version": "1.0.0",
4
- "description": "various print functions for debugging purposes",
5
- "main": "qtools-print-debug.js",
6
- "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
8
- },
9
- "author": "TQ White II",
10
- "license": "ISC"
11
- }
@@ -1,352 +0,0 @@
1
- 'use strict';
2
- const util = require('util');
3
- //START OF moduleFunction() ============================================================
4
- var moduleFunction = function(args = {}) {
5
- const { commonFunctions } = args;
6
-
7
- const addToPrototypeActual = functionObject => () =>
8
- commonFunctions.universalAddToPrototype(commonFunctions, functionObject);
9
-
10
- function qtDump(args = {}) {
11
- const inData = this;
12
- let label = '';
13
- let returnString = false;
14
- let addSeparators = false;
15
- let outputFunction;
16
- let noSuffix = false; //suppresses suffix if true
17
- let callerName = commonFunctions.callerName(true);
18
- let separator = '';
19
- let returnn = '';
20
- let showLabel = '';
21
- let suffix = '';
22
- let cancelDump = args.cancelDump ? args.cancelDump : false;
23
-
24
- if (cancelDump) {
25
- return this;
26
- }
27
-
28
- const recursionDepth =
29
- typeof args.recursionDepth != 'undefined' ? args.recursionDepth : null;
30
- const addCliColors =
31
- typeof args.addCliColors != 'undefined' ? args.recursionDepth : true;
32
-
33
- if (typeof args == 'object') {
34
- label = args.label ? args.label : '';
35
- returnString = args.returnString ? args.returnString : false;
36
- addSeparators = args.addSeparators ? args.addSeparators : false;
37
- noSuffix = args.noSuffix ? args.noSuffix : false;
38
- callerName = commonFunctions.callerName(true);
39
- separator = addSeparators ? '\n--------\n' : '';
40
- returnn = addSeparators ? '\n' : ' ';
41
- showLabel = label.replace(/\n/g, '');
42
- suffix = noSuffix ? '' : ` [${returnn}[${callerName}]${separator}]`;
43
- outputFunction = args.outputFunction
44
- ? args.outputFunction
45
- : console.error;
46
- } else if (typeof args == 'string') {
47
- label = args;
48
- showLabel = label.replace(/\n/g, '');
49
- }
50
-
51
- if (['string', 'number', 'boolean'].includes(typeof this)) {
52
- if (returnString) {
53
- return `${this}${suffix}`;
54
- } else {
55
- let outString = this;
56
- let suffixx = '';
57
- const disassesmbleString = this.match(/(\n*)$/);
58
- if (disassesmbleString[0]) {
59
- suffixx = disassesmbleString[0];
60
- outString = outString.replace(disassesmbleString[0], '');
61
- }
62
-
63
- outputFunction(
64
- `${separator}${label ? showLabel + '= ' : ''}${outString} ${suffix}`
65
- );
66
- }
67
- } else if (['function'].includes(typeof this)) {
68
- if (returnString) {
69
- return this.toString() + suffix;
70
- } else {
71
- outputFunction(
72
- `${separator}${
73
- label ? showLabel + `=${returnn}` : ''
74
- }${returnn}${this}${returnn}${suffix}`
75
- );
76
- }
77
- } else {
78
- let tmpObject = inData;
79
- if (label) {
80
- tmpObject = { [label]: inData };
81
- }
82
-
83
- if (returnString) {
84
- return (
85
- util.inspect(tmpObject, {
86
- depth: recursionDepth,
87
- maxArrayLength: null,
88
- colors: addCliColors
89
- }) + ` [${suffix}]`
90
- );
91
- } else {
92
- outputFunction(
93
- `${separator}${label ? showLabel + `:${returnn}` : ''}${util.inspect(
94
- inData,
95
- {
96
- depth: recursionDepth,
97
- colors: addCliColors
98
- }
99
- )} ${suffix}`
100
- );
101
- }
102
- }
103
- return this;
104
- }
105
-
106
- function qtListProperties(args = {}) {
107
- const inObject = this;
108
- const {
109
- label = '',
110
- returnString = false,
111
- maxShowStringLength = 100
112
- } = args;
113
-
114
- var outString = label ? `${label}:\n` : '';
115
- var list = [];
116
- var count = 0;
117
- var type = commonFunctions.toType(inObject);
118
-
119
- if (type == 'object' || type == 'arguments') {
120
- var outList = [];
121
- for (var i in inObject) {
122
- var element = inObject[i];
123
- var hadProperties = true;
124
- var showElement;
125
- if (
126
- ['object', 'array', 'function', 'map'].indexOf(
127
- commonFunctions.toType(element)
128
- ) == -1
129
- ) {
130
- if (element == null) {
131
- showElement = 'null'.green;
132
- } else {
133
- if (element.length > maxShowStringLength) {
134
- element =
135
- element.substr(0, maxShowStringLength) +
136
- ' ... (length=' +
137
- element.length +
138
- ', use maxShowStringLength)';
139
- }
140
- if (returnString) {
141
- showElement = element.toString();
142
- } else {
143
- showElement = element.toString();
144
- }
145
- }
146
- if (returnString) {
147
- var tmp =
148
- 'item #' +
149
- count +
150
- " named '" +
151
- i +
152
- "' is a " +
153
- commonFunctions.toType(element) +
154
- ' value= ' +
155
- showElement;
156
- } else {
157
- var tmp =
158
- 'item #' +
159
- count +
160
- " named '" +
161
- i +
162
- "' is a " +
163
- commonFunctions.toType(element) +
164
- ' value= ' +
165
- showElement;
166
- }
167
- outList.push({ name: i, string: tmp });
168
- } else {
169
- if (returnString) {
170
- var tmp =
171
- 'item #' +
172
- count +
173
- " named '" +
174
- i +
175
- "' is a " +
176
- commonFunctions.toType(element) +
177
- (commonFunctions.toType(element) == 'array'
178
- ? ` length= ${element.length}`
179
- : '');
180
- } else {
181
- var tmp =
182
- 'item #' +
183
- count +
184
- " named '" +
185
- i +
186
- "' is a " +
187
- commonFunctions.toType(element) +
188
- (commonFunctions.toType(element) == 'array'
189
- ? ` length= ${element.length}`
190
- : '');
191
- }
192
- outList.push({ name: i, string: tmp });
193
- }
194
- count++;
195
- }
196
-
197
- outList = outList.sort(commonFunctions.byObjectProperty('name'));
198
-
199
- for (var i = 0, len = outList.length; i < len; i++) {
200
- var element = outList[i];
201
-
202
- outString += `\t${element.string}\n`;
203
- }
204
- } else if (type == 'array') {
205
- for (var i = 0, len = list.length; i < len; i++) {
206
- var element = inObject[i];
207
- var hadProperties = true;
208
-
209
- outString +=
210
- 'item #' +
211
- count +
212
- " index '" +
213
- i +
214
- ' is ' +
215
- commonFunctions.toType(element) +
216
- 'length= ' +
217
- element.length +
218
- '\n';
219
-
220
- count++;
221
- }
222
- } else if (type == 'map') {
223
- var hadProperties = false;
224
- var outList = [];
225
- inObject.forEach((element, i, all) => {
226
- hadProperties = true;
227
-
228
- var showElement;
229
- if (
230
- ['object', 'array', 'function', 'map'].indexOf(
231
- commonFunctions.toType(element)
232
- ) == -1
233
- ) {
234
- if (element == null) {
235
- showElement = 'null'.green;
236
- } else {
237
- if (element.length > maxShowStringLength) {
238
- element =
239
- element.substr(0, maxShowStringLength) +
240
- ' ... (length=' +
241
- element.length +
242
- ')';
243
- }
244
- if (returnString) {
245
- showElement = element.toString();
246
- } else {
247
- showElement = element.toString();
248
- }
249
- }
250
- if (returnString) {
251
- var tmp =
252
- 'item #' +
253
- count +
254
- " named '" +
255
- i +
256
- "' is a " +
257
- commonFunctions.toType(element) +
258
- ' value= ' +
259
- showElement;
260
- } else {
261
- var tmp =
262
- ('item #' + count + " named '").grey +
263
- i.red +
264
- "' is a ".grey +
265
- commonFunctions.toType(element).red +
266
- ' value= '.grey +
267
- showElement;
268
- }
269
- outList.push({ name: i, string: tmp });
270
- } else {
271
- if (returnString) {
272
- var tmp =
273
- 'item #' +
274
- count +
275
- " named '" +
276
- i +
277
- "' is a " +
278
- commonFunctions.toType(element);
279
- } else {
280
- var tmp =
281
- ('item #' + count + " named '").grey +
282
- i.red +
283
- "' is a ".grey +
284
- commonFunctions.toType(element).red;
285
- }
286
- outList.push({ name: i, string: tmp });
287
- }
288
- count++;
289
- });
290
-
291
- outList = outList.sort(commonFunctions.byObjectProperty('name'));
292
-
293
- for (var i = 0, len = outList.length; i < len; i++) {
294
- var element = outList[i];
295
-
296
- outString += `\t${element.string}\n`;
297
- }
298
- } else {
299
- if (!returnString) {
300
- var message =
301
- "commonFunctions.listProperties says, input was of not an object or array. It was type '" +
302
- commonFunctions.toType(inObject) +
303
- "'";
304
- console.error(message);
305
- var hadProperties = true; //don't need no properties message
306
- }
307
- }
308
- if (!hadProperties) {
309
- if (!returnString) {
310
- console.error('input had no properties');
311
- }
312
- }
313
- if (!returnString) {
314
- console.error(outString);
315
- return this;
316
- } else {
317
- return outString;
318
- }
319
- }
320
-
321
- //first method definition function ==========================
322
- const firstMethodFunction = commonFunctions => {
323
- const functionObject = new Map(); // prettier-ignore
324
-
325
- functionObject.set('qtDump', {
326
- description: `placeholder`,
327
- supportedTypeList: [Object],
328
- method: () => qtDump
329
- });
330
-
331
- functionObject.set('qtListProperties', {
332
- description: `placeholder`,
333
- supportedTypeList: [Object],
334
- method: () => qtListProperties,
335
- test: args => {
336
- return require('./test.js')({
337
- ...args,
338
- ...{
339
- moduleName: module.id.replace(module.path, '')
340
- }
341
- });
342
- }
343
- });
344
- return functionObject;
345
- };
346
- this.addToPrototype = addToPrototypeActual(
347
- firstMethodFunction(commonFunctions)
348
- );
349
- };
350
- //END OF moduleFunction() ============================================================
351
- module.exports = moduleFunction;
352
- //module.exports = new moduleFunction();
@@ -1,77 +0,0 @@
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}:`);
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
- animal: 'bird',
43
- eatsWith: 'teeth',
44
- color: 'red',
45
- list:[1,2,3]
46
- };
47
-
48
-
49
- //TEST ITEM ------------------------------------------------------
50
- methodName='qtDump'
51
- thisStepMessage = "not yet implemented";
52
- thisStepResult = testArray[methodName]({returnString:true});
53
- thisStepEvalFunction = item => typeof(item)=='string';
54
- passingTests =
55
- completeStep(methodName, thisStepMessage, thisStepResult, thisStepEvalFunction) &&
56
- passingTests;
57
-
58
-
59
- methodName='qtListProperties'
60
- thisStepMessage = "not yet implemented";
61
- thisStepResult = testArray[methodName]({returnString:true});
62
- thisStepEvalFunction = item => typeof(item)=='string';
63
- passingTests =
64
- completeStep(methodName, thisStepMessage, thisStepResult, thisStepEvalFunction) &&
65
- passingTests;
66
-
67
-
68
-
69
-
70
- return passingTests;
71
- };
72
-
73
- //END OF moduleFunction() ============================================================
74
-
75
- module.exports = moduleFunction;
76
- //module.exports = new moduleFunction();
77
-
@@ -1,11 +0,0 @@
1
- {
2
- "name": "qtools-select-properties",
3
- "version": "1.0.0",
4
- "description": "Create new objects (or list of objects) containing only the enumerated properties. Allows defaults to be supplied for missing properties. If an enumerated property name does not exist at all, a property with the default value is created.",
5
- "main": "qtools-select-properties.js",
6
- "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
8
- },
9
- "author": "TQ White II",
10
- "license": "ISC"
11
- }
@@ -1,132 +0,0 @@
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 = 'qtSelectProperties';
14
- const description = `operand.qtSelectProperties(value) create snew objects (or list of objects) containing only the enumerated properties. Allows defaults to be supplied for missing properties. If an enumerated property name does not exist at all, a property with the default value is created.`;
15
- const supportedTypeList = [Array, Object];
16
-
17
- const method = () =>
18
- function(keepers, options = {}) {
19
-
20
- const {
21
- moreDefaultValues = {},
22
- omitUndefined = true,
23
- excludeMode = false
24
- } = options;
25
-
26
- if (!(keepers instanceof Object)) {
27
- throw new Error(
28
- 'qtSelectProperties() argument one must be instance of Object or Array'
29
- );
30
- }
31
-
32
- let inclusions = keepers;
33
- let defaultValues = {};
34
- if (!(keepers instanceof Array)) {
35
- inclusions = Object.keys(keepers);
36
- defaultValues = keepers;
37
- }
38
-
39
- Object.keys(moreDefaultValues).forEach(
40
- name => (defaultValues[name] = moreDefaultValues[name])
41
- );
42
-
43
- const selectingFunction = currentObject => {
44
- const getDefault = (currentObject, keeperName) =>
45
- typeof defaultValues[keeperName] == 'function'
46
- ? defaultValues[keeperName](currentObject.qtClone(), keeperName)
47
- : defaultValues[keeperName];
48
-
49
- // defaultFunction=(currentObject, elementName)=>{}
50
-
51
- let outObj = {};
52
-
53
- if (!excludeMode) {
54
- inclusions.forEach(keeperName => {
55
- const newValue =
56
- typeof currentObject[keeperName] != 'undefined'
57
- ? currentObject[keeperName]
58
- : getDefault(currentObject, keeperName);
59
- if (typeof newValue != 'undefined' || !omitUndefined) {
60
- outObj[keeperName] = newValue;
61
- }
62
- });
63
- } else {
64
- outObj = currentObject;
65
- inclusions.forEach(keeperName => {
66
- if (typeof (outObj[keeperName] == 'undefined')) {
67
- delete outObj[keeperName];
68
- }
69
- });
70
- }
71
-
72
- return outObj;
73
- };
74
-
75
-
76
- if (this instanceof Array) {
77
- return this.map(item => selectingFunction(item));
78
- } else {
79
- return selectingFunction(this);
80
- }
81
- };
82
-
83
- const test = args => {
84
- return require('./test.js')({
85
- ...args,
86
- ...{
87
- moduleName: module.id.replace(module.path, '')
88
- }
89
- });
90
- };
91
-
92
- return {
93
- methodName,
94
- description,
95
- supportedTypeList,
96
- method,
97
- test
98
- };
99
- };
100
-
101
- const functionObject = new Map(); // prettier-ignore
102
- const addFunction = definition => {
103
- const {
104
- methodName,
105
- description,
106
- supportedTypeList,
107
- method,
108
- test
109
- } = definition;
110
- functionObject.set(methodName, {
111
- description,
112
- supportedTypeList,
113
- method,
114
- test: args => {
115
- return require('./test.js')({
116
- ...args,
117
- ...{
118
- moduleName: module.id.replace(module.path, '')
119
- }
120
- });
121
- }
122
- });
123
- };
124
-
125
- addFunction(firstMethodFunction());
126
-
127
- this.addToPrototype = addToPrototypeActual(functionObject);
128
-
129
- };
130
- //END OF moduleFunction() ============================================================
131
- module.exports = moduleFunction;
132
- //module.exports = new moduleFunction();