@kezh/my-custom-js-converter 0.0.18 → 0.0.19
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/core/encode.js +21 -7
- package/package.json +1 -1
package/core/encode.js
CHANGED
|
@@ -244,13 +244,27 @@ function getSrcMethodNames(entry, srcAst) {
|
|
|
244
244
|
function getMethods(entry, ast) {
|
|
245
245
|
const methods = [];
|
|
246
246
|
(0, traverse_1.default)(ast, {
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
247
|
+
Program(path) {
|
|
248
|
+
path.node.body.forEach((statement) => {
|
|
249
|
+
if (core_1.types.isVariableDeclaration(statement)) {
|
|
250
|
+
const variableDeclaration = statement;
|
|
251
|
+
variableDeclaration.declarations.filter((declaration) => {
|
|
252
|
+
if (core_1.types.isIdentifier(declaration.id)) {
|
|
253
|
+
const id = declaration.id;
|
|
254
|
+
if (id.name === entry) {
|
|
255
|
+
return true;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
return false;
|
|
259
|
+
}).forEach((declaration) => {
|
|
260
|
+
if (core_1.types.isObjectExpression(declaration.init)) {
|
|
261
|
+
const init = declaration.init;
|
|
262
|
+
const objectMethods = init.properties.filter(property => core_1.types.isObjectMethod(property));
|
|
263
|
+
methods.push(...objectMethods);
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
});
|
|
254
268
|
}
|
|
255
269
|
});
|
|
256
270
|
return methods;
|