From 421b11f2ffa787bad266990c742354ca635c4ba8 Mon Sep 17 00:00:00 2001 From: niklaus Date: Thu, 24 May 2018 12:04:12 +0900 Subject: [PATCH] Remove lodash --- code-generator.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/code-generator.js b/code-generator.js index a061933..6ec4c21 100644 --- a/code-generator.js +++ b/code-generator.js @@ -21,7 +21,6 @@ * */ -const _ = require('lodash') const fs = require('fs') const path = require('path') const codegen = require('./codegen-utils') @@ -71,7 +70,7 @@ class PythonCodeGenerator { var inherits = app.repository.getRelationshipsOf(elem, function (rel) { return (rel.source === elem && (rel instanceof type.UMLGeneralization || rel instanceof type.UMLInterfaceRealization)) }) - return _.map(inherits, function (gen) { return gen.target }) + return inherits.map(function (gen) { return gen.target }) } /** @@ -110,7 +109,7 @@ class PythonCodeGenerator { } else { line = 'self.' + elem.name } - if (elem.multiplicity && _.includes(['0..*', '1..*', '*'], elem.multiplicity.trim())) { + if (elem.multiplicity && ['0..*', '1..*', '*'].includes(elem.multiplicity.trim())) { line += ' = []' } else if (elem.defaultValue && elem.defaultValue.length > 0) { line += ' = ' + elem.defaultValue @@ -182,7 +181,7 @@ class PythonCodeGenerator { // params var params = elem.getNonReturnParameters() - var paramStr = _.map(params, function (p) { return p.name }).join(', ') + var paramStr = params.map(function (p) { return p.name }).join(', ') if (elem.isStatic) { codeWriter.writeLine('@classmethod') @@ -243,7 +242,7 @@ class PythonCodeGenerator { // Import if (_inherits.length > 0) { _inherits.forEach(function (e) { - var _path = _.map(e.getPath(self.baseModel), function (item) { return item.name }).join('.') + var _path = e.getPath(self.baseModel).map(function (item) { return item.name }).join('.') codeWriter.writeLine('from ' + _path + ' import ' + e.name) }) codeWriter.writeLine() @@ -254,7 +253,7 @@ class PythonCodeGenerator { // Inherits if (_inherits.length > 0) { - line += '(' + _.map(_inherits, function (e) { return e.name }).join(', ') + ')' + line += '(' + _inherits.map(function (e) { return e.name }).join(', ') + ')' } codeWriter.writeLine(line + ':')