]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Better dfl implementation
authorIskren Chernev <iskren.chernev@gmail.com>
Tue, 6 May 2014 16:56:01 +0000 (09:56 -0700)
committerIskren Chernev <iskren.chernev@gmail.com>
Tue, 6 May 2014 16:56:01 +0000 (09:56 -0700)
moment.js

index c0070c93ffd1c1821e57791a95bd18d581201fed..a26528686c95cbe9fb4cf15561b7e04b33519de4 100644 (file)
--- a/moment.js
+++ b/moment.js
 
         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() {