Skip to content

Commit 8db92d4

Browse files
committed
removed lodash
1 parent ba53616 commit 8db92d4

File tree

4 files changed

+32
-40
lines changed

4 files changed

+32
-40
lines changed

main.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
const typeScriptCodeGenerator = require("./typeScriptCodeGenerator")
22

33
function _handleGen(base, path, options) {
4-
console.log('this is a test');
5-
6-
74
// window.alert('Hello World!');
85
// If options is not passed, get from preference
96
options = options || getGenOptions()

package-lock.json

Lines changed: 3 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,26 @@
44
"description": "TypeScript code generation",
55
"homepage": "https://github.com/qwin/staruml-typescript",
66
"issues": "https://github.com/qwin/staruml-typescript/issues",
7+
"repository": {
8+
"type": "git",
9+
"url": "https://github.com/qwin/staruml-typescript.git"
10+
},
711
"version": "0.2.0",
8-
"keywords": ["TypeScript", "ts", "UML", "staruml"],
12+
"keywords": [
13+
"TypeScript",
14+
"ts",
15+
"UML",
16+
"staruml"
17+
],
918
"author": {
1019
"name": "Robert Al Malak",
1120
"email": "robertalmalak7@gmail.com",
1221
"url": "https://github.com/qwin"
1322
},
14-
"license": "GPLv3",
23+
"license": "GPL-3.0",
1524
"engines": {
1625
"staruml": ">=3.0.0"
1726
},
18-
"devDependencies": {
19-
"lodash": "^4.17.11"
20-
}
21-
}
27+
"devDependencies": {},
28+
"dependencies": {}
29+
}

typeScriptCodeGenerator.js

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
const CodeWriter = require("./CodeGenUtils")
66
var path = require('path');
77
var fs = require('fs');
8-
var _ = require('lodash');
9-
108

119
class TypeScriptCodeGenerator {
1210
/**
@@ -147,7 +145,7 @@ class TypeScriptCodeGenerator {
147145
writeNamespace(writeFunction, codeWriter, elem, options) {
148146
var path = null;
149147
if (elem._parent) {
150-
path = _.map(elem._parent.getPath(this.baseModel), function (e) {
148+
path = elem._parent.getPath(this.baseModel).map(function (e) {
151149
return e.name;
152150
}).join(".");
153151
}
@@ -228,9 +226,7 @@ class TypeScriptCodeGenerator {
228226
// Extends
229227
var _extends = this.getSuperClasses(elem);
230228
if (_extends.length > 0) {
231-
terms.push("extends " + _.map(_extends, function (e) {
232-
return e.name;
233-
}).join(", "));
229+
terms.push("extends " + _extends.map(function (e) { return e.name }).join(', '))
234230
}
235231
codeWriter.writeLine(terms.join(" ") + " {");
236232
codeWriter.writeLine();
@@ -306,7 +302,7 @@ class TypeScriptCodeGenerator {
306302

307303
// Modifiers
308304
var _modifiers = this.getModifiers(elem);
309-
if (_.some(elem.operations, function (op) {
305+
if (elem.operations.some(function (op) {
310306
return op.isAbstract === true;
311307
})) {
312308
_modifiers.push("abstract");
@@ -333,11 +329,11 @@ class TypeScriptCodeGenerator {
333329
var _implements = this.getSuperInterfaces(elem);
334330
if (_implements.length > 0) {
335331
if (_extends.length > 0) {
336-
terms.push(", " + _.map(_implements, function (e) {
332+
terms.push(", " + _implements.map(function (e) {
337333
return e.name;
338334
}).join(", "));
339335
} else {
340-
terms.push("implements " + _.map(_implements, function (e) {
336+
terms.push("implements " + _implements.map(function (e) {
341337
return e.name;
342338
}).join(", "));
343339
}
@@ -428,7 +424,7 @@ class TypeScriptCodeGenerator {
428424

429425
// Modifiers
430426
// var _modifiers = this.getModifiers(elem);
431-
// if (_.some(elem.operations, function(op) {
427+
// if (elem.operations.some(function(op) {
432428
// return op.isAbstract === true;
433429
// })) {
434430
// _modifiers.push("abstract");
@@ -451,11 +447,11 @@ class TypeScriptCodeGenerator {
451447
var _implements = this.getSuperInterfaces(elem);
452448
if (_implements.length > 0) {
453449
if (_extends.length > 0) {
454-
terms.push(", " + _.map(_implements, function (e) {
450+
terms.push(", " + _implements.map(function (e) {
455451
return e.name;
456452
}).join(", "));
457453
} else {
458-
terms.push("implements " + _.map(_implements, function (e) {
454+
terms.push("implements " + _implements.map(function (e) {
459455
return e.name;
460456
}).join(", "));
461457
}
@@ -541,7 +537,7 @@ class TypeScriptCodeGenerator {
541537

542538
// doc
543539
var doc = elem.documentation.trim();
544-
_.each(params, function (param) {
540+
params.forEach(function (param) {
545541
doc += "\n@param " + param.name + " " + param.documentation;
546542
});
547543
if (returnParam) {
@@ -581,7 +577,7 @@ class TypeScriptCodeGenerator {
581577
}
582578

583579
// body
584-
if (skipBody === true || _.contains(_modifiers, "abstract")) {
580+
if (skipBody === true || _modifiers.includes("abstract")) {
585581
codeWriter.writeLine(terms.join(" ") + ";");
586582
} else {
587583
codeWriter.writeLine(terms.join(" ") + " {");
@@ -640,15 +636,15 @@ class TypeScriptCodeGenerator {
640636
} else {
641637
if (elem.type instanceof type.UMLModelElement && elem.type.name.length > 0) {
642638
_type = elem.type.name;
643-
} else if (_.isString(elem.type) && elem.type.length > 0) {
639+
} else if ((typeof elem.type === 'string') && elem.type.length > 0) {
644640
_type = elem.type;
645641
}
646642
}
647643

648644

649645
// multiplicity
650646
if (elem.multiplicity) {
651-
if (_.contains(["0..*", "1..*", "*"], elem.multiplicity.trim())) {
647+
if (["0..*", "1..*", "*"].includes(elem.multiplicity.trim())) {
652648
if (elem.isOrdered === true) {
653649
_type = "List<" + _type + ">";
654650
} else {
@@ -731,7 +727,7 @@ class TypeScriptCodeGenerator {
731727
*/
732728
writeDoc(codeWriter, text, options) {
733729
var i, len, lines;
734-
if (options.tsDoc && _.isString(text)) {
730+
if (options.tsDoc && (typeof text === 'string')) {
735731
console.log("write Doc");
736732
lines = text.trim().split("\n");
737733
codeWriter.writeLine("/**");
@@ -800,7 +796,7 @@ class TypeScriptCodeGenerator {
800796
var generalizations = app.repository.getRelationshipsOf(elem, function (rel) {
801797
return (rel instanceof type.UMLGeneralization && rel.source === elem);
802798
});
803-
return _.map(generalizations, function (gen) {
799+
return generalizations.map(function (gen) {
804800
return gen.target;
805801
});
806802
};
@@ -814,7 +810,7 @@ class TypeScriptCodeGenerator {
814810
var realizations = app.repository.getRelationshipsOf(elem, function (rel) {
815811
return (rel instanceof type.UMLInterfaceRealization && rel.source === elem);
816812
});
817-
return _.map(realizations, function (gen) {
813+
return realizations.map(function (gen) {
818814
return gen.target;
819815
});
820816
};

0 commit comments

Comments
 (0)