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.
- package/LICENSE +21 -0
- package/README.md +1 -0
- package/package.json +2 -2
- package/libDotD_Working_Example/README.md +0 -234
- package/libDotD_Working_Example/demoModules_DotD/demo1.js +0 -46
- package/libDotD_Working_Example/demoModules_DotD/demo2.js +0 -48
- package/libDotD_Working_Example/index.js +0 -133
- package/libDotD_Working_Example/node_modules/.package-lock.json +0 -29
- package/libDotD_Working_Example/node_modules/qtools-asynchronous-pipe-plus/README.md +0 -213
- package/libDotD_Working_Example/node_modules/qtools-asynchronous-pipe-plus/package.json +0 -20
- package/libDotD_Working_Example/node_modules/qtools-asynchronous-pipe-plus/qtools-asynchronous-pipe-plus.js +0 -278
- package/libDotD_Working_Example/node_modules/qtools-asynchronous-pipe-plus/test.js +0 -79
- package/libDotD_Working_Example/node_modules/qtools-functional-library/README.md +0 -110
- package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-clone/package.json +0 -11
- package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-clone/qtools-clone.js +0 -103
- package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-clone/test.js +0 -78
- package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-get-by-property/package.json +0 -11
- package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-get-by-property/qtools-get-by-property.js +0 -73
- package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-get-by-property/test.js +0 -129
- package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-includes-regex/package.json +0 -11
- package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-includes-regex/qtools-includes-regex.js +0 -54
- package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-includes-regex/test.js +0 -76
- package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-log-output/package.json +0 -11
- package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-log-output/qtools-log-output.js +0 -114
- package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-log-output/test.js +0 -130
- package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-map-properties/package.json +0 -11
- package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-map-properties/qtools-map-properties.js +0 -99
- package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-map-properties/test.js +0 -118
- package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-merge/package.json +0 -11
- package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-merge/qtools-merge.js +0 -147
- package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-merge/test.js +0 -214
- package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-new-method-template/package.json +0 -11
- package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-new-method-template/qtools-new-method-template.js +0 -70
- package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-new-method-template/test.js +0 -66
- package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-number-iterator/package.json +0 -11
- package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-number-iterator/qtools-number-iterator.js +0 -137
- package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-number-iterator/test.js +0 -68
- package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-number-keys-to-array/package.json +0 -11
- package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-number-keys-to-array/qtools-number-keys-to-array.js +0 -131
- package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-number-keys-to-array/test.js +0 -181
- package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-object-sure-path/package.json +0 -11
- package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-object-sure-path/qtools-object-sure-path.js +0 -204
- package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-object-sure-path/test.js +0 -345
- package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-pass-through/package.json +0 -11
- package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-pass-through/qtools-pass-through.js +0 -58
- package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-pass-through/test.js +0 -66
- package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-pop/package.json +0 -11
- package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-pop/qtools-pop.js +0 -175
- package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-pop/test.js +0 -118
- package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-print-debug/package.json +0 -11
- package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-print-debug/qtools-print-debug.js +0 -352
- package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-print-debug/test.js +0 -77
- package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-select-properties/package.json +0 -11
- package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-select-properties/qtools-select-properties.js +0 -132
- package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-select-properties/test.js +0 -156
- package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-template-replace/README.md +0 -3
- package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-template-replace/package.json +0 -11
- package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-template-replace/qtools-template-replace.js +0 -106
- package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-template-replace/test.js +0 -168
- package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-to-key-value-array/package.json +0 -11
- package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-to-key-value-array/qtools-to-key-value-array.js +0 -83
- package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-to-key-value-array/test.js +0 -68
- package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-to-string/package.json +0 -11
- package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-to-string/qtools-to-string.js +0 -84
- package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-to-string/test.js +0 -63
- package/libDotD_Working_Example/node_modules/qtools-functional-library/package.json +0 -37
- package/libDotD_Working_Example/node_modules/qtools-functional-library/qtFunctionalDemo.js +0 -297
- package/libDotD_Working_Example/node_modules/qtools-functional-library/qtools-functional-library.js +0 -271
- package/libDotD_Working_Example/node_modules/qtools-functional-library/test.js +0 -47
- package/libDotD_Working_Example/node_modules/qtools-library-dot-d/README.md +0 -208
- package/libDotD_Working_Example/node_modules/qtools-library-dot-d/package.json +0 -15
- package/libDotD_Working_Example/node_modules/qtools-library-dot-d/qtools-library-dot-d.js +0 -239
- package/libDotD_Working_Example/package-lock.json +0 -37
- package/libDotD_Working_Example/package.json +0 -23
package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-log-output/test.js
DELETED
|
@@ -1,130 +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 = ({
|
|
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} (${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 testObject={
|
|
40
|
-
substitution1:'with object substitution',
|
|
41
|
-
nested:{
|
|
42
|
-
element:'replaced from a nested element'
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const replaceObject={
|
|
47
|
-
fromReplaceObj:"additional replacement object substitution"
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
//TEST ITEM ------------------------------------------------------
|
|
52
|
-
methodName = 'qtLog';
|
|
53
|
-
thisStepMessage = 'object.qtLog() message test';
|
|
54
|
-
thisStepResult = testObject[methodName](thisStepMessage, {noSuffix:true, destination:'returnString'});
|
|
55
|
-
thisStepEvalFunction = item => item==thisStepMessage;
|
|
56
|
-
passingTests =
|
|
57
|
-
completeStep(
|
|
58
|
-
methodName,
|
|
59
|
-
thisStepMessage,
|
|
60
|
-
thisStepResult,
|
|
61
|
-
thisStepEvalFunction
|
|
62
|
-
) && passingTests;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
methodName = 'qtLog';
|
|
66
|
-
thisStepMessage = 'object.qtLog() message test -><!substitution1!><-';
|
|
67
|
-
thisStepResult = testObject[methodName](thisStepMessage, {noSuffix:true, destination:'returnString'});
|
|
68
|
-
thisStepEvalFunction = item => item=='object.qtLog() message test ->with object substitution<-';
|
|
69
|
-
passingTests =
|
|
70
|
-
completeStep(
|
|
71
|
-
methodName,
|
|
72
|
-
thisStepMessage,
|
|
73
|
-
thisStepResult,
|
|
74
|
-
thisStepEvalFunction
|
|
75
|
-
) && passingTests;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
methodName = 'qtLog';
|
|
79
|
-
thisStepMessage = 'object.qtLog() message test -><!substitution1!><- and -><!fromReplaceObj!><-';
|
|
80
|
-
thisStepResult = testObject[methodName](thisStepMessage, {noSuffix:true, destination:'returnString', substitutions:replaceObject});
|
|
81
|
-
thisStepEvalFunction = item => item=='object.qtLog() message test ->with object substitution<- and ->additional replacement object substitution<-';
|
|
82
|
-
passingTests =
|
|
83
|
-
completeStep(
|
|
84
|
-
methodName,
|
|
85
|
-
thisStepMessage,
|
|
86
|
-
thisStepResult,
|
|
87
|
-
thisStepEvalFunction
|
|
88
|
-
) && passingTests;
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
methodName = 'qtLog';
|
|
92
|
-
thisStepMessage = 'object.qtLog() message test -><!nested.element!><-';
|
|
93
|
-
thisStepResult = testObject[methodName](thisStepMessage, {noSuffix:true, destination:'returnString', substitutions:testObject});
|
|
94
|
-
thisStepEvalFunction = item => item=='object.qtLog() message test ->replaced from a nested element<-';
|
|
95
|
-
passingTests =
|
|
96
|
-
completeStep(
|
|
97
|
-
methodName,
|
|
98
|
-
thisStepMessage,
|
|
99
|
-
thisStepResult,
|
|
100
|
-
thisStepEvalFunction
|
|
101
|
-
) && passingTests;
|
|
102
|
-
|
|
103
|
-
const qt=require('../../qtools-functional-library');
|
|
104
|
-
|
|
105
|
-
methodName = 'log';
|
|
106
|
-
thisStepMessage = 'qt.log() message test -><!substitution1!><-';
|
|
107
|
-
thisStepResult = qt[methodName](thisStepMessage, {noSuffix:true, destination:'returnString', substitutions:testObject});
|
|
108
|
-
thisStepEvalFunction = item => item=='qt.log() message test ->with object substitution<-';
|
|
109
|
-
passingTests =
|
|
110
|
-
completeStep(
|
|
111
|
-
methodName,
|
|
112
|
-
thisStepMessage,
|
|
113
|
-
thisStepResult,
|
|
114
|
-
thisStepEvalFunction
|
|
115
|
-
) && passingTests;
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
return passingTests;
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
//END OF moduleFunction() ============================================================
|
|
127
|
-
|
|
128
|
-
module.exports = moduleFunction;
|
|
129
|
-
//module.exports = new moduleFunction();
|
|
130
|
-
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "qtools-map-properties",
|
|
3
|
-
"version": "1.0.0",
|
|
4
|
-
"description": " Transform and add properties to a javascript object or array of objects",
|
|
5
|
-
"main": "qtools-map-properties.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
-
},
|
|
9
|
-
"author": "TQ White II",
|
|
10
|
-
"license": "ISC"
|
|
11
|
-
}
|
|
@@ -1,99 +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 = 'qtMapProperties';
|
|
14
|
-
const description = `operand.qtMapProperties() transforms and adds properties to a javascript object or array of objects`;
|
|
15
|
-
const supportedTypeList = [Array, Object];
|
|
16
|
-
|
|
17
|
-
const method = () =>
|
|
18
|
-
function(mappings = {}, options = {}) {
|
|
19
|
-
const mappingFunction = item => {
|
|
20
|
-
const outObj = item.qtClone();
|
|
21
|
-
const originalThis = item.qtClone();
|
|
22
|
-
|
|
23
|
-
// mappingElementFunction=(item, name, entire)=>{}; //note: synthetic elements have item==undefined
|
|
24
|
-
|
|
25
|
-
Object.keys(mappings).forEach(name => {
|
|
26
|
-
if (typeof mappings[name] == 'function') {
|
|
27
|
-
outObj[name] = mappings[name](
|
|
28
|
-
originalThis[name],
|
|
29
|
-
name,
|
|
30
|
-
originalThis
|
|
31
|
-
);
|
|
32
|
-
} else {
|
|
33
|
-
outObj[name] = mappings[name];
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
return outObj;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (this instanceof Array) {
|
|
42
|
-
return this.map(item => mappingFunction(item));
|
|
43
|
-
} else {
|
|
44
|
-
return mappingFunction(this);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
const test = args => {
|
|
50
|
-
return require('./test.js')({
|
|
51
|
-
...args,
|
|
52
|
-
...{
|
|
53
|
-
moduleName: module.id.replace(module.path, '')
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
return {
|
|
59
|
-
methodName,
|
|
60
|
-
description,
|
|
61
|
-
supportedTypeList,
|
|
62
|
-
method,
|
|
63
|
-
test
|
|
64
|
-
};
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const functionObject = new Map(); // prettier-ignore
|
|
69
|
-
const addFunction = definition => {
|
|
70
|
-
const {
|
|
71
|
-
methodName,
|
|
72
|
-
description,
|
|
73
|
-
supportedTypeList,
|
|
74
|
-
method,
|
|
75
|
-
test
|
|
76
|
-
} = definition;
|
|
77
|
-
functionObject.set(methodName, {
|
|
78
|
-
description,
|
|
79
|
-
supportedTypeList,
|
|
80
|
-
method,
|
|
81
|
-
test: args => {
|
|
82
|
-
return require('./test.js')({
|
|
83
|
-
...args,
|
|
84
|
-
...{
|
|
85
|
-
moduleName: module.id.replace(module.path, '')
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
addFunction(firstMethodFunction());
|
|
93
|
-
|
|
94
|
-
this.addToPrototype = addToPrototypeActual(functionObject);
|
|
95
|
-
|
|
96
|
-
};
|
|
97
|
-
//END OF moduleFunction() ============================================================
|
|
98
|
-
module.exports = moduleFunction;
|
|
99
|
-
//module.exports = new moduleFunction();
|
|
@@ -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
|
-
|
|
42
|
-
const testObject={
|
|
43
|
-
one: 1,
|
|
44
|
-
two: 2
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const testArray=[
|
|
48
|
-
{
|
|
49
|
-
alpha: 11,
|
|
50
|
-
beta: 12
|
|
51
|
-
},{
|
|
52
|
-
alpha: 21,
|
|
53
|
-
beta: 22
|
|
54
|
-
}
|
|
55
|
-
];
|
|
56
|
-
|
|
57
|
-
const testOneArgument={
|
|
58
|
-
one: (item, name, entire)=>item*1000
|
|
59
|
-
}
|
|
60
|
-
const testTwoArgument={
|
|
61
|
-
one: (item, name, entire)=>item*1000,
|
|
62
|
-
addedValue:(item, name, entire)=>`${name} says, item:${item} becomes ${Object.keys(entire).join(', ')}`
|
|
63
|
-
}
|
|
64
|
-
const testThreeArgument={
|
|
65
|
-
alpha: (item, name, entire)=>item*1000,
|
|
66
|
-
addedValue:(item, name, entire)=>`${name} says, item:${item} becomes ${Object.keys(entire).join(', ')}`
|
|
67
|
-
}
|
|
68
|
-
// map one object
|
|
69
|
-
// map one with added property
|
|
70
|
-
// map array
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
//TEST ITEM ------------------------------------------------------
|
|
75
|
-
methodName='qtMapProperties'
|
|
76
|
-
thisStepMessage = "did not get map one object ";
|
|
77
|
-
thisStepResult = testObject[methodName](testOneArgument);
|
|
78
|
-
thisStepEvalFunction = item => (item.one==1000 && item.two==2);
|
|
79
|
-
passingTests =
|
|
80
|
-
completeStep(methodName, thisStepMessage, thisStepResult, thisStepEvalFunction) &&
|
|
81
|
-
passingTests;
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
//TEST ITEM ------------------------------------------------------
|
|
85
|
-
methodName='qtMapProperties'
|
|
86
|
-
thisStepMessage = "did not map one with added property";
|
|
87
|
-
thisStepResult = testObject[methodName](testTwoArgument);
|
|
88
|
-
thisStepEvalFunction = item => (item.one==1000 && item.two==2 && item.addedValue=='addedValue says, item:undefined becomes one, two');
|
|
89
|
-
passingTests =
|
|
90
|
-
completeStep(methodName, thisStepMessage, thisStepResult, thisStepEvalFunction) &&
|
|
91
|
-
passingTests;
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
//TEST ITEM ------------------------------------------------------
|
|
95
|
-
methodName='qtMapProperties'
|
|
96
|
-
thisStepMessage = "did not map array woth added property";
|
|
97
|
-
thisStepResult = testArray[methodName](testThreeArgument);
|
|
98
|
-
thisStepEvalFunction = item => (
|
|
99
|
-
item[0].alpha==11000 &&
|
|
100
|
-
item[0].beta==12 &&
|
|
101
|
-
item[0].addedValue=='addedValue says, item:undefined becomes alpha, beta' &&
|
|
102
|
-
item[1].alpha==21000 &&
|
|
103
|
-
item[1].beta==22 &&
|
|
104
|
-
item[1].addedValue=='addedValue says, item:undefined becomes alpha, beta'
|
|
105
|
-
);
|
|
106
|
-
passingTests =
|
|
107
|
-
completeStep(methodName, thisStepMessage, thisStepResult, thisStepEvalFunction) &&
|
|
108
|
-
passingTests;
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
return passingTests;
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
//END OF moduleFunction() ============================================================
|
|
115
|
-
|
|
116
|
-
module.exports = moduleFunction;
|
|
117
|
-
//module.exports = new moduleFunction();
|
|
118
|
-
|
|
@@ -1,147 +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 baseMerge = (receivingObject, sendingObject, args = {}) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const { mergeNonExistent = true } = args;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
if (
|
|
17
|
-
['string', 'number', 'boolean', 'function', 'date'].includes(
|
|
18
|
-
typeof sendingObject
|
|
19
|
-
)
|
|
20
|
-
) {
|
|
21
|
-
receivingObject = sendingObject;
|
|
22
|
-
return receivingObject;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
for (var i in sendingObject) {
|
|
28
|
-
if (!sendingObject.hasOwnProperty(i)) {
|
|
29
|
-
continue;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
var element = sendingObject[i];
|
|
33
|
-
|
|
34
|
-
if (
|
|
35
|
-
['string', 'number', 'boolean', 'function', 'date'].includes(
|
|
36
|
-
typeof element
|
|
37
|
-
) ||
|
|
38
|
-
['string', 'number', 'boolean', 'function', 'date'].includes(
|
|
39
|
-
typeof receivingObject[i]
|
|
40
|
-
)
|
|
41
|
-
) {
|
|
42
|
-
receivingObject[i] = element;
|
|
43
|
-
continue;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
if (
|
|
47
|
-
mergeNonExistent &&
|
|
48
|
-
(element == null || typeof element == 'undefined' || element === '')
|
|
49
|
-
) {
|
|
50
|
-
receivingObject[i] = element;
|
|
51
|
-
continue;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (element instanceof Array) {
|
|
55
|
-
if (typeof receivingObject[i] == 'undefined') {
|
|
56
|
-
receivingObject[i] = [];
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
element.forEach((item, inx) => {
|
|
60
|
-
if (
|
|
61
|
-
receivingObject.qtGetSurePath(`${i}.${inx}`) &&
|
|
62
|
-
element.qtGetSurePath(`${inx}`)
|
|
63
|
-
) {
|
|
64
|
-
|
|
65
|
-
receivingObject[i][inx] = baseMerge(
|
|
66
|
-
receivingObject[i][inx],
|
|
67
|
-
element[inx],
|
|
68
|
-
args
|
|
69
|
-
);
|
|
70
|
-
} else if (element.qtGetSurePath(`${inx}`)) {
|
|
71
|
-
receivingObject[i][inx] = element[inx];
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
continue;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
if (element instanceof Object) {
|
|
80
|
-
if (typeof receivingObject[i] == 'undefined') {
|
|
81
|
-
receivingObject[i] = {};
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
receivingObject[i] = baseMerge(receivingObject[i], element, args);
|
|
85
|
-
continue;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return receivingObject;
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
//first method definition function ==========================
|
|
93
|
-
const firstMethodFunction = commonFunctions => {
|
|
94
|
-
const functionObject = new Map(); // prettier-ignore
|
|
95
|
-
|
|
96
|
-
const methodName = 'qtMerge';
|
|
97
|
-
const description = `Deep merge of two objects. Clones by default. receivingObject.qtMerge(sendingObject, {mutateObjects:false, mergeNonExistent:true}). DOESN'T YET WORK FOR MAPS OR SETS.`;
|
|
98
|
-
const supportedTypeList = [Object];
|
|
99
|
-
|
|
100
|
-
const method = () =>
|
|
101
|
-
function(sendingObject, args = {}) {
|
|
102
|
-
//if one of the supportedTypeList elements is Object, basically all data types will have this method and type checking is important.
|
|
103
|
-
if (!commonFunctions.isSupportedType(this, supportedTypeList)) {
|
|
104
|
-
// prettier-ignore
|
|
105
|
-
throw new Error(
|
|
106
|
-
`${methodName}(): unsupported data type: '${commonFunctions.toType(this)}' (${methodName} supports ${supportedTypeList.map(item=>item.toString().replace(/.*function (.*?)\(\).*/, '$1')).join(', ')})`
|
|
107
|
-
);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
const { mutateObjects = false } = args;
|
|
111
|
-
|
|
112
|
-
let receivingObject = this;
|
|
113
|
-
|
|
114
|
-
if (!mutateObjects) {
|
|
115
|
-
receivingObject = this.qtClone();
|
|
116
|
-
sendingObject = sendingObject.qtClone();
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
const outObj = baseMerge(receivingObject, sendingObject, args);
|
|
120
|
-
|
|
121
|
-
return outObj;
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
functionObject.set(methodName, {
|
|
125
|
-
description,
|
|
126
|
-
supportedTypeList,
|
|
127
|
-
method,
|
|
128
|
-
test: args => {
|
|
129
|
-
return require('./test.js')({
|
|
130
|
-
...args,
|
|
131
|
-
...{
|
|
132
|
-
moduleName: module.id.replace(module.path, '')
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
return functionObject;
|
|
139
|
-
};
|
|
140
|
-
this.addToPrototype = addToPrototypeActual(
|
|
141
|
-
firstMethodFunction(commonFunctions)
|
|
142
|
-
);
|
|
143
|
-
|
|
144
|
-
};
|
|
145
|
-
//END OF moduleFunction() ============================================================
|
|
146
|
-
module.exports = moduleFunction;
|
|
147
|
-
//module.exports = new moduleFunction();
|