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,156 +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 testObject={
42
- one: 1,
43
- two: 2
44
- }
45
-
46
- const testArray=[
47
- {
48
- alpha: 11,
49
- beta: 12,
50
- gamma:13
51
- },{
52
- alpha: 21,
53
- gamma:23
54
- }
55
- ];
56
-
57
- const testOneArgument=[ 'one'];
58
- const testTwoArgument=['alpha'];
59
-
60
- const testThreeArgument=['alpha', 'beta'];
61
- const testThreeMoreValues={moreDefaultValues:{beta:(currentObject, elementName)=>`default function ${elementName} produces ${Object.keys(currentObject).join(', ')}`}}
62
-
63
- const testFourArgument={
64
- alpha: (item, name, entire)=>item*1000,
65
- addedValue:(item, name, entire)=>`${name} says, item:${item} becomes ${Object.keys(entire).join(', ')}`
66
- }
67
-
68
- const testFiveArgument={
69
- alpha: 'eleven',
70
- beta: 'twelve'
71
- }
72
-
73
- // array of strings for one object
74
- // array of strings for array of objects
75
- // array of strings for one object with moreDefaultValues
76
- // object with defaults for object
77
- // EXCLUDE MODE
78
-
79
- //TEST ITEM ------------------------------------------------------
80
- methodName='qtSelectProperties'
81
- thisStepMessage = "did not get array of strings for one object ";
82
- thisStepResult = testObject[methodName](testOneArgument);
83
- thisStepEvalFunction = item => (item.one==1 && typeof(item.two)=='undefined');
84
- passingTests =
85
- completeStep(methodName, thisStepMessage, thisStepResult, thisStepEvalFunction) &&
86
- passingTests;
87
-
88
- //TEST ITEM ------------------------------------------------------
89
- methodName='qtSelectProperties'
90
- thisStepMessage = "did not get array of strings for array of objects";
91
- thisStepResult = testArray[methodName](testTwoArgument);
92
- thisStepEvalFunction = item => (
93
- item[0].alpha==11 &&
94
- typeof(item[0].beta)=='undefined' &&
95
- item[1].alpha==21 &&
96
- typeof(item[1].beta)=='undefined'
97
- );
98
- passingTests =
99
- completeStep(methodName, thisStepMessage, thisStepResult, thisStepEvalFunction) &&
100
- passingTests;
101
-
102
- //TEST ITEM ------------------------------------------------------
103
- methodName='qtSelectProperties'
104
- thisStepMessage = "did not get array of strings for one object with moreDefaultValues";
105
- thisStepResult = testArray[methodName](testThreeArgument, testThreeMoreValues);
106
- thisStepEvalFunction = item => (
107
- item[0].alpha==11 &&
108
- item[0].beta==12 &&
109
- item[1].alpha==21 &&
110
- item[1].beta=='default function beta produces alpha, gamma'
111
- );
112
- passingTests =
113
- completeStep(methodName, thisStepMessage, thisStepResult, thisStepEvalFunction) &&
114
- passingTests;
115
-
116
- //TEST ITEM ------------------------------------------------------
117
- methodName='qtSelectProperties'
118
- thisStepMessage = "did not get object argument containing defaults";
119
- thisStepResult = testArray[methodName](testFiveArgument);
120
- thisStepEvalFunction = item => (
121
- item[0].alpha==11 &&
122
- item[0].beta==12 &&
123
- item[1].alpha==21 &&
124
- item[1].beta=='twelve'
125
- );
126
- passingTests =
127
- completeStep(methodName, thisStepMessage, thisStepResult, thisStepEvalFunction) &&
128
- passingTests;
129
-
130
- //TEST ITEM ------------------------------------------------------
131
- methodName='qtSelectProperties'
132
- thisStepMessage = "did not get EXCLUDE MODE";
133
- thisStepResult = testArray[methodName](testThreeArgument, {excludeMode:true});
134
- thisStepEvalFunction = item => (
135
- typeof(item[0].alpha)=='undefined' &&
136
- typeof(item[0].beta)=='undefined' &&
137
- item[0].gamma==13 &&
138
- typeof(item[1].alpha)=='undefined' &&
139
- typeof(item[1].beta)=='undefined' &&
140
- item[1].gamma==23
141
- );
142
- passingTests =
143
- completeStep(methodName, thisStepMessage, thisStepResult, thisStepEvalFunction) &&
144
- passingTests;
145
-
146
-
147
-
148
-
149
- return passingTests;
150
- };
151
-
152
- //END OF moduleFunction() ============================================================
153
-
154
- module.exports = moduleFunction;
155
- //module.exports = new moduleFunction();
156
-
@@ -1,3 +0,0 @@
1
- qtools-template-replace
2
-
3
- 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.
@@ -1,11 +0,0 @@
1
- {
2
- "name": "qtools-template-replace",
3
- "version": "1.0.1",
4
- "description": "Replaces <!tag!> tags based on properties in objects.",
5
- "main": "qtools-template-replace.js",
6
- "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
8
- },
9
- "author": "TQ White II",
10
- "license": "ISC"
11
- }
@@ -1,106 +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
- const baseReplacementFunction = (replaceObject, template, options) => {
10
- const { transformations = {}, leaveUnmatchedTagsIntact = true } = options;
11
- replaceObject = {...replaceObject,...transformations};
12
-
13
- const tmp = template.match(/<!.*?!>/g);
14
-
15
- const tags =
16
- commonFunctions.toType(tmp) == 'array'
17
- ? tmp.map(item => item.replace(/<!(.*?)!>/, '$1'))
18
- : [];
19
-
20
- const outString = tags.reduce((result, tag) => {
21
- let replacement = replaceObject.qtGetSurePath(tag);
22
-
23
- if (typeof replacement == 'undefined' && leaveUnmatchedTagsIntact) {
24
- return result;
25
- } else if (typeof replacement == 'undefined') {
26
- replacement = '';
27
- }
28
-
29
- return result.replace(
30
- `<!${tag}!>`,
31
- typeof replacement == 'function'
32
- ? replacement(replaceObject)
33
- : replacement
34
- );
35
- }, template);
36
-
37
- return outString;
38
- };
39
-
40
- // prettier-ignore
41
- const objectCallsString = (item, arg) => item instanceof Object && typeof arg == 'string';
42
- // prettier-ignore
43
- const arrayOfObjectsCallsString = (item, arg) => item instanceof Array && typeof arg == 'string' && item.filter(item => item instanceof Object).qtPop(true);
44
- // prettier-ignore
45
- const stringCallsObject = (item, arg) => arg instanceof Object && typeof item == 'string';
46
- // prettier-ignore
47
- const stringCallsArrayOfObjects = (item, arg) => arg instanceof Array && typeof item == 'string';
48
- // prettier-ignore
49
- const arrayOfStringsCallsObject = (item, arg) => arg instanceof Object && item instanceof Array && item.filter(item => typeof item == 'string').qtPop(false) ? true : false;
50
-
51
- //first method definition function ==========================
52
- const firstMethodFunction = commonFunctions => {
53
- const functionObject = new Map(); // prettier-ignore
54
-
55
- const methodName = 'qtTemplateReplace';
56
- const description = `object.qtTemplateReplace(string), arrayOfObjects.qtTemplateReplace(string), string.qtTemplateReplace(object), arrayOfStrings.qtTemplateReplace(object)`;
57
- const supportedTypeList = [Array, Object, String];
58
-
59
- const method = () =>
60
- function(arg, options = {}) {
61
- //if one of the supportedTypeList elements is Object, basically all data types will have this method and type checking is important.
62
- if (!commonFunctions.isSupportedType(this, supportedTypeList)) {
63
- // prettier-ignore
64
- throw new Error(`${methodName}(): unsupported data type: '${commonFunctions.toType(this)}' (${methodName} supports ${supportedTypeList.map(item=>item.toString().replace(/.*function (.*?)\(\).*/, '$1')).join(', ')})`);
65
- }
66
-
67
- if (arrayOfStringsCallsObject(this, arg)) {
68
- return this.map(item => baseReplacementFunction(arg, item, options));
69
- } else if (arrayOfObjectsCallsString(this, arg)) {
70
- return this.map(item => baseReplacementFunction(item, arg, options));
71
- } else if (objectCallsString(this, arg)) {
72
- return baseReplacementFunction(this, arg, options);
73
- } else if (stringCallsArrayOfObjects(this, arg)) {
74
- return arg.map(item => baseReplacementFunction(item, this, options));
75
- } else if (stringCallsObject(this, arg)) {
76
- return baseReplacementFunction(arg, this, options);
77
- }
78
-
79
- throw new Error(
80
- `${methodName}(): unsupported data combination. Accepts object.qtTemplateReplace(string), arrayOfObjects.qtTemplateReplace(string), string.qtTemplateReplace(object), arrayOfStrings.qtTemplateReplace(object)`
81
- );
82
- };
83
-
84
- functionObject.set(methodName, {
85
- description,
86
- supportedTypeList,
87
- method,
88
- test: args => {
89
- return require('./test.js')({
90
- ...args,
91
- ...{
92
- moduleName: module.id.replace(module.path, '')
93
- }
94
- });
95
- }
96
- });
97
-
98
- return functionObject;
99
- };
100
- this.addToPrototype = addToPrototypeActual(
101
- firstMethodFunction(commonFunctions)
102
- );
103
- };
104
- //END OF moduleFunction() ============================================================
105
- module.exports = moduleFunction;
106
- //module.exports = new moduleFunction();
@@ -1,168 +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
- thisStepResult.qtDump();
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
-
42
- const replaceArray = [
43
- {
44
- animal: 'fish',
45
- eatsWith: 'straw',
46
- color: 'red',
47
- finSize:'flappy',
48
- foods:{
49
- desert:'watermelon',
50
- lunch:'ice cubes'
51
- },
52
- testMark:'testMarkOutput',
53
- capitalAnimal:replaceObject=>replaceObject.animal.toUpperCase()
54
- },
55
- {
56
- animal: 'snake',
57
- eatsWith: 'straw',
58
- color: 'blue',
59
- finSize:'trim',
60
- foods:{
61
- desert:'birds',
62
- lunch:'worms'
63
- },
64
- testMark:'testMarkOutput'
65
- },
66
- {
67
- animal: 'bird',
68
- eatsWith: 'teeth',
69
- color: 'red',
70
- foods:{
71
- desert:'chewy clouds',
72
- lunch:'stars'
73
- },
74
- testMark:'testMarkOutput'
75
- },
76
- {
77
- animal: 'bird',
78
- eatsWith: 'chopsticks',
79
- color: 'red',
80
- foods:{
81
- desert:'sticky clouds',
82
- lunch:'rice stars'
83
- },
84
- testMark:'testMarkOutput'
85
- }
86
- ];
87
-
88
- const template=`The <!animal!> (<!capitalAnimal!>) eats with <!wrapEatsWith!> and are usually <!color!>. The like <!foods.lunch!> for lunch with a snappy <!foods.desert!> for desert. [<!testMark!>] <!unmatchedTag!>`;
89
-
90
- const templateList=[
91
-
92
- `ONE: ${template}`,
93
- `TWO: ${template}`,
94
- `THREE: ${template}`,
95
-
96
- ];
97
-
98
- const transformations={
99
- wrapEatsWith:replaceObject=>`[[${replaceObject.eatsWith}]]`
100
-
101
- }
102
-
103
-
104
- //TEST ITEM ------------------------------------------------------
105
- methodName='qtTemplateReplace'
106
- thisStepMessage = "did not work for a single object replacement";
107
- thisStepResult = replaceArray[0][methodName](template);
108
- thisStepEvalFunction = item => item.match(/testMarkOutput/, {transformations});
109
- passingTests =
110
- completeStep(methodName, thisStepMessage, thisStepResult, thisStepEvalFunction) &&
111
- passingTests;
112
-
113
- //TEST ITEM ------------------------------------------------------
114
- methodName='qtTemplateReplace'
115
- thisStepMessage = "did not work for a list of objects replacement";
116
- thisStepResult = replaceArray[methodName](template, {transformations});
117
- thisStepEvalFunction = item => item[0].match(/testMarkOutput/)?true:false;
118
- passingTests =
119
- completeStep(methodName, thisStepMessage, thisStepResult, thisStepEvalFunction) &&
120
- passingTests;
121
-
122
- //TEST ITEM ------------------------------------------------------
123
- methodName='qtTemplateReplace'
124
- thisStepMessage = "did not work for a string base with a single object";
125
- thisStepResult = template[methodName](replaceArray[0], {transformations});
126
- thisStepEvalFunction = item => item.match(/testMarkOutput/);
127
- passingTests =
128
- completeStep(methodName, thisStepMessage, thisStepResult, thisStepEvalFunction) &&
129
- passingTests;
130
-
131
- //TEST ITEM ------------------------------------------------------
132
- methodName='qtTemplateReplace'
133
- thisStepMessage = "did not work for a string array with a single object";
134
- thisStepResult = templateList[methodName](replaceArray[0], {transformations});
135
- thisStepEvalFunction = item => item[0].match(/testMarkOutput/);
136
- passingTests =
137
- completeStep(methodName, thisStepMessage, thisStepResult, thisStepEvalFunction) &&
138
- passingTests;
139
-
140
- //TEST ITEM ------------------------------------------------------
141
- methodName='qtTemplateReplace'
142
- thisStepMessage = "did not correctly remove unmatched tag";
143
- thisStepResult = templateList[methodName](replaceArray[0], {transformations, leaveUnmatchedTagsIntact:false});
144
- thisStepEvalFunction = item => !item[0].match(/unmatchedTag/);
145
- passingTests =
146
- completeStep(methodName, thisStepMessage, thisStepResult, thisStepEvalFunction) &&
147
- passingTests;
148
-
149
- //TEST ITEM ------------------------------------------------------
150
- methodName='qtTemplateReplace'
151
- thisStepMessage = "did not reatain unmatched tag";
152
- thisStepResult = templateList[methodName](replaceArray[0], {transformations, leaveUnmatchedTagsIntact:true});
153
- thisStepEvalFunction = item => item[0].match(/unmatchedTag/);
154
- passingTests =
155
- completeStep(methodName, thisStepMessage, thisStepResult, thisStepEvalFunction) &&
156
- passingTests;
157
-
158
-
159
-
160
-
161
- return passingTests;
162
- };
163
-
164
- //END OF moduleFunction() ============================================================
165
-
166
- module.exports = moduleFunction;
167
- //module.exports = new moduleFunction();
168
-
@@ -1,11 +0,0 @@
1
- {
2
- "name": "qtools-to-key-value-array",
3
- "version": "1.0.0",
4
- "description": "Takes an object, map or set. Converts object or map into an array of {key:'keyName', value:'value'} pairs. A set is converted to an array of values.",
5
- "main": "qtools-to-key-value-array.js",
6
- "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
8
- },
9
- "author": "TQ White II",
10
- "license": "ISC"
11
- }
@@ -1,83 +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 functionObject = new Map(); // prettier-ignore
14
-
15
- const methodName = 'qtToKeyValueArray';
16
- const description = `[Object|Set|Map].${methodName} Converts to an array of {key:'keyName', value:'value'} pairs. A Set does not have a key property.`;
17
- const supportedTypeList = [Object, Map, Set];
18
-
19
- const method = () =>
20
- function(arg) {
21
- if (!commonFunctions.isSupportedType(this, supportedTypeList)) {
22
- // prettier-ignore
23
- throw new Error(
24
- `${methodName}(): unsupported data type: '${commonFunctions.toType(this)}' (${methodName} supports ${supportedTypeList.map(item=>item.toString().replace(/.*function (.*?)\(\).*/, '$1')).join(', ')})`
25
- );
26
- }
27
-
28
- const outArray = [];
29
-
30
- switch (commonFunctions.toType(this)) {
31
- case 'object':
32
- for (var i in this) {
33
- if (!this.hasOwnProperty(i)) {
34
- continue;
35
- }
36
- var element = this[i];
37
- outArray.push({ key: i, value: element });
38
- }
39
-
40
- break;
41
- case 'map':
42
- this.forEach((item, inx) =>
43
- outArray.push({ key: inx, value: item })
44
- );
45
- break;
46
- case 'set':
47
- this.forEach(item => outArray.push({ value: item }));
48
- break;
49
- default:
50
- // prettier-ignore
51
- throw new Error(
52
- `${methodName}(): unsupported data type: '${commonFunctions.toType(this)}' (${methodName} supports ${supportedTypeList.map(item=>item.toString().replace(/.*function (.*?)\(\).*/, '$1')).join(', ')})`
53
- );
54
- break;
55
- }
56
-
57
- return outArray;
58
- };
59
-
60
- functionObject.set(methodName, {
61
- description,
62
- supportedTypeList,
63
- method,
64
- test: args => {
65
- return require('./test.js')({
66
- ...args,
67
- ...{
68
- moduleName: module.id.replace(module.path, '')
69
- }
70
- });
71
- }
72
- });
73
-
74
- return functionObject;
75
- };
76
- this.addToPrototype = addToPrototypeActual(
77
- firstMethodFunction(commonFunctions)
78
- );
79
-
80
- };
81
- //END OF moduleFunction() ============================================================
82
- module.exports = moduleFunction;
83
- //module.exports = new moduleFunction();
@@ -1,68 +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='qtToKeyValueArray'
51
- thisStepMessage = "not yet implemented";
52
- thisStepResult = testArray[methodName]();
53
- thisStepEvalFunction = item => item='allocute,Hello : SUFFIX';
54
- passingTests =
55
- completeStep(methodName, thisStepMessage, thisStepResult, thisStepEvalFunction) &&
56
- passingTests;
57
-
58
-
59
-
60
-
61
- return passingTests;
62
- };
63
-
64
- //END OF moduleFunction() ============================================================
65
-
66
- module.exports = moduleFunction;
67
- //module.exports = new moduleFunction();
68
-
@@ -1,11 +0,0 @@
1
- {
2
- "name": "qtools-to-string",
3
- "version": "1.0.0",
4
- "description": "implements qtToString() to allow more informative display of stuff",
5
- "main": "qtools-to-string.js",
6
- "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
8
- },
9
- "author": "TQ White II",
10
- "license": "ISC"
11
- }