Skip to content

Commit

Permalink
removed lodash
Browse files Browse the repository at this point in the history
  • Loading branch information
Qwin committed Mar 21, 2019
1 parent ba53616 commit 8db92d4
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 40 deletions.
3 changes: 0 additions & 3 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
const typeScriptCodeGenerator = require("./typeScriptCodeGenerator")

function _handleGen(base, path, options) {
console.log('this is a test');


// window.alert('Hello World!');
// If options is not passed, get from preference
options = options || getGenOptions()
Expand Down
15 changes: 3 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 14 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,26 @@
"description": "TypeScript code generation",
"homepage": "https://github.com/qwin/staruml-typescript",
"issues": "https://github.com/qwin/staruml-typescript/issues",
"repository": {
"type": "git",
"url": "https://github.com/qwin/staruml-typescript.git"
},
"version": "0.2.0",
"keywords": ["TypeScript", "ts", "UML", "staruml"],
"keywords": [
"TypeScript",
"ts",
"UML",
"staruml"
],
"author": {
"name": "Robert Al Malak",
"email": "[email protected]",
"url": "https://github.com/qwin"
},
"license": "GPLv3",
"license": "GPL-3.0",
"engines": {
"staruml": ">=3.0.0"
},
"devDependencies": {
"lodash": "^4.17.11"
}
}
"devDependencies": {},
"dependencies": {}
}
34 changes: 15 additions & 19 deletions typeScriptCodeGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
const CodeWriter = require("./CodeGenUtils")
var path = require('path');
var fs = require('fs');
var _ = require('lodash');


class TypeScriptCodeGenerator {
/**
Expand Down Expand Up @@ -147,7 +145,7 @@ class TypeScriptCodeGenerator {
writeNamespace(writeFunction, codeWriter, elem, options) {
var path = null;
if (elem._parent) {
path = _.map(elem._parent.getPath(this.baseModel), function (e) {
path = elem._parent.getPath(this.baseModel).map(function (e) {
return e.name;
}).join(".");
}
Expand Down Expand Up @@ -228,9 +226,7 @@ class TypeScriptCodeGenerator {
// Extends
var _extends = this.getSuperClasses(elem);
if (_extends.length > 0) {
terms.push("extends " + _.map(_extends, function (e) {
return e.name;
}).join(", "));
terms.push("extends " + _extends.map(function (e) { return e.name }).join(', '))
}
codeWriter.writeLine(terms.join(" ") + " {");
codeWriter.writeLine();
Expand Down Expand Up @@ -306,7 +302,7 @@ class TypeScriptCodeGenerator {

// Modifiers
var _modifiers = this.getModifiers(elem);
if (_.some(elem.operations, function (op) {
if (elem.operations.some(function (op) {
return op.isAbstract === true;
})) {
_modifiers.push("abstract");
Expand All @@ -333,11 +329,11 @@ class TypeScriptCodeGenerator {
var _implements = this.getSuperInterfaces(elem);
if (_implements.length > 0) {
if (_extends.length > 0) {
terms.push(", " + _.map(_implements, function (e) {
terms.push(", " + _implements.map(function (e) {
return e.name;
}).join(", "));
} else {
terms.push("implements " + _.map(_implements, function (e) {
terms.push("implements " + _implements.map(function (e) {
return e.name;
}).join(", "));
}
Expand Down Expand Up @@ -428,7 +424,7 @@ class TypeScriptCodeGenerator {

// Modifiers
// var _modifiers = this.getModifiers(elem);
// if (_.some(elem.operations, function(op) {
// if (elem.operations.some(function(op) {
// return op.isAbstract === true;
// })) {
// _modifiers.push("abstract");
Expand All @@ -451,11 +447,11 @@ class TypeScriptCodeGenerator {
var _implements = this.getSuperInterfaces(elem);
if (_implements.length > 0) {
if (_extends.length > 0) {
terms.push(", " + _.map(_implements, function (e) {
terms.push(", " + _implements.map(function (e) {
return e.name;
}).join(", "));
} else {
terms.push("implements " + _.map(_implements, function (e) {
terms.push("implements " + _implements.map(function (e) {
return e.name;
}).join(", "));
}
Expand Down Expand Up @@ -541,7 +537,7 @@ class TypeScriptCodeGenerator {

// doc
var doc = elem.documentation.trim();
_.each(params, function (param) {
params.forEach(function (param) {
doc += "\n@param " + param.name + " " + param.documentation;
});
if (returnParam) {
Expand Down Expand Up @@ -581,7 +577,7 @@ class TypeScriptCodeGenerator {
}

// body
if (skipBody === true || _.contains(_modifiers, "abstract")) {
if (skipBody === true || _modifiers.includes("abstract")) {
codeWriter.writeLine(terms.join(" ") + ";");
} else {
codeWriter.writeLine(terms.join(" ") + " {");
Expand Down Expand Up @@ -640,15 +636,15 @@ class TypeScriptCodeGenerator {
} else {
if (elem.type instanceof type.UMLModelElement && elem.type.name.length > 0) {
_type = elem.type.name;
} else if (_.isString(elem.type) && elem.type.length > 0) {
} else if ((typeof elem.type === 'string') && elem.type.length > 0) {
_type = elem.type;
}
}


// multiplicity
if (elem.multiplicity) {
if (_.contains(["0..*", "1..*", "*"], elem.multiplicity.trim())) {
if (["0..*", "1..*", "*"].includes(elem.multiplicity.trim())) {
if (elem.isOrdered === true) {
_type = "List<" + _type + ">";
} else {
Expand Down Expand Up @@ -731,7 +727,7 @@ class TypeScriptCodeGenerator {
*/
writeDoc(codeWriter, text, options) {
var i, len, lines;
if (options.tsDoc && _.isString(text)) {
if (options.tsDoc && (typeof text === 'string')) {
console.log("write Doc");
lines = text.trim().split("\n");
codeWriter.writeLine("/**");
Expand Down Expand Up @@ -800,7 +796,7 @@ class TypeScriptCodeGenerator {
var generalizations = app.repository.getRelationshipsOf(elem, function (rel) {
return (rel instanceof type.UMLGeneralization && rel.source === elem);
});
return _.map(generalizations, function (gen) {
return generalizations.map(function (gen) {
return gen.target;
});
};
Expand All @@ -814,7 +810,7 @@ class TypeScriptCodeGenerator {
var realizations = app.repository.getRelationshipsOf(elem, function (rel) {
return (rel instanceof type.UMLInterfaceRealization && rel.source === elem);
});
return _.map(realizations, function (gen) {
return realizations.map(function (gen) {
return gen.target;
});
};
Expand Down

0 comments on commit 8db92d4

Please sign in to comment.