Skip to content

Commit

Permalink
Clean up the defaults implementation.
Browse files Browse the repository at this point in the history
  • Loading branch information
timrwood authored and ichernev committed Mar 25, 2015
1 parent eb4c014 commit 3676152
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/utils/defaults.js
Original file line number Diff line number Diff line change
@@ -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;
}

0 comments on commit 3676152

Please sign in to comment.