qtools-library-dot-d 1.0.12 → 1.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -0
  3. package/package.json +2 -2
  4. package/libDotD_Working_Example/README.md +0 -234
  5. package/libDotD_Working_Example/demoModules_DotD/demo1.js +0 -46
  6. package/libDotD_Working_Example/demoModules_DotD/demo2.js +0 -48
  7. package/libDotD_Working_Example/index.js +0 -133
  8. package/libDotD_Working_Example/node_modules/.package-lock.json +0 -29
  9. package/libDotD_Working_Example/node_modules/qtools-asynchronous-pipe-plus/README.md +0 -213
  10. package/libDotD_Working_Example/node_modules/qtools-asynchronous-pipe-plus/package.json +0 -20
  11. package/libDotD_Working_Example/node_modules/qtools-asynchronous-pipe-plus/qtools-asynchronous-pipe-plus.js +0 -278
  12. package/libDotD_Working_Example/node_modules/qtools-asynchronous-pipe-plus/test.js +0 -79
  13. package/libDotD_Working_Example/node_modules/qtools-functional-library/README.md +0 -110
  14. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-clone/package.json +0 -11
  15. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-clone/qtools-clone.js +0 -103
  16. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-clone/test.js +0 -78
  17. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-get-by-property/package.json +0 -11
  18. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-get-by-property/qtools-get-by-property.js +0 -73
  19. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-get-by-property/test.js +0 -129
  20. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-includes-regex/package.json +0 -11
  21. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-includes-regex/qtools-includes-regex.js +0 -54
  22. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-includes-regex/test.js +0 -76
  23. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-log-output/package.json +0 -11
  24. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-log-output/qtools-log-output.js +0 -114
  25. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-log-output/test.js +0 -130
  26. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-map-properties/package.json +0 -11
  27. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-map-properties/qtools-map-properties.js +0 -99
  28. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-map-properties/test.js +0 -118
  29. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-merge/package.json +0 -11
  30. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-merge/qtools-merge.js +0 -147
  31. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-merge/test.js +0 -214
  32. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-new-method-template/package.json +0 -11
  33. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-new-method-template/qtools-new-method-template.js +0 -70
  34. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-new-method-template/test.js +0 -66
  35. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-number-iterator/package.json +0 -11
  36. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-number-iterator/qtools-number-iterator.js +0 -137
  37. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-number-iterator/test.js +0 -68
  38. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-number-keys-to-array/package.json +0 -11
  39. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-number-keys-to-array/qtools-number-keys-to-array.js +0 -131
  40. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-number-keys-to-array/test.js +0 -181
  41. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-object-sure-path/package.json +0 -11
  42. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-object-sure-path/qtools-object-sure-path.js +0 -204
  43. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-object-sure-path/test.js +0 -345
  44. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-pass-through/package.json +0 -11
  45. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-pass-through/qtools-pass-through.js +0 -58
  46. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-pass-through/test.js +0 -66
  47. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-pop/package.json +0 -11
  48. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-pop/qtools-pop.js +0 -175
  49. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-pop/test.js +0 -118
  50. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-print-debug/package.json +0 -11
  51. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-print-debug/qtools-print-debug.js +0 -352
  52. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-print-debug/test.js +0 -77
  53. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-select-properties/package.json +0 -11
  54. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-select-properties/qtools-select-properties.js +0 -132
  55. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-select-properties/test.js +0 -156
  56. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-template-replace/README.md +0 -3
  57. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-template-replace/package.json +0 -11
  58. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-template-replace/qtools-template-replace.js +0 -106
  59. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-template-replace/test.js +0 -168
  60. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-to-key-value-array/package.json +0 -11
  61. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-to-key-value-array/qtools-to-key-value-array.js +0 -83
  62. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-to-key-value-array/test.js +0 -68
  63. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-to-string/package.json +0 -11
  64. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-to-string/qtools-to-string.js +0 -84
  65. package/libDotD_Working_Example/node_modules/qtools-functional-library/lib/qtools-to-string/test.js +0 -63
  66. package/libDotD_Working_Example/node_modules/qtools-functional-library/package.json +0 -37
  67. package/libDotD_Working_Example/node_modules/qtools-functional-library/qtFunctionalDemo.js +0 -297
  68. package/libDotD_Working_Example/node_modules/qtools-functional-library/qtools-functional-library.js +0 -271
  69. package/libDotD_Working_Example/node_modules/qtools-functional-library/test.js +0 -47
  70. package/libDotD_Working_Example/node_modules/qtools-library-dot-d/README.md +0 -208
  71. package/libDotD_Working_Example/node_modules/qtools-library-dot-d/package.json +0 -15
  72. package/libDotD_Working_Example/node_modules/qtools-library-dot-d/qtools-library-dot-d.js +0 -239
  73. package/libDotD_Working_Example/package-lock.json +0 -37
  74. package/libDotD_Working_Example/package.json +0 -23
@@ -1,271 +0,0 @@
1
- const commonFunctions = {
2
- universalAddToPrototype: (commonFunctions, functionObject) => {
3
- let methods = [];
4
- let documentation = [];
5
- let methodName;
6
- let testList = [];
7
- functionObject.forEach((functionItem, inx) => {
8
- methodName = inx;
9
-
10
- const supportedTypeList = functionItem.supportedTypeList
11
- .map(item => item.toString().replace(/^function (.*?)\(.*$/, '$1'))
12
- .join(', ')
13
- .replace(/, $/, '');
14
-
15
- if (functionItem.test && typeof functionItem.test == 'function') {
16
- testList.push({ methodName, test: functionItem.test });
17
- }
18
-
19
- methods.push(methodName);
20
- documentation.push({
21
- name: methodName,
22
- description: `${functionItem.description}`,
23
- supportedTypeList
24
- });
25
-
26
- functionItem.supportedTypeList.forEach(target => {
27
- if (typeof target.prototype[methodName] == 'undefined') {
28
- Object.defineProperty(target.prototype, methodName, {
29
- value: functionItem.method(commonFunctions),
30
- writable: false,
31
- enumerable: false
32
- });
33
- }
34
- });
35
- });
36
- const testActual=methodName=>(args) => {
37
- const tmp = testList.reduce((passingTests, testItem, inx) => {
38
-
39
- if (typeof(args.methodList)!='undefined' && args.methodList.length>0 && !args.methodList.includes(methodName)){
40
- return true;
41
- }
42
-
43
- const result=passingTests && testItem.test(args) ? true : false;
44
-
45
-
46
- if (args.listTests){
47
- console.log(`${methodName} ${result?'passed':'failed'}`);
48
- }
49
-
50
- return result //calls test method passed from functional module
51
- }, true);
52
- return tmp;
53
- };
54
-
55
-
56
- const test = testActual(methodName);
57
-
58
- return {
59
- methods,
60
- documentation,
61
- test
62
- };
63
- },
64
-
65
- callerName: (calledFromQtLib = false, options={}) => {
66
- if (typeof(options)!='object'){
67
- throw(`qtools-functional-library.js internal error: options must be an object, got '${options}'`);
68
- }
69
- options.suffixCallStackDepth=options.suffixCallStackDepth?options.suffixCallStackDepth:3;
70
-
71
-
72
- const index = calledFromQtLib ? options.suffixCallStackDepth : 2; //the 1 might need adjusting once this is made available to applications
73
- return new Error().stack
74
- .split(/\n/)[index]
75
- .trim()
76
- .replace(/at new moduleFunction/, "called from")
77
- .replace(/Object\.<anonymous>/, 'not_in_function');
78
- },
79
-
80
- toType: function(obj) {
81
-
82
- if (obj instanceof Map) {
83
- return 'map';
84
- }
85
- if (obj instanceof Set) {
86
- return 'set';
87
- }
88
-
89
- if (typeof obj == 'string') {
90
- return 'string';
91
- }
92
-
93
- if (typeof obj == 'number') {
94
- return 'number';
95
- }
96
-
97
- if (typeof obj == 'obj' && typeof length == 'number') {
98
- return 'array';
99
- }
100
-
101
- if (obj === null) {
102
- return 'null';
103
- }
104
-
105
- if (typeof obj == 'undefined') {
106
- return 'undefined';
107
- }
108
-
109
- if (typeof obj == 'string') {
110
- return 'string';
111
- }
112
-
113
- return {}.toString
114
- .call(obj)
115
- .match(/\s([a-z|A-Z]+)/)[1]
116
- .toLowerCase();
117
- },
118
-
119
- byObjectProperty: function(fieldName, transformer) {
120
- //called: resultArray=someArray.sort(qtools.byObjectProperty('somePropertyName'));
121
- //based on closure of fieldName
122
- var fullNameSort;
123
- return (fullNameSort = function(a, b) {
124
- var localFieldName = fieldName;
125
- var localTransformer = transformer;
126
- //for debug
127
- if (typeof fieldName == 'function') {
128
- var aa = a;
129
- var bb = b;
130
- transformer = fieldName;
131
- } else {
132
- var aa = a.qtGetSurePath(fieldName);
133
- var bb = b.qtGetSurePath(fieldName);
134
- }
135
-
136
- if (typeof transformer == 'function') {
137
- aa = transformer(aa);
138
- bb = transformer(bb);
139
- } else if (transformer) {
140
- switch (transformer) {
141
- case 'caseInsensitive':
142
- aa = aa.toLowerCase();
143
- bb = bb.toLowerCase();
144
- break;
145
- default:
146
- console.log(
147
- 'qt.byObjectProperty says, No such transformer as: ' + transformer
148
- );
149
- break;
150
- }
151
- }
152
-
153
- if (!bb && !aa) {
154
- return 0;
155
- }
156
- if (!bb) {
157
- return -1;
158
- }
159
- if (!aa) {
160
- return 1;
161
- }
162
-
163
- if (aa > bb) {
164
- return 1;
165
- }
166
- if (aa < bb) {
167
- return -1;
168
- }
169
- return 0;
170
- });
171
- },
172
-
173
-
174
- isSupportedType: (input, supportedTypeList) =>
175
- supportedTypeList.reduce((result, supportedTypeItem) => {
176
- return (
177
- result || Object.getPrototypeOf(input) === supportedTypeItem.prototype
178
- ); //instoanceof does not work for strings and numbers
179
- }, false)
180
- };
181
-
182
- // Array.prototype.remove = function(from, to) {
183
- // var rest = this.slice((to || from) + 1 || this.length);
184
- // this.length = from < 0 ? this.length + from : from;
185
- // return this.push.apply(this, rest);
186
- // };
187
-
188
- String.prototype.toCamelCase = function(delimiter, pascalCase) {
189
- var firstCharFunction = pascalCase
190
- ? function(v) {
191
- return v.toUpperCase();
192
- }
193
- : function(v) {
194
- return v.toLowerCase();
195
- };
196
- delimiter = delimiter ? delimiter : ' ';
197
- return this.split(delimiter)
198
- .map(function(word) {
199
- var first = word.substring(0, 1);
200
- word = word.replace(new RegExp(first), first.toUpperCase());
201
- return word;
202
- })
203
- .join('')
204
- .replace(/^(.)/, firstCharFunction);
205
- };
206
-
207
- const docList = [];
208
- const testList = [];
209
-
210
- const addMorePrototypes = () => {
211
- const fs = require('fs');
212
- const path = require('path');
213
- const libDir = path.join(path.dirname(module.filename), 'lib');
214
- const dirList = fs.readdirSync(libDir);
215
-
216
- dirList.forEach(item => {
217
- if (item.match(/^qtools/)) {
218
- const moduleGen = require(path.join(libDir, item));
219
- const module = new moduleGen({ commonFunctions });
220
- const result = module.addToPrototype();
221
- result.documentation && docList.push(result.documentation);
222
- result.test && testList.push(result.test);
223
- }
224
- });
225
- };
226
-
227
- addMorePrototypes();
228
-
229
- const helpActual = docList => (options={}) => {
230
-
231
- const {printOutput=true, sendJson=false, queryString='.*'}=options;
232
-
233
- let rawList;
234
- if (!queryString) {
235
- rawList = docList;
236
- } else {
237
- rawList = docList.filter(item => {
238
- const regex = new RegExp(queryString, 'i');
239
- const result = JSON.stringify(item).match(regex);
240
- return result;
241
- });
242
- }
243
-
244
- let outArray=[];
245
- rawList.forEach(item=>{
246
- outArray=outArray.concat(item);
247
- });
248
-
249
- const outString='<!name!>: <!description!> (<!supportedTypeList!>) '.qtTemplateReplace(outArray).join('\n');
250
-
251
- if (printOutput){
252
- console.log(outString);
253
- }
254
- return outString;
255
- };
256
-
257
- const testActual = testList => (args={}) => {
258
- return testList.reduce((result, test) => {
259
- if (typeof test == 'function') {
260
- result = test(args) && result; //executes the framework testItem.test() above
261
- }
262
- return result;
263
- }, true);
264
- };
265
-
266
- commonFunctions.qtLog_AddCallableMethods("what part of 'not for civilian use' is unclear?");
267
-
268
- commonFunctions.help = helpActual(docList);
269
- commonFunctions.test = testActual(testList);
270
- module.exports = commonFunctions;
271
-
@@ -1,47 +0,0 @@
1
- #!/usr/local/bin/node
2
- 'use strict';
3
-
4
- const qt = require('./qtools-functional-library.js');
5
-
6
- //console.dir(qt.help());
7
- const verbose=process.argv.filter(item=>item.match(/verbose/i))[0]?true:false
8
- const logErrors=process.argv.filter(item=>item.match(/logErrors/i))[0]?true:false
9
- const listTests=process.argv.filter(item=>item.match(/listTests/i))[0]?true:false
10
-
11
- const methodList=process.argv
12
- .qtClone() //create a deep copy so changes can't leak back to the source
13
- .filter(item=>item.match(/^--methodList/)) //['--methodList=qtClone,qtToString,qtPop']
14
- .qtGetSurePath('[0]', '') //'--methodList=qtClone,qtToString,qtPop'
15
- .split('=') //['--methodList', 'qtClone,qtToString,qtPop']
16
- .qtGetSurePath('[1]', '') //'qtClone,qtToString,qtPop'
17
- .split(',') //['qtClone', 'qtToString', 'qtPop']
18
- .filter(item=>item.length>0) //eliminates the empty if default
19
-
20
-
21
- const result=qt.test({logErrors, verbose, methodList, listTests});
22
- console.log(result?"PASSED ALL TESTS":"");
23
-
24
- const showAdditionalInfo=(verbose, result)=>{
25
- console.log(`result=${result}`);
26
-
27
- if (!verbose && result){
28
- return;
29
- }
30
- console.log(`
31
-
32
- Additional Usage:
33
- npm logTest; #node --trace-uncaught test.js -listTests -logErrors --methodList=qtLog
34
- npm test; #node test.js -verbose -logErrors
35
- npm quiet; #node test.js -listTests -logErrors
36
-
37
- # -logErrors shows the message from any failing tests
38
-
39
- or find .../qtools-functional-library/test.js and execute, eg,
40
- cd .../qtools-functional-library/test.js;
41
- node test.js --methodList=qtMapProperties
42
- `)
43
-
44
- }
45
- showAdditionalInfo(verbose, result)
46
-
47
- process.exit(result?0:1);
@@ -1,208 +0,0 @@
1
- # qtools-library-dot-d
2
-
3
- # NOT READY. STILL WORKING IT OUT.
4
-
5
- NAME
6
-
7
-     qtools-library-dot-d
8
-
9
- DESCRIPTION
10
-
11
- Utility provides tools to scan a directory for NodeJS modules, require() them into existance with tools to connect them to a system.
12
-
13
-
14
-
15
- First use case is adding endpoints to an expressJS system. When instantiated, qtDotD
16
-
17
- scans a directory containing modules, dotLib.d. It requires it with two parameters,
18
-
19
- dotD and passThroughArgs. For this case, passThrough args has two properties,
20
-
21
- expressApp and routingPrefix. The module uses these to construct one or more
22
-
23
- expressJS endpoitns.
24
-
25
-
26
-
27
- the dotD object contains three parameters, add....
28
-
29
- ASYNCHRONOUS CODE SAMPLE
30
-
31
- const promptObjects = require('qtools-library-dot-d')({
32
- libraryName: 'promptObjects',
33
- }, callback);
34
- promptObjects.setLibraryPath(path.join(__dirname, 'prompts.d'), callback);
35
-
36
- const passThroughParameters = {};
37
- promptObjects.loadModules({ passThroughParameters }, callback);
38
- promptObjects.seal(); //make the library immutable
39
-
40
-
41
-
42
- SYNCHROMOUS CODE SAMPLE:
43
-
44
- const promptObjects = require('qtools-library-dot-d')({
45
- libraryName: 'promptObjects',
46
- });
47
- promptObjects.setLibraryPath(path.join(__dirname, 'prompts.d'));
48
-
49
- const passThroughParameters = {};
50
- promptObjects.loadModules({ passThroughParameters });
51
- promptObjects.seal(); //make the library immutable
52
-
53
-
54
- COMPLETE WORKING CODE SAMPLE
55
-
56
- // ================================================================================
57
- // index.js for demonstration
58
-
59
- #!/usr/bin/env node
60
- 'use strict';
61
- // Suppress punycode deprecation warning
62
- process.noDeprecation = true;
63
-
64
- const moduleName = __filename.replace(__dirname + '/', '').replace(/.js$/, ''); //this just seems to come in handy a lot
65
-
66
- // const qt = require('qtools-functional-library'); //also exposes qtLog(); qt.help({printOutput:true, queryString:'.*', sendJson:false});
67
-
68
- const os = require('os');
69
- const path = require('path');
70
- const fs = require('fs');
71
-
72
- const qtLibDotD = require('qtools-library-dot-d');
73
-
74
- //START OF moduleFunction() ============================================================
75
- const moduleFunction =
76
- ({ moduleName } = {}) =>
77
- ({ unused } = {}) => {
78
-
79
- // ========================================================================
80
- // SYNCHRONOUS DEMO
81
-
82
- const synchronousDemo = () => {
83
- const demoDotD = qtLibDotD({
84
- libraryName: 'demoDotD',
85
- });
86
-
87
- const libraryModulesPath = path.join(__dirname, 'demoModules_DotD');
88
-
89
- const passThroughParameters = {
90
- message: 'Hello from a dotDlib module',
91
- add: (a, b) => a + b,
92
- };
93
-
94
- demoDotD.setLibraryPath(libraryModulesPath);
95
- demoDotD.loadModules({ passThroughParameters });
96
- demoDotD.seal();
97
-
98
- // console.log(demoDotD.qtdProcessLog());
99
- console.log(demoDotD.toString());
100
-
101
- demoDotD.demo1();
102
- demoDotD.demo2(10, 7);
103
- };
104
- console.log(`SYNCHRONOUS DEMO =====================================`);
105
- synchronousDemo();
106
-
107
- // ========================================================================
108
- // ASYNCHRONOUS DEMO
109
-
110
- const asynchronousDemo = (callback) => {
111
- const localCallback = (err) => {
112
- demoDotD.seal();
113
- callback(err, demoDotD);
114
- };
115
-
116
- const demoDotD = qtLibDotD({
117
- libraryName: 'demoDotD',
118
- });
119
-
120
- const libraryModulesPath = path.join(__dirname, 'demoModules_DotD');
121
-
122
- const passThroughParameters = {
123
- message: 'Hello from a dotDlib module',
124
- add: (a, b) => a + b,
125
- };
126
-
127
- demoDotD.setLibraryPath(libraryModulesPath);
128
- demoDotD.loadModules({ passThroughParameters }, localCallback);
129
- };
130
-
131
- console.log(`\n\nASYNCHRONOUS DEMO =====================================`);
132
-
133
- const callback = (err, demoDotD) => {
134
- console.log(demoDotD.toString());
135
- demoDotD.demo1();
136
- demoDotD.demo2(10, 7);
137
- };
138
-
139
- asynchronousDemo(callback);
140
- };
141
-
142
-
143
- // ================================================================================
144
- // demo1.js
145
-
146
- #!/usr/bin/env node
147
- 'use strict';
148
- // Suppress punycode deprecation warning
149
- process.noDeprecation = true;
150
-
151
- const moduleName = __filename.replace(__dirname + '/', '').replace(/.js$/, ''); //this just seems to come in handy a lot
152
-
153
- //START OF moduleFunction() ============================================================
154
- const moduleFunction = ({ moduleName } = {}) => ({ dotD, passThroughParameters } = {}) => {
155
-
156
- const workingFunction = () => {
157
- console.log(`${passThroughParameters.message} [${moduleName}]`);
158
- return 'hello';
159
- };
160
-
161
-
162
- dotD.library.add(moduleName, workingFunction);
163
- };
164
-
165
- //END OF moduleFunction() ============================================================
166
-
167
- module.exports = moduleFunction({ moduleName }); //runs it right now
168
- //END OF moduleFunction() ============================================================
169
-
170
- module.exports = moduleFunction({ moduleName })({});
171
-
172
-
173
- // ================================================================================
174
- //demo2.js
175
-
176
- #!/usr/bin/env node
177
- 'use strict';
178
- // Suppress punycode deprecation warning
179
- process.noDeprecation = true;
180
-
181
- const moduleName = __filename.replace(__dirname + '/', '').replace(/.js$/, ''); //this just seems to come in handy a lot
182
-
183
- //START OF moduleFunction() ============================================================
184
- const moduleFunction = ({ moduleName } = {}) => ({ dotD, passThroughParameters } = {}) => {
185
-
186
- const workingFunction = (arg1, arg2) => {
187
- console.log(`Pass Through Function: ${arg1}+${arg2}=${passThroughParameters.add(arg1, arg2)} [${moduleName}]`);
188
- return 'hello';
189
- };
190
-
191
-
192
- dotD.library.add(moduleName, workingFunction);
193
- };
194
-
195
- //END OF moduleFunction() ============================================================
196
-
197
- module.exports = moduleFunction({ moduleName }); //runs it right now
198
-
199
-
200
- HISTORY
201
-
202
- v1.05 - cleaned up toString() report, returns exception list (or err if callback) if needed, added qtools-functional-library
203
- v1.04 - Now tolerates (and reports) directories and files that are not modules.
204
-
205
-
206
- HISTORY
207
-
208
- v1.04 - Now tolerates (and reports) directories and files that are not modules.
@@ -1,15 +0,0 @@
1
- {
2
- "name": "qtools-library-dot-d",
3
- "version": "1.0.5",
4
- "description": "Scan a directory for JS modules that can execute and addMe() that attaches it to some form of name/value list, eg, a Map() with functions as values or an xPressJS route/endpoint list.",
5
- "main": "qtools-library-dot-d.js",
6
- "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
8
- },
9
- "author": "TQ White II",
10
- "license": "ISC",
11
- "dependencies": {
12
- "qtools-asynchronous-pipe-plus": "^1.0.2",
13
- "qtools-functional-library": "^2.0.4"
14
- }
15
- }