From: Tim Wood Date: Thu, 22 Jan 2015 16:53:37 +0000 (-0800) Subject: Clean up the defaults implementation. X-Git-Tag: 2.10.2~15^2~38 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=367615298640338b57c99cdf95e25a67d1ede7f9;p=thirdparty%2Fmoment.git Clean up the defaults implementation. --- diff --git a/lib/utils/defaults.js b/lib/utils/defaults.js index d69197c16..45c5e8794 100644 --- a/lib/utils/defaults.js +++ b/lib/utils/defaults.js @@ -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; }