binhend 1.4.4 → 1.5.1
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/package.json +1 -1
- package/src/binh.web.builder.js +45 -46
- package/src/code.js +52 -26
- package/src/component.build.js +39 -16
- package/src/component.file.js +43 -4
- package/src/component.format.js +6 -8
- package/test.js +45 -19
package/package.json
CHANGED
package/src/binh.web.builder.js
CHANGED
|
@@ -135,72 +135,71 @@ function WebBuilder(binh, Binh) {
|
|
|
135
135
|
return Binh;
|
|
136
136
|
};
|
|
137
137
|
|
|
138
|
-
Binh.web = function(webPath, sourcePath, modulePath) {
|
|
139
|
-
switch (arguments.length) {
|
|
140
|
-
case 1:
|
|
141
|
-
Binh.webStatic(webPath);
|
|
142
|
-
break;
|
|
143
|
-
|
|
144
|
-
case 2:
|
|
145
|
-
Binh.webApp(sourcePath, webPath);
|
|
146
|
-
break;
|
|
147
|
-
|
|
148
|
-
default:
|
|
149
|
-
if (arguments.length > 2) {
|
|
150
|
-
Binh.webApp(webPath, sourcePath, modulePath);
|
|
151
|
-
}
|
|
152
|
-
break;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
return Binh;
|
|
156
|
-
};
|
|
157
|
-
|
|
158
138
|
Binh.webStatic = function(webPath) {
|
|
159
|
-
|
|
160
|
-
Binh.web.value = getAbsolutePaths(webPath).web;
|
|
139
|
+
Binh.web.value = getAbsolutePath(webPath);
|
|
161
140
|
return Binh;
|
|
162
141
|
};
|
|
163
142
|
|
|
164
|
-
Binh.
|
|
165
|
-
if (!isString(
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
var { source,
|
|
143
|
+
Binh.webModule = function({ source, module }, onDone) {
|
|
144
|
+
if (!(isString(source) && isString(module))) {
|
|
145
|
+
throw new Error(`[BINHEND][WEB-BUILDER] Require paths for source and module. Current: { source: ${source}, module: ${module} }`);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
var { source, module } = getAbsolutePaths({ source, module });
|
|
170
149
|
|
|
171
|
-
ComponentFormat.generate(source, module,
|
|
150
|
+
ComponentFormat.generate(source, module, onDone);
|
|
172
151
|
|
|
173
|
-
Binh
|
|
152
|
+
return Binh;
|
|
153
|
+
};
|
|
174
154
|
|
|
155
|
+
Binh.webModuleBundle = function({ source, module, web }) {
|
|
156
|
+
var { source, module, web } = processWebBuildPaths({ source, module, web });
|
|
157
|
+
ComponentBuild.bundle({ source, module, web });
|
|
175
158
|
return Binh;
|
|
176
159
|
};
|
|
177
160
|
|
|
178
|
-
Binh.
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
161
|
+
Binh.webModuleLazy = function({ source, module, web }) {
|
|
162
|
+
var { source, module, web } = processWebBuildPaths({ source, module, web });
|
|
163
|
+
ComponentBuild.lazyload({ source, module, web });
|
|
164
|
+
return Binh;
|
|
165
|
+
};
|
|
182
166
|
|
|
183
|
-
|
|
167
|
+
Binh.webBundle = function({ source, module, web }) {
|
|
168
|
+
var absolutePaths = processWebBuildPaths({ source, module, web });
|
|
169
|
+
return Binh.webModule({ source, module }, () => ComponentBuild.bundle(absolutePaths));
|
|
170
|
+
};
|
|
184
171
|
|
|
185
|
-
|
|
172
|
+
Binh.webLazy = function({ source, module, web }) {
|
|
173
|
+
var absolutePaths = processWebBuildPaths({ source, module, web });
|
|
174
|
+
return Binh.webModule({ source, module }, () => ComponentBuild.lazyload(absolutePaths));
|
|
186
175
|
};
|
|
187
176
|
|
|
188
|
-
|
|
189
|
-
webPath = isString(webPath) ? webPath : 'web/app';
|
|
190
|
-
modulePath = isString(modulePath) ? modulePath : 'web/modules';
|
|
177
|
+
Binh.web = Binh.webBundle;
|
|
191
178
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
modulePathAbsolute = path.join(rootpath, modulePath);
|
|
179
|
+
function getAbsolutePath(relativePath) {
|
|
180
|
+
return isString(relativePath) ? path.join(Binh.getRootpath(), relativePath) : null;
|
|
181
|
+
}
|
|
196
182
|
|
|
183
|
+
function getAbsolutePaths({ source, module, web }) {
|
|
197
184
|
return {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
185
|
+
source: getAbsolutePath(source),
|
|
186
|
+
module: getAbsolutePath(module),
|
|
187
|
+
web: getAbsolutePath(web)
|
|
201
188
|
};
|
|
202
189
|
}
|
|
203
190
|
|
|
191
|
+
function processWebBuildPaths({ source, module, web }) {
|
|
192
|
+
if (!(isString(source) && isString(module) && isString(web))) {
|
|
193
|
+
throw new Error(`[BINHEND][WEB-BUILDER] Require paths for source, module and web. Current: { source: ${source}, module: ${module}, web: ${web} }`);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
var absolutePaths = getAbsolutePaths({ source, module, web });
|
|
197
|
+
|
|
198
|
+
Binh.web.value = absolutePaths.web;
|
|
199
|
+
|
|
200
|
+
return absolutePaths;
|
|
201
|
+
}
|
|
202
|
+
|
|
204
203
|
function isString(input) {
|
|
205
204
|
return typeof input === 'string';
|
|
206
205
|
}
|
package/src/code.js
CHANGED
|
@@ -143,6 +143,20 @@ function getRelativeFilePath(filePath, rootPath) {
|
|
|
143
143
|
getRelativeFilePath.cache = {};
|
|
144
144
|
|
|
145
145
|
function bundle(component, rootPath) {
|
|
146
|
+
var codes = getComponentBaseCodes(component, rootPath);
|
|
147
|
+
|
|
148
|
+
var codeOfDependencies = getCodeOfDependencies(component, rootPath);
|
|
149
|
+
if (codeOfDependencies) codes.push(codeOfDependencies);
|
|
150
|
+
|
|
151
|
+
return codes.join('\r\n');
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function lazyload(component, rootPath) {
|
|
155
|
+
var codes = getComponentBaseCodes(component, rootPath);
|
|
156
|
+
return codes.join('\r\n');
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function getComponentBaseCodes(component, rootPath) {
|
|
146
160
|
var dependencyDelaration = getDependencyDelaration(component, rootPath);
|
|
147
161
|
var optionCode = generateOptionCode(component, '', rootPath);
|
|
148
162
|
var componentCode = component.toString();
|
|
@@ -154,14 +168,12 @@ function bundle(component, rootPath) {
|
|
|
154
168
|
var codes = [];
|
|
155
169
|
|
|
156
170
|
if (componentCode) {
|
|
157
|
-
|
|
171
|
+
var url = getRelativeFilePath(component.filename, rootPath);
|
|
172
|
+
codes.push(`Binh.${component.type}('${url}', ${component.type})${optionCode};`);
|
|
158
173
|
codes.push(`${componentCode}\r\n`);
|
|
159
174
|
}
|
|
160
|
-
|
|
161
|
-
var codeOfDependencies = getCodeOfDependencies(component, rootPath);
|
|
162
|
-
if (codeOfDependencies) codes.push(codeOfDependencies);
|
|
163
175
|
|
|
164
|
-
return codes
|
|
176
|
+
return codes;
|
|
165
177
|
}
|
|
166
178
|
|
|
167
179
|
function getHtmlTagDeclaration(component) {
|
|
@@ -172,40 +184,54 @@ function getHtmlTagDeclaration(component) {
|
|
|
172
184
|
return `var {${variablesList}} = Binh.els;\r\n`;
|
|
173
185
|
}
|
|
174
186
|
|
|
175
|
-
function
|
|
176
|
-
var
|
|
187
|
+
function processElementTags(tags) {
|
|
188
|
+
var
|
|
189
|
+
variables = tags.join(','),
|
|
190
|
+
tagnames = tags.map((tag) => JSON.stringify(tag)).join(',');
|
|
177
191
|
|
|
192
|
+
return [variables, tagnames];
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function htmlTags(tags) {
|
|
178
196
|
if (!tags.length) return '';
|
|
179
|
-
|
|
180
|
-
var variablesList = tags.join(',');
|
|
181
|
-
tags = tags.map((tag) => JSON.stringify(tag));
|
|
182
197
|
|
|
198
|
+
var [variables, tagnames] = processElementTags(tags);
|
|
199
|
+
|
|
183
200
|
return [
|
|
184
|
-
`Binh.els = Binh.element(${
|
|
185
|
-
''
|
|
186
|
-
`var {${variablesList}} = Binh.els;`,
|
|
187
|
-
''
|
|
201
|
+
`Binh.els = Binh.element(${tagnames});`, '',
|
|
202
|
+
`var {${variables}} = Binh.els;`, ''
|
|
188
203
|
]
|
|
189
204
|
.join(`\r\n`);
|
|
190
205
|
}
|
|
191
206
|
|
|
192
|
-
function
|
|
193
|
-
|
|
207
|
+
function bundleHtmlTags(component) {
|
|
208
|
+
return htmlTags(distinctValues(component, 'htmltags'));
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function lazyHtmlTags(component) {
|
|
212
|
+
return htmlTags(component.htmltags);
|
|
213
|
+
}
|
|
194
214
|
|
|
215
|
+
function svgTags(tags) {
|
|
195
216
|
if (!tags.length) return '';
|
|
196
|
-
|
|
197
|
-
var
|
|
198
|
-
tags = tags.map((tag) => JSON.stringify(tag));
|
|
217
|
+
|
|
218
|
+
var [variables, tagnames] = processElementTags(tags);
|
|
199
219
|
|
|
200
220
|
return [
|
|
201
|
-
`Binh.SVGs = Binh.svgs(${
|
|
202
|
-
''
|
|
203
|
-
`var {${variablesList}} = Binh.SVGs;`,
|
|
204
|
-
''
|
|
221
|
+
`Binh.SVGs = Binh.svgs(${tagnames});`, '',
|
|
222
|
+
`var {${variables}} = Binh.SVGs;`, ''
|
|
205
223
|
]
|
|
206
224
|
.join(`\r\n`);
|
|
207
225
|
}
|
|
208
226
|
|
|
227
|
+
function bundleSvgTags(component) {
|
|
228
|
+
return svgTags(distinctValues(component, 'svgtags'));
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function lazySvgTags(component) {
|
|
232
|
+
return svgTags(component.svgtags);
|
|
233
|
+
}
|
|
234
|
+
|
|
209
235
|
function prequire(component, codes) {
|
|
210
236
|
var code = '', links = distinctValues(component, 'links');
|
|
211
237
|
|
|
@@ -264,9 +290,9 @@ function uniquefy(arrays) {
|
|
|
264
290
|
}
|
|
265
291
|
|
|
266
292
|
module.exports = {
|
|
267
|
-
bundle,
|
|
268
|
-
|
|
269
|
-
|
|
293
|
+
bundle, lazyload,
|
|
294
|
+
bundleHtmlTags, lazyHtmlTags,
|
|
295
|
+
bundleSvgTags, lazySvgTags,
|
|
270
296
|
prequire,
|
|
271
297
|
IIF
|
|
272
298
|
};
|
package/src/component.build.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
|
|
2
2
|
const { parse } = require('path');
|
|
3
|
-
const { scanNestedFiles,
|
|
3
|
+
const { scanNestedFiles, cloneFileIfNew, writeToFileIfNew, makeFullDirPath } = require('./component.file');
|
|
4
4
|
const CodeFormat = require('./code');
|
|
5
5
|
const Component = require('./component');
|
|
6
6
|
const UglifyJS = require('uglify-js');
|
|
7
7
|
const BeautifyJS = require('js-beautify/js');
|
|
8
8
|
|
|
9
|
-
function
|
|
9
|
+
function processEachFile({ source: sourceRootPath, web: outputRootPath, module: stageRootPath }, buildCodeMethod) {
|
|
10
10
|
if (sourceRootPath == undefined || outputRootPath == undefined) return;
|
|
11
11
|
stageRootPath = stageRootPath || outputRootPath;
|
|
12
12
|
console.info('[BINHEND][COMPONENT] Build web components from:', stageRootPath);
|
|
@@ -19,39 +19,62 @@ function generate(sourceRootPath, outputRootPath, stageRootPath) {
|
|
|
19
19
|
makeFullDirPath(fileOutputPath);
|
|
20
20
|
|
|
21
21
|
if (parse(file.name).ext !== '.js') {
|
|
22
|
-
return
|
|
22
|
+
return cloneFileIfNew(fileSourcePath, fileOutputPath);
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
try {
|
|
26
26
|
var component = require(file.path);
|
|
27
27
|
}
|
|
28
28
|
catch (error) {
|
|
29
|
-
return
|
|
29
|
+
return cloneFileIfNew(fileSourcePath, fileOutputPath);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
if (!(component instanceof Function) || component.constructor !== Component) {
|
|
33
|
-
return
|
|
33
|
+
return cloneFileIfNew(fileSourcePath, fileOutputPath);
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
var code =
|
|
37
|
-
|
|
36
|
+
var code = buildCodeMethod(component, stageRootPath);
|
|
38
37
|
code = Component.minification ? minifyCode(code) : beautifyCode(code);
|
|
39
38
|
|
|
40
|
-
|
|
39
|
+
writeToFileIfNew(fileOutputPath, code);
|
|
41
40
|
});
|
|
42
41
|
}
|
|
43
42
|
|
|
44
|
-
function
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
CodeFormat.
|
|
48
|
-
CodeFormat.
|
|
49
|
-
|
|
43
|
+
function buildBundleCode(component, rootPath, shouldBundle = true) {
|
|
44
|
+
return wrapCode(component, [
|
|
45
|
+
CodeFormat.bundleHtmlTags(component),
|
|
46
|
+
CodeFormat.bundleSvgTags(component),
|
|
47
|
+
CodeFormat.bundle(component, rootPath, shouldBundle)
|
|
48
|
+
]);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function generate({ source, web, module }) {
|
|
52
|
+
processEachFile({ source, web, module }, buildBundleCode);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function bundle({ source, web, module }) {
|
|
56
|
+
generate({ source, web, module });
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function lazyload({ source, web, module }) {
|
|
60
|
+
processEachFile({ source, web, module }, buildLazyCode);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function buildLazyCode(component, rootPath) {
|
|
64
|
+
return wrapCode(component, [
|
|
65
|
+
CodeFormat.lazyHtmlTags(component),
|
|
66
|
+
CodeFormat.lazySvgTags(component),
|
|
67
|
+
CodeFormat.lazyload(component, rootPath)
|
|
50
68
|
]);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function wrapCode(component, inputCodes) {
|
|
72
|
+
var stackOfCodes = [`var _Binh = Binh;\r\n`];
|
|
73
|
+
stackOfCodes.push.apply(stackOfCodes, inputCodes);
|
|
51
74
|
|
|
52
75
|
return CodeFormat.IIF([
|
|
53
76
|
`var Binh = window.Binh;`,
|
|
54
|
-
|
|
77
|
+
CodeFormat.prequire(component, stackOfCodes)
|
|
55
78
|
]);
|
|
56
79
|
}
|
|
57
80
|
|
|
@@ -66,5 +89,5 @@ function beautifyCode(code) {
|
|
|
66
89
|
}
|
|
67
90
|
|
|
68
91
|
module.exports = {
|
|
69
|
-
generate
|
|
92
|
+
generate, bundle, lazyload
|
|
70
93
|
};
|
package/src/component.file.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
|
|
2
|
-
const { readdir, statSync, existsSync, copyFile, writeFile, mkdirSync } = require('fs');
|
|
2
|
+
const { readdir, statSync, existsSync, copyFile, writeFile, writeFileSync, readFileSync, mkdirSync } = require('fs');
|
|
3
3
|
const { join, dirname } = require('path');
|
|
4
4
|
|
|
5
|
-
// TODO
|
|
6
|
-
// [-] Enhance code by removing sync logics (except for existsSync, mkdirSync): readdir, readFileSync, (statSync?)
|
|
7
|
-
|
|
8
5
|
function getItemInfo(itemPath) {
|
|
9
6
|
var info = {};
|
|
10
7
|
|
|
@@ -91,6 +88,22 @@ function cloneFile(filepath, outpath) {
|
|
|
91
88
|
});
|
|
92
89
|
}
|
|
93
90
|
|
|
91
|
+
function cloneFileIfNew(filepath, outpath) {
|
|
92
|
+
if (isSameFile(filepath, outpath)) return;
|
|
93
|
+
cloneFile(filepath, outpath);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function isSameFile(filePathA, filePathB) {
|
|
97
|
+
var sameFile = false;
|
|
98
|
+
|
|
99
|
+
if (existsSync(filePathA) && existsSync(filePathB)) {
|
|
100
|
+
var fileA = readFileSync(filePathA), fileB = readFileSync(filePathB);
|
|
101
|
+
sameFile = fileA.equals(fileB);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return sameFile;
|
|
105
|
+
}
|
|
106
|
+
|
|
94
107
|
function makeFullDirPath(filePath) {
|
|
95
108
|
var dirPath = dirname(filePath);
|
|
96
109
|
if (existsSync(dirPath)) return true;
|
|
@@ -106,6 +119,29 @@ function writeToFile(fileOutputPath, content) {
|
|
|
106
119
|
});
|
|
107
120
|
}
|
|
108
121
|
|
|
122
|
+
function writeToFileIfNew(fileOutputPath, content) {
|
|
123
|
+
try {
|
|
124
|
+
if (isSameContent(fileOutputPath, content)) return false;
|
|
125
|
+
writeFileSync(fileOutputPath, content, { encoding: 'utf8', flag: 'w' });
|
|
126
|
+
return true;
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
printError('Failed writing file', fileOutputPath, error);
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function isSameContent(filePath, content) {
|
|
135
|
+
var sameContent = false;
|
|
136
|
+
|
|
137
|
+
if (existsSync(filePath)) {
|
|
138
|
+
var current = readFileSync(filePath, { encoding: 'utf8', flag: 'r' });
|
|
139
|
+
sameContent = content === current;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return sameContent;
|
|
143
|
+
}
|
|
144
|
+
|
|
109
145
|
function printError(message, id, error) {
|
|
110
146
|
console.error(`[BINHEND][COMPONENT] ${message}:`, id);
|
|
111
147
|
console.error('[BINHEND][COMPONENT] Error details:', error);
|
|
@@ -117,7 +153,10 @@ module.exports = {
|
|
|
117
153
|
scanFiles,
|
|
118
154
|
scanNestedFiles,
|
|
119
155
|
cloneFile,
|
|
156
|
+
cloneFileIfNew,
|
|
120
157
|
makeFullDirPath,
|
|
121
158
|
writeToFile,
|
|
159
|
+
writeToFileIfNew,
|
|
160
|
+
isSameContent,
|
|
122
161
|
printError
|
|
123
162
|
};
|
package/src/component.format.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
|
|
2
|
-
const {
|
|
2
|
+
const { readFileSync } = require('fs');
|
|
3
3
|
const { parse } = require('path');
|
|
4
|
-
const { scanNestedFiles,
|
|
5
|
-
|
|
6
|
-
// TODO
|
|
7
|
-
// [-] Enhance code by removing sync logics (except for existsSync, mkdirSync): readdir, readFileSync, (statSync?)
|
|
4
|
+
const { scanNestedFiles, cloneFileIfNew, printError, makeFullDirPath, writeToFileIfNew } = require('./component.file');
|
|
8
5
|
|
|
9
6
|
const PREFIX_CODE =
|
|
10
7
|
`var { context, tag, svg, script, require, css } = binh.context(module, require);
|
|
@@ -29,16 +26,17 @@ function generate(sourceRootPath, outputRootPath, callbackDone) {
|
|
|
29
26
|
|
|
30
27
|
if (fileExtension === '.css') {
|
|
31
28
|
var cssModuleCode = 'binh.css(module);';
|
|
32
|
-
|
|
29
|
+
writeToFileIfNew(fileOutputPath + '.js', cssModuleCode);
|
|
33
30
|
}
|
|
34
31
|
|
|
35
32
|
if (fileExtension !== '.js') {
|
|
36
|
-
return
|
|
33
|
+
return cloneFileIfNew(fileSourcePath, fileOutputPath);
|
|
37
34
|
}
|
|
38
35
|
|
|
39
36
|
var content = readFileSync(fileSourcePath, { encoding: 'utf8', flag: 'r' });
|
|
40
37
|
var code = PREFIX_CODE + content.trim() + '\r\n\r\n;binh.final(module);';
|
|
41
|
-
|
|
38
|
+
|
|
39
|
+
writeToFileIfNew(fileOutputPath, code);
|
|
42
40
|
}
|
|
43
41
|
catch (error) {
|
|
44
42
|
printError('Failed formatting file:', fileSourcePath, error);
|
package/test.js
CHANGED
|
@@ -1,22 +1,48 @@
|
|
|
1
|
+
// const path = require('path');
|
|
2
|
+
|
|
3
|
+
// function parseFilePathToVariableName(filePath) {
|
|
4
|
+
// return path.parse(filePath).name.replace(/-/g, '').replace(/\W.*/, '');
|
|
5
|
+
// // try {
|
|
6
|
+
// // }
|
|
7
|
+
// // catch (error) {
|
|
8
|
+
// // return '';
|
|
9
|
+
// // }
|
|
10
|
+
// };
|
|
11
|
+
|
|
12
|
+
// // console.log(parseFilePathToVariableName(1));
|
|
13
|
+
// console.log(parseFilePathToVariableName(''));
|
|
14
|
+
// // console.log(parseFilePathToVariableName(null));
|
|
15
|
+
// // console.log(parseFilePathToVariableName());
|
|
16
|
+
// // console.log(parseFilePathToVariableName('abc.js'));
|
|
17
|
+
// // console.log(parseFilePathToVariableName('abc,.js'));
|
|
18
|
+
// // console.log(parseFilePathToVariableName('abc.css.js'));
|
|
19
|
+
// // console.log(parseFilePathToVariableName('./uhm/abc.css.js'));
|
|
20
|
+
// console.log(parseFilePathToVariableName('.css.js'));
|
|
21
|
+
|
|
22
|
+
// var abc = function ab() { return 123; };
|
|
23
|
+
// var cc = () => {};
|
|
24
|
+
|
|
25
|
+
// !function(callback1, callback2) {
|
|
26
|
+
// delete callback1.name;
|
|
27
|
+
// console.log(callback1.toString());
|
|
28
|
+
// console.log(callback2.toString());
|
|
29
|
+
// }(abc, cc);
|
|
30
|
+
|
|
31
|
+
// console.log(abc.toString());
|
|
32
|
+
// console.log(cc.toString());
|
|
33
|
+
|
|
1
34
|
const path = require('path');
|
|
2
35
|
|
|
36
|
+
// console.log(__dirname);
|
|
37
|
+
// console.log(path.join(__dirname, null));
|
|
38
|
+
|
|
39
|
+
function abc({ a, b, c }) {
|
|
40
|
+
console.log(path.join(__dirname, a));
|
|
41
|
+
console.log(path.join(__dirname, b));
|
|
42
|
+
console.log(path.join(__dirname, c));
|
|
43
|
+
}
|
|
3
44
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
// catch (error) {
|
|
9
|
-
// return '';
|
|
10
|
-
// }
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
// console.log(parseFilePathToVariableName(1));
|
|
15
|
-
console.log(parseFilePathToVariableName(''));
|
|
16
|
-
// console.log(parseFilePathToVariableName(null));
|
|
17
|
-
// console.log(parseFilePathToVariableName());
|
|
18
|
-
// console.log(parseFilePathToVariableName('abc.js'));
|
|
19
|
-
// console.log(parseFilePathToVariableName('abc,.js'));
|
|
20
|
-
// console.log(parseFilePathToVariableName('abc.css.js'));
|
|
21
|
-
// console.log(parseFilePathToVariableName('./uhm/abc.css.js'));
|
|
22
|
-
console.log(parseFilePathToVariableName('.css.js'));
|
|
45
|
+
abc({
|
|
46
|
+
a: 'a',
|
|
47
|
+
b: 'b'
|
|
48
|
+
});
|