From 45bc74efe76dea21bd789e76d1f37416ad6f30b1 Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Sun, 8 Mar 2015 02:57:37 +1100 Subject: [PATCH] use a lookup table instead of an if - #945 --- src/babel/build-external-helpers.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/babel/build-external-helpers.js b/src/babel/build-external-helpers.js index b96579a27f..b20f956c3b 100644 --- a/src/babel/build-external-helpers.js +++ b/src/babel/build-external-helpers.js @@ -56,12 +56,15 @@ export default function (whitelist, outputType = "global") { }; var tree; - if (outputType === "global") { - tree = buildGlobal(namespace, builder); - } else if (outputType === "umd") { - tree = buildUmd(namespace, builder); - } else if (outputType === "var") { - tree = buildVar(namespace, builder); + + var build = { + global: buildGlobal, + umd: buildUmd, + var: buildVar + }[outputType]; + + if (builder) { + tree = build(namespace, builder); } else { throw new Error(messages.get("unsupportedOutputType", outputType)); }