From: Iskren Chernev Date: Tue, 6 May 2014 16:56:01 +0000 (-0700) Subject: Better dfl implementation X-Git-Tag: 2.7.0~23^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fd192ff318b22e886d0c9cea645e9aecbfa27678;p=thirdparty%2Fmoment.git Better dfl implementation --- diff --git a/moment.js b/moment.js index c0070c93f..a26528686 100644 --- a/moment.js +++ b/moment.js @@ -283,14 +283,14 @@ lists = ['months', 'monthsShort', 'weekdays', 'weekdaysShort', 'weekdaysMin']; - function dfl() { - var i; - for (i = 0; i < arguments.length; ++i) { - if (arguments[i] != null) { - return arguments[i]; - } + // Pick the first defined of two or three arguments. dfl comes from + // default. + function dfl(a, b, c) { + switch (arguments.length) { + case 2: return a != null ? a : b; + case 3: return a != null ? a : b != null ? b : c; + default: throw new Error("Implement me"); } - return null; } function defaultParsingFlags() {