]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Clean up the defaults implementation.
authorTim Wood <washwithcare@gmail.com>
Thu, 22 Jan 2015 16:53:37 +0000 (08:53 -0800)
committerIskren Chernev <iskren.chernev@gmail.com>
Wed, 25 Mar 2015 16:27:42 +0000 (09:27 -0700)
lib/utils/defaults.js

index d69197c16987873b33a745d890da2ea285d85282..45c5e8794247286e8ee4399d47e75dadd4ea2aad 100644 (file)
@@ -1,8 +1,10 @@
-// Pick the first defined of two or three arguments. dfl comes from default.
+// Pick the first defined of two or three arguments.
 export default function defaults(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'); // TODO: Fix
+    if (a != null) {
+        return a;
     }
+    if (b != null) {
+        return b;
+    }
+    return c;
 }