Skip to content

Commit

Permalink
Remove lodash
Browse files Browse the repository at this point in the history
  • Loading branch information
niklauslee committed May 24, 2018
1 parent a327f73 commit 421b11f
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions code-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
*
*/

const _ = require('lodash')
const fs = require('fs')
const path = require('path')
const codegen = require('./codegen-utils')
Expand Down Expand Up @@ -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 })
}

/**
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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()
Expand All @@ -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 + ':')
Expand Down

0 comments on commit 421b11f

Please sign in to comment.