Skip to content

Commit

Permalink
fix(Angularjs) WIP - code cleanup
Browse files Browse the repository at this point in the history
Prepares a single boolean return instead of several if return boolean
statements.

angular#4751
  • Loading branch information
jackcviers committed Nov 9, 2013
1 parent 9ba755e commit 252e834
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/Angular.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,16 +167,15 @@ if (isNaN(msie)) {
* String ...)
*/
function isArrayLike(obj) {
var length
if (obj == null || isWindow(obj)) {
return false;
}
if(obj.nodeType === 1 && obj.hasChildNodes()) return true;
if(obj.hasOwnProperty('length') && obj.hasOwnProperty('callee')) return true;
length = obj.length;
return isString(obj) || isArray(obj) || (
!isObject(obj) && length === 0 || (
typeof length === 'number' && length >= 0 && (length - 1) in obj));
var length, objExists, isNodeList, isArguments, isSomeOtherObj;
objExists = isDefined(obj) && obj !== null;
length = objExists ? obj.length : undefined;
isNodeList = objExists && obj.nodeType === 1 && obj.hasChildNodes();
isArguments = objExists && obj.hasOwnProperty('length') && obj.hasOwnProperty('callee');
isSomeOtherObj = objExists && !isArguments && !isNodeList && !isArray(obj) && !isString(obj) && (!isObject(obj) && length === 0 || (typeof length === 'number' && length >= 0 && (length - 1) in obj));

return objExists && !isWindow(obj) && (((obj.nodeType === 1 && obj.hasChildNodes()) || (obj.hasOwnProperty('length') && obj.hasOwnProperty('callee')) || isString(obj) || isArray(obj)) || (!isObject(obj) && length === 0 || (typeof length === 'number' && length >= 0 && (length - 1) in obj)) );

}

/**
Expand Down

0 comments on commit 252e834

Please sign in to comment.