A helper for converting a NodeList to a JS Array
776601
function nodeListToArray (nodes) {
    if ($.env.name !== 'IE' || $.env.version > 9) {
      return prototypeSlice.call(nodes);
    }

    // IE 9 and below call use Array.prototype.slice.call against
    // a NodeList, hence the following
    var array = [];

    for (var i=0, num=nodes.length; i<num; ++i) {
      array.push(nodes[i]);
    }

    return array;
  }
1230620
function toArray(val){
        var ret = [],
            kind = kindOf(val),
            n;

        if (val != null) {
            if ( val.length == null || kind === 'String' || kind === 'Function' || kind === 'RegExp' || val === _win ) {
                //string, regexp, function have .length but user probably just want
                //to wrap value into an array..
                ret[ret.length] = val;
            } else {
                //window returns true on isObject in IE7 and may have length
                //property. `typeof NodeList` returns `function` on Safari so
                //we can't use it (#58)
                n = val.length;
                while (n--) {
                    ret[n] = val[n];
                }
            }
        }
        return ret;
    }
1139753
function (Type, Arr, Obj, Node, Error, console) {
    var rawSet = function (dom, key, value) {
      /*
       * JQuery coerced everything to a string, and silently did nothing on text node/null/undefined.
       *
       * We fail on those invalid cases, only allowing numbers and booleans.
       */
      if (Type.isString(value) || Type.isBoolean(value) || Type.isNumber(value)) {
        dom.setAttribute(key, value + '');
      } else {
        console.error('Invalid call to Attr.set. Key ', key, ':: Value ', value, ':: Element ', dom);
        throw new Error('Attribute value was not simple');
      }
    };

    var set = function (element, key, value) {
      rawSet(element.dom(), key, value);
    };

    var setAll = function (element, attrs) {
      var dom = element.dom();
      Obj.each(attrs, function (v, k) {
        rawSet(dom, k, v);
      });
    };

    var get = function (element, key) {
      var v = element.dom().getAttribute(key);

      // undefined is the more appropriate value for JS, and this matches JQuery
      return v === null ? undefined : v;
    };

    var has = function (element, key) {
      var dom = element.dom();

      // return false for non-element nodes, no point in throwing an error
      return dom && dom.hasAttribute ? dom.hasAttribute(key) : false;
    };

    var remove = function (element, key) {
      element.dom().removeAttribute(key);
    };

    var hasNone = function (element) {
      var attrs = element.dom().attributes;
      return attrs === undefined || attrs === null || attrs.length === 0;
    };

    var clone = function (element) {
      return Arr.foldl(element.dom().attributes, function (acc, attr) {
        acc[attr.name] = attr.value;
        return acc;
      }, {});
    };

    var transferOne = function (source, destination, attr) {
      // NOTE: We don't want to clobber any existing attributes
      if (has(source, attr) && !has(destination, attr)) set(destination, attr, get(source, attr));        
    };

    // Transfer attributes(attrs) from source to destination, unless they are already present
    var transfer = function (source, destination, attrs) {
      if (!Node.isElement(source) || !Node.isElement(destination)) return;
      Arr.each(attrs, function (attr) {
        transferOne(source, destination, attr);
      });
    };

    return {
      clone: clone,
      set: set,
      setAll: setAll,
      get: get,
      has: has,
      remove: remove,
      hasNone: hasNone,
      transfer: transfer
    };
  }
152005
function listToArray ( list, opts ) {
	const length = list.getLength();
	const data = [];
	for ( let i = 0; i < length; i++ ) {
		const value = getJsonValueFromSassValue(list.getValue(i), opts);
		data.push(value);
	}
	return data;
}
143317
public static List<Element> nodeListToList(NodeList<Element> nodelist) {

        List<Element> result = Lists.newArrayList();
        for (int i = 0; i < nodelist.getLength(); i++) {
            result.add(nodelist.getItem(i));
        }
        return result;
    }
609173
function (nodeData, options) {

    var makeNode = function (name, content, attributes, level, hasSubNodes) {

        var indentValue = options.indent !== undefined ? options.indent : '\t';
        var indent = options.prettyPrint ? '\n' + new Array(level).join(indentValue) : '';
        if (options.removeIllegalNameCharacters) {
            name = name.replace(elementReplace, '_');
        }

        var node = [indent, '<', name, (attributes || '')];
        if (content && content.length > 0) {
            node.push('>');
            node.push(content);
            if(hasSubNodes) node.push(indent);
            node.push('</');
            node.push(name);
            node.push('>');
        } else {
            node.push('/>');
        }
        return node.join('');
    };

    return (function fn(nodeData, nodeDescriptor, level) {
        var type = typeof nodeData;
        if ((Array.isArray) ? Array.isArray(nodeData) : nodeData instanceof Array) {
            type = 'array';
        } else if (nodeData instanceof Date) {
            type = 'date';
        }

        switch (type) {
            //if value is an array create child nodes from values
            case 'array':
                var ret = [];
                nodeData.map(function (v) {
                    ret.push(fn(v, 1, level + 1));
                    //entries that are values of an array are the only ones that can be special node descriptors
                });
                if(options.prettyPrint) ret.push('\n');
                return ret.join('');
            case 'date':
                // cast dates to ISO 8601 date (soap likes it)
                return nodeData.toJSON ? nodeData.toJSON() : nodeData + '';
            case 'object':
                if (nodeDescriptor === 1 && nodeData.name) {
                    var content = [], attributes = [], c = '';

                    if (nodeData.attrs) {
                        if (typeof nodeData.attrs !== 'object') {
                            // attrs is a string, etc. - just use it as an attribute
                            attributes.push(' ');
                            attributes.push(nodeData.attrs);
                        } else {
                            for (var key in nodeData.attrs) {
                                var value = nodeData.attrs[key];
                                attributes.push(' ');
                                attributes.push(key);
                                attributes.push('="');
                                attributes.push(options.escape ? esc(value) : value);
                                attributes.push('"');
                            }
                        }
                    }

                    //later attributes can be added here
                    if (typeof nodeData.value !== 'undefined') {
                        c = '' + nodeData.value;
                        content.push(options.escape ? esc(c) : c);
                    } else if (typeof nodeData.text !== 'undefined') {
                        c = '' + nodeData.text;
                        content.push(options.escape ? esc(c) : c);
                    }

                    if (nodeData.children) {
                        content.push(fn(nodeData.children, 0, level + 1));
                    }

                    return makeNode(nodeData.name, content.join(''), attributes.join(''), level, !!nodeData.children);
                } else {
                    var nodes = [];
                    for (var name in nodeData) {
                        nodes.push(makeNode(name, fn(nodeData[name], 0, level + 1), null, level + 1));
                    }
                    if(options.prettyPrint && nodes.length > 0) nodes.push('\n');
                    return nodes.join('');
                }
            /* falls through */
            case 'function':
                return nodeData();
            default:
                return options.escape ? esc(nodeData) : '' + nodeData;
        }
    }(nodeData, 0, 0));
}
854902
function serializeArray(element, options = { disabled: false, button: false }) {
  // Resolve all form elements from either forms or collections of form elements
  return (
    element
      .map((i, elem) => {
        const $elem = cheerio(elem);
        if (elem.name === 'form') {
          return $elem.find(submittableSelector).toArray();
        }
        return $elem.filter(submittableSelector).toArray();
      })
      // Verify elements have a name (`attr.name`)
      // and are not disabled (`:disabled`) if `options.disabled === false`
      // and cannot be clicked (`[type=submit]`) if `options.button === true`
      // are used in 'x-www-form-urlencoded' ('[type=file]')
      // and are either checked/don't have a checkable state
      // Convert each of the elements to its value(s)
      .filter(`[name!=""]${options.disabled ? '' : ':not(:disabled)'}:not(${
        options.button ? '' : ':submit, :button, '
      }:image, :reset, :file):matches([checked], :not(:checkbox, :radio))`)
      .map((i, elem) => {
        const $elem = cheerio(elem);
        const name = $elem.attr('name');
        let value = $elem.val();

        // If there is no value set (e.g. `undefined`, `null`), then default value to empty
        if (value == null) {
          value = $elem.attr('type') === 'checkbox' ? 'on' : '';
        }

        // If we have an array of values (e.g. `<select multiple>`),
        // return an array of key/value pairs
        if (Array.isArray(value)) {
          return value.map(val => ({ name, value: val.replace(rCRLF, '\r\n') })); //   These can occur inside of `<textarea>'s` // to guarantee consistency across platforms // We trim replace any line endings (e.g. `\r` or `\r\n` with `\r\n`)
          // Otherwise (e.g. `<input type="text">`, return only one key/value pair
        }
        return { name, value: value.replace(rCRLF, '\r\n') };

        // Convert our result to an array
      })
      .get()
  );
}
748527
public static function nodelist_to_array( \DOMNodeList $list ) {
		$out = [];

		foreach ( $list as $node ) {
			$out[ \spl_object_hash( $node ) ] = $node;
		}

		return $out;
	}
1090263
function parseMarkup(children) {
    const nodeList = children;
    const cstList = [];

    if (typeof nodeList.length === 'undefined') {
      throw new TypeError('Invalid Argument');
    }

    for (let i = 0, li = nodeList.length; i < li; i++) {
      if (nodeList[i] instanceof HTMLElement && nodeList[i].tagName.toUpperCase() === 'OPTGROUP') {
        const cstOptgroup = document.createElement('div');
        cstOptgroup.classList.add(builderParams.optgroupClass);
        cstOptgroup.setAttribute('data-label', nodeList[i].label);

        // IMPORTANT: Stores in a property of the created custom option group
        // a hook to the the corrisponding select's option group
        cstOptgroup.customSelectOriginalOptgroup = nodeList[i];

        // IMPORTANT: Stores in a property of select's option group
        // a hook to the created custom option group
        nodeList[i].customSelectCstOptgroup = cstOptgroup;

        const subNodes = parseMarkup(nodeList[i].children);
        for (let j = 0, lj = subNodes.length; j < lj; j++) {
          cstOptgroup.appendChild(subNodes[j]);
        }

        cstList.push(cstOptgroup);
      } else if (nodeList[i] instanceof HTMLElement
          && nodeList[i].tagName.toUpperCase() === 'OPTION') {
        const cstOption = document.createElement('div');
        cstOption.classList.add(builderParams.optionClass);
        cstOption.textContent = nodeList[i].text;
        cstOption.setAttribute('data-value', nodeList[i].value);
        cstOption.setAttribute('role', 'option');

        // IMPORTANT: Stores in a property of the created custom option
        // a hook to the the corrisponding select's option
        cstOption.customSelectOriginalOption = nodeList[i];

        // IMPORTANT: Stores in a property of select's option
        // a hook to the created custom option
        nodeList[i].customSelectCstOption = cstOption;

        // If the select's option is selected
        if (nodeList[i].selected) {
          setSelectedElement(cstOption);
        }
        cstList.push(cstOption);
      } else {
        throw new TypeError('Invalid Argument');
      }
    }
    return cstList;
  }
785839
function dollarRaw(selector, context, childOnly) {
    function flatten(a) { // flatten list, keep non-lists, remove nulls
      return isList(a) ? collector(flexiEach, a, flatten) : a;
    }
    function filterElements(list) { // converts into array, makes sure context is respected
      return filter(collector(flexiEach, list, flatten), function(node) {
        var a = node;
        while (a = a['parentNode'])
          if (a == context[0] || childOnly)
            return a == context[0];
        // fall through to return undef
      });
    }

    if (context) {
      if ((context = dollarRaw(context)).length != 1)
        return collectUniqNodes(context, function(ci) { return dollarRaw(selector, ci, childOnly);});
      else if (isString(selector)) {
        if (isNode(context[0]) != 1)
          return [];
        else
          return childOnly ? filterElements(context[0].querySelectorAll(selector)) : context[0].querySelectorAll(selector);
      }
      else
        return filterElements(selector);

    }
    else if (isString(selector))
      return document.querySelectorAll(selector);
    else
      return collector(flexiEach, selector, flatten);
  }
1157105
function isNodeList(nodes) {
  var stringRepr = Object.prototype.toString.call(nodes)

  return typeof nodes === 'object' &&
    /^\[object (HTMLCollection|NodeList|Object)\]$/.test(stringRepr) &&
    (typeof nodes.length === 'number') &&
    (nodes.length === 0 || (typeof nodes[0] === "object" && nodes[0].nodeType > 0))
}
572974
function nodesToArray(nodes) {
    if (!nodes || nodes.length === 0) {
        return false;
    } else {
        return nodes.length ? [].slice.call(nodes) : [nodes];
    }
}
818155
function (nodesToAppend) {
            let nodes = Array.prototype.slice.call(nodesToAppend);

            for (let i = 0, len = nodes.length; i < len; ++i) {
                el.appendChild(nodes[i]);
            }
        }
342778
public static List<Element> convertToElementList(org.w3c.dom.NodeList _nodeList) {
        List<org.w3c.dom.Element> elemList = new ArrayList<>();
        for (int i = 0; i < _nodeList.getLength(); i++) {
            Element elem = (org.w3c.dom.Element) _nodeList.item(i);
            elemList.add(elem);
        }
        return elemList;
    }
361437
function positionInNodeList(element, nodeList) {
  for (var i = 0; i < nodeList.length; i++) {
    if (element === nodeList[i]) {
      return i;
    }
  }
  return -1;
}
231596
public static function DOMNodeListToArray(DOMNodeList $nodeList, $associative = false, $attributes = false)
    {
        $nodes = array();

        foreach ($nodeList as $node) {
            $nodes[] = static::DOMNodeValue($node, $associative, $attributes);
        }

        return $nodes;
    }
161918
function getChildJSXElements(node, parent) {
  if (node.children.length === 0) return [];
  const childJsxComponentsArr = node
    .children
    .filter(jsx => jsx.type === 'JSXElement'
      && htmlElements.indexOf(jsx.openingElement.name.name) < 0);
  return childJsxComponentsArr
    .map(child => {
      return {
        name: child.openingElement.name.name,
        children: getChildJSXElements(child, parent),
        props: getReactProps(child, parent),
        state: {},
        methods: [],
      };
    });
}