Skip to content
This repository has been archived by the owner on Aug 13, 2021. It is now read-only.

Commit

Permalink
Rebases stuff from associations to check undefind/null
Browse files Browse the repository at this point in the history
  • Loading branch information
mikermcneil committed Dec 17, 2013
1 parent 10fda61 commit d1df619
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions index.js
Expand Up @@ -239,22 +239,22 @@ var compare = {

// Prepare two values for comparison
function normalizeComparison(a,b) {

if(_.isUndefined(a) || a === null) a = '';
if(_.isUndefined(b) || b === null) b = '';

if (_.isString(a) && _.isString(b)) {
a = a.toLowerCase();
b = b.toLowerCase();
}



// Stringify for comparisons- except for numbers, null, and undefined
if (!_.isNumber(a)) {
a = a.toString();
a = typeof a.toString !== 'undefined' ? a.toString() : '' + a;
}
else if (_.isNull(a) || _.isUndefined(a)) {}

if (!_.isNumber(b)) {
b = b.toString();
b = typeof b.toString !== 'undefined' ? b.toString() : '' + b;
}
else if (_.isNull(b) || _.isUndefined(b)) {}


return [a,b];
Expand Down

0 comments on commit d1df619

Please sign in to comment.