@teleporthq/teleport-plugin-common
Advanced tools
Comparing version
@@ -60,4 +60,4 @@ import * as types from '@babel/types'; | ||
export declare const generateMemberExpressionASTFromBase: (base: types.MemberExpression | types.Identifier, path: string[]) => types.MemberExpression; | ||
export declare const generateMemberExpressionASTFromPath: (path: string[]) => types.MemberExpression | types.Identifier; | ||
export declare const generateMemberExpressionASTFromPath: (path: Array<string | number>) => types.MemberExpression | types.Identifier; | ||
export {}; | ||
//# sourceMappingURL=ast-utils.d.ts.map |
@@ -485,6 +485,11 @@ "use strict"; | ||
if (path.length === 1) { | ||
return types.identifier(path[0]); | ||
return types.identifier(path[0].toString()); | ||
} | ||
pathClone.pop(); | ||
return types.memberExpression((0, exports.generateMemberExpressionASTFromPath)(pathClone), types.identifier(path[path.length - 1]), false); | ||
var currentPath = path[path.length - 1]; | ||
if (typeof currentPath === 'number') { | ||
return types.memberExpression((0, exports.generateMemberExpressionASTFromPath)(pathClone), types.numericLiteral(currentPath), true); | ||
} | ||
var containsSpecial = currentPath.indexOf('.') !== -1 || currentPath.indexOf('-') !== -1; | ||
return types.memberExpression((0, exports.generateMemberExpressionASTFromPath)(pathClone), containsSpecial ? types.stringLiteral(currentPath) : types.identifier(currentPath), containsSpecial); | ||
}; | ||
@@ -491,0 +496,0 @@ exports.generateMemberExpressionASTFromPath = generateMemberExpressionASTFromPath; |
@@ -60,4 +60,4 @@ import * as types from '@babel/types'; | ||
export declare const generateMemberExpressionASTFromBase: (base: types.MemberExpression | types.Identifier, path: string[]) => types.MemberExpression; | ||
export declare const generateMemberExpressionASTFromPath: (path: string[]) => types.MemberExpression | types.Identifier; | ||
export declare const generateMemberExpressionASTFromPath: (path: Array<string | number>) => types.MemberExpression | types.Identifier; | ||
export {}; | ||
//# sourceMappingURL=ast-utils.d.ts.map |
@@ -430,6 +430,11 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { | ||
if (path.length === 1) { | ||
return types.identifier(path[0]); | ||
return types.identifier(path[0].toString()); | ||
} | ||
pathClone.pop(); | ||
return types.memberExpression(generateMemberExpressionASTFromPath(pathClone), types.identifier(path[path.length - 1]), false); | ||
var currentPath = path[path.length - 1]; | ||
if (typeof currentPath === 'number') { | ||
return types.memberExpression(generateMemberExpressionASTFromPath(pathClone), types.numericLiteral(currentPath), true); | ||
} | ||
var containsSpecial = currentPath.indexOf('.') !== -1 || currentPath.indexOf('-') !== -1; | ||
return types.memberExpression(generateMemberExpressionASTFromPath(pathClone), containsSpecial ? types.stringLiteral(currentPath) : types.identifier(currentPath), containsSpecial); | ||
}; | ||
@@ -436,0 +441,0 @@ var generateURLParamsAST = function (urlParams, propsPrefix, extraUrlParamsGenerator) { |
{ | ||
"name": "@teleporthq/teleport-plugin-common", | ||
"version": "0.27.3-alpha.2", | ||
"version": "0.27.3-alpha.3", | ||
"description": "Common building and modelating functions for ASTs and HASTs", | ||
@@ -28,8 +28,8 @@ "author": "teleportHQ", | ||
"@babel/types": "^7.5.5", | ||
"@teleporthq/teleport-shared": "^0.27.3-alpha.2", | ||
"@teleporthq/teleport-types": "^0.27.3-alpha.2", | ||
"@teleporthq/teleport-shared": "^0.27.3-alpha.3", | ||
"@teleporthq/teleport-types": "^0.27.3-alpha.3", | ||
"jss": "^10.0.0", | ||
"jss-preset-default": "^10.0.0" | ||
}, | ||
"gitHead": "1826e455b9c5c73c972391f96f740d7cd548134b" | ||
"gitHead": "776fa2beea05204929e2ef93ab70aa619fe7b0e3" | ||
} |
@@ -690,7 +690,7 @@ import * as types from '@babel/types' | ||
export const generateMemberExpressionASTFromPath = ( | ||
path: string[] | ||
path: Array<string | number> | ||
): types.MemberExpression | types.Identifier => { | ||
const pathClone = [...path] | ||
if (path.length === 1) { | ||
return types.identifier(path[0]) | ||
return types.identifier(path[0].toString()) | ||
} | ||
@@ -700,6 +700,17 @@ | ||
const currentPath = path[path.length - 1] | ||
if (typeof currentPath === 'number') { | ||
return types.memberExpression( | ||
generateMemberExpressionASTFromPath(pathClone), | ||
types.numericLiteral(currentPath), | ||
true | ||
) | ||
} | ||
const containsSpecial = currentPath.indexOf('.') !== -1 || currentPath.indexOf('-') !== -1 | ||
return types.memberExpression( | ||
generateMemberExpressionASTFromPath(pathClone), | ||
types.identifier(path[path.length - 1]), | ||
false | ||
containsSpecial ? types.stringLiteral(currentPath) : types.identifier(currentPath), | ||
containsSpecial | ||
) | ||
@@ -706,0 +717,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
570789
0.36%7716
0.25%