MCPcopy Create free account
hub / github.com/Lucifier129/react-lite / hasArrayNature

Function hasArrayNature

examples/simple/react.js:17803–17823  ·  view source on GitHub ↗

* Perform a heuristic test to determine if an object is "array-like". * * A monk asked Joshu, a Zen master, "Has a dog Buddha nature?" * Joshu replied: "Mu." * * This function determines if its argument has "array nature": it returns * true if the argument is an actual array, an `arguments

(obj)

Source from the content-addressed store, hash-verified

17801 * @return {boolean}
17802 */
17803function hasArrayNature(obj) {
17804 return(
17805 // not null/false
17806 !!obj && (
17807 // arrays are objects, NodeLists are functions in Safari
17808 typeof obj == 'object' || typeof obj == 'function') &&
17809 // quacks like an array
17810 'length' in obj &&
17811 // not window
17812 !('setInterval' in obj) &&
17813 // no DOM node should be considered an array-like
17814 // a 'select' element has 'length' and 'item' properties on IE8
17815 typeof obj.nodeType != 'number' && (
17816 // a real array
17817 Array.isArray(obj) ||
17818 // arguments
17819 'callee' in obj ||
17820 // HTMLCollection/NodeList
17821 'item' in obj)
17822 );
17823}
17824
17825/**
17826 * Ensure that the argument is an array by wrapping it in an array if it is not.

Callers 1

createArrayFromMixedFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected