From 1228639103ff5edb58b6610ca589691f334cf922 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Fri, 29 Jun 2012 19:33:36 -0400 Subject: [PATCH] Cleanup build.js. Former-commit-id: 01f5488ddba9f51344561c8df493d4f1bc6b0ef9 --- build.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/build.js b/build.js index 6e5984bb3..49bfb1a07 100755 --- a/build.js +++ b/build.js @@ -580,12 +580,15 @@ "'else if (thisArg) callback = iteratorBind(callback, thisArg)'" ); + /*--------------------------------------------------------------------------*/ + // DRY out isType methods (function() { var iteratorName = lodash.find(['forEach', 'forOwn'], function(funcName) { return !isRemoved(source, funcName); }); + // skip this optimization if there is no iteration method to use if (!iteratorName) { return; } @@ -594,6 +597,7 @@ result = [], token = '__isTypeToken__'; + // build replacement code lodash.forOwn({ 'Arguments': "'[object Arguments]'", 'Date': 'dateClass', @@ -607,6 +611,7 @@ if (funcCode) { if (!snippet) { + // use snippet to mark the insert position snippet = funcCode; } funcNames.push(funcName); @@ -674,6 +679,9 @@ // remove IE `shift` and `splice` fix source = source.replace(/(?:\s*\/\/.*\n)*( +)if *\(value.length *=== *0[\s\S]+?\n\1}/, ''); + + // cleanup code + source = source.replace(/^ *;\n/gm, ''); } else { // inline `iteratorTemplate` template