Skip to content

Commit

Permalink
Minor code style changes
Browse files Browse the repository at this point in the history
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
  • Loading branch information
florian-h05 committed May 15, 2023
1 parent 6af72dd commit d5d01b2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import Blockly from 'blockly'
import { javascriptGenerator } from 'blockly/javascript'
import { addDict } from './utils'

export default function (f7, isGraalJs) {
Blockly.Blocks['dicts_create_with'] = {
Expand Down Expand Up @@ -257,15 +256,21 @@ export default function (f7, isGraalJs) {
if (dictType === 'Dictionary') {
// Dictionary used directly, so we create an intermediate var
dictVar = addDict()
code += `${dictVar}=${dict}\n`
code += `${dictVar}=${dict};\n`
} else {
dictVar = dict
}

code += `for (var ${loopVar}Key in ${dictVar}) {\n`
code += `${loopVar} = ${dictVar}[${loopVar}Key]\n`
code += dictForCode + '\n'
code += ` ${loopVar} = ${dictVar}[${loopVar}Key];\n`
code += dictForCode
code += '}\n'
return code
}
}

function addDict () {
return javascriptGenerator.provideFunction_(
'dictionary',
['var ' + javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_ + ';'])
}
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,6 @@ export function addGetItemMetaConfigValue () {
])
}

export function addDict () {
let dict = javascriptGenerator.provideFunction_(
'dictionary',
['var ' + javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_ + ';'])
return dict
}

/**
* Gets the type of passed input to a given block.
*
Expand Down

0 comments on commit d5d01b2

Please sign in to comment.