marcog83/RoboJS

View on GitHub
src/internal/_isArrayLike.js

Summary

Maintainability
A
2 hrs
Test Coverage
import _isArray from "./_isArray";
 
function _isString(x) {
return Object.prototype.toString.call(x) === "[object String]";
}
 
Function `default` has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
export default function (x) {
const isArray = Array.isArray || _isArray;
if (!x) {
return false;
}
if (isArray(x)) {
return true;
}
 
if ("object" !== typeof x) {
 
return false;
}
if (_isString(x)) {
return false;
}
if (x.nodeType === 1) {
Avoid too many `return` statements within this function.
return !!x.length;
}
if (x.length === 0) {
Avoid too many `return` statements within this function.
return true;
}
if (x.length > 0) {
Avoid too many `return` statements within this function.
return x.hasOwnProperty(0) && x.hasOwnProperty(x.length - 1);
}
Avoid too many `return` statements within this function.
return false;
}