isListLike
Test if a value looks like a constructor function.
isListLike(list)
Return true
if list
is a String
,
OR list
is not a primitive and implements @@iterator
,
OR list
is not a primitive and returns true
for Array.isArray()
,
OR list
is not a primitive and has a
numerical length and is either empty (length === 0
) or has a last element at index length - 1
; false
otherwise
canReflect.isListLike(null); // -> false
canReflect.isListLike({}); // -> false
canReflect.isListLike([]); // -> true
canReflect.isListLike("foo"); // -> true
canReflect.isListLike(1); // -> false
canReflect.isListLike({ [canSymbol.for("can.isListLike")]: true }); // -> true
canReflect.isListLike({ [canSymbol.iterator]: function() {} }); // -> true
canReflect.isListLike({ length: 0 }); // -> true
canReflect.isListLike({ length: 3 }); // -> false
canReflect.isListLike({ length: 3, "2": true }); // -> true
canReflect.isListLike(new DefineMap()); // -> false
canReflect.isListLike(new DefineList()); // -> true
Parameters
- list
{*}
:maybe a List-like
Returns
{Boolean}
: