mirror of
https://github.com/ritz078/transform.git
synced 2026-11-25 18:23:47 +03:00
added accordion for navigation
This commit is contained in:
1 parent
e7aec70db1
commit
88bfa7ab01
12 files changed
+462
-235
No files matched your search
@@ -16,10 +16,7 @@ export default function({ types: t }) {
|
||||
if (t.isObjectExpression(uniqueElements[0])) {
|
||||
uniqueElements = [
|
||||
t.callExpression(
|
||||
t.memberExpression(
|
||||
t.identifier("t"),
|
||||
t.identifier("model")
|
||||
),
|
||||
t.memberExpression(t.identifier("t"), t.identifier("model")),
|
||||
uniqueElements
|
||||
)
|
||||
];
|
||||
@@ -31,10 +28,7 @@ export default function({ types: t }) {
|
||||
) {
|
||||
path.replaceWith(
|
||||
t.callExpression(
|
||||
t.memberExpression(
|
||||
t.identifier("t"),
|
||||
t.identifier("array")
|
||||
),
|
||||
t.memberExpression(t.identifier("t"), t.identifier("array")),
|
||||
uniqueElements
|
||||
)
|
||||
);
|
||||
@@ -76,26 +70,20 @@ export default function({ types: t }) {
|
||||
});
|
||||
},
|
||||
|
||||
ObjectProperty(path){
|
||||
if(t.isStringLiteral(path.node.key)){
|
||||
path.node.key = t.identifier(path.node.key.value)
|
||||
}
|
||||
ObjectProperty(path) {
|
||||
if (t.isStringLiteral(path.node.key)) {
|
||||
path.node.key = t.identifier(path.node.key.value);
|
||||
}
|
||||
},
|
||||
|
||||
ObjectExpression(path) {
|
||||
if (
|
||||
t.isCallExpression(path.parent)
|
||||
)
|
||||
return;
|
||||
if (t.isCallExpression(path.parent)) return;
|
||||
|
||||
const elements = [path.node];
|
||||
|
||||
path.replaceWith(
|
||||
t.callExpression(
|
||||
t.memberExpression(
|
||||
t.identifier("t"),
|
||||
t.identifier("model")
|
||||
),
|
||||
t.memberExpression(t.identifier("t"), t.identifier("model")),
|
||||
elements
|
||||
)
|
||||
);
|
||||
|
||||
@@ -16,6 +16,6 @@ const y = `{
|
||||
"index": true,
|
||||
"required": true
|
||||
}
|
||||
}`
|
||||
}`;
|
||||
|
||||
export default y
|
||||
export default y;
|
||||
@@ -21,11 +21,15 @@ var is;
|
||||
}
|
||||
is.string = string;
|
||||
function number(n) {
|
||||
return (typeof n === "number" || n instanceof Number) && !Number.isInteger(n)
|
||||
return (
|
||||
(typeof n === "number" || n instanceof Number) && !Number.isInteger(n)
|
||||
);
|
||||
}
|
||||
is.number = number;
|
||||
function integer(n) {
|
||||
return (typeof n === "number" || n instanceof Number) && Number.isInteger(n)
|
||||
return (
|
||||
(typeof n === "number" || n instanceof Number) && Number.isInteger(n)
|
||||
);
|
||||
}
|
||||
is.integer = integer;
|
||||
function boolean(b) {
|
||||
@@ -277,7 +281,7 @@ var Types = (function() {
|
||||
function Types() {}
|
||||
Types.STRING = "String";
|
||||
Types.NUMBER = "f64";
|
||||
Types.INTEGER = "i64"
|
||||
Types.INTEGER = "i64";
|
||||
Types.BOOLEAN = "boolean";
|
||||
Types.ARRAY = "[]";
|
||||
return Types;
|
||||
@@ -327,9 +331,14 @@ var Json2dts = (function() {
|
||||
var interfaceTab = outputModule ? " " : "";
|
||||
var propertyTab = interfaceTab + " ";
|
||||
Object.keys(this.classes).map(function(clsName) {
|
||||
output = interfaceTab + "#[derive(Serialize, Deserialize)]\nstruct " + clsName + " {\n";
|
||||
output =
|
||||
interfaceTab +
|
||||
"#[derive(Serialize, Deserialize)]\nstruct " +
|
||||
clsName +
|
||||
" {\n";
|
||||
Object.keys(_this.classes[clsName]).map(function(key) {
|
||||
output += propertyTab + key + ": " + _this.classes[clsName][key] + ",\n";
|
||||
output +=
|
||||
propertyTab + key + ": " + _this.classes[clsName][key] + ",\n";
|
||||
});
|
||||
output += interfaceTab + "}\n\n";
|
||||
classes[clsName] = output;
|
||||
@@ -372,7 +381,8 @@ var Json2dts = (function() {
|
||||
type = "Vec<()>";
|
||||
} else {
|
||||
if (is.object(value[0])) {
|
||||
type = "Vec<" + _this.getInterfaceType(key, value[0]).trim() + ">";
|
||||
type =
|
||||
"Vec<" + _this.getInterfaceType(key, value[0]).trim() + ">";
|
||||
_this.analyse_object(value[0], key);
|
||||
} else {
|
||||
type = "Vec<" + _this.getBasicType(value[0]) + ">";
|
||||
|
||||
@@ -326,7 +326,12 @@ var Json2dts = (function() {
|
||||
? interfaceTab + "type " + clsName + " = \n" + interfaceTab + "{\n"
|
||||
: interfaceTab + "interface " + clsName + " \n" + interfaceTab + "{\n";
|
||||
Object.keys(_this.classes[clsName]).map(function(key) {
|
||||
output += propertyTab + key + ":" + _this.classes[clsName][key] + (flow ? ",\n" : ";\n");
|
||||
output +=
|
||||
propertyTab +
|
||||
key +
|
||||
":" +
|
||||
_this.classes[clsName][key] +
|
||||
(flow ? ",\n" : ";\n");
|
||||
});
|
||||
output += interfaceTab + (flow ? "};\n\n" : "}\n\n");
|
||||
classes[clsName] = output;
|
||||
|
||||
Reference in new issue
Block a user