The logic for this is quite terse. It's because we need to
support spread elements. We loop over all attributes,
breaking on spreads, we then push a new object containg
all prior attributes to an array for later processing.
963290
function buildJSXOpeningElementAttributes(attribs, file) {
    var _props = [];
    var objs = [];

    var pushProps = function pushProps() {
      if (!_props.length) return;

      objs.push(t.objectExpression(_props));
      _props = [];
    };

    while (attribs.length) {
      var prop = attribs.shift();
      if (t.isJSXSpreadAttribute(prop)) {
        pushProps();
        objs.push(prop.argument);
      } else {
        _props.push(prop);
      }
    }

    pushProps();

    if (objs.length === 1) {
      // only one object
      attribs = objs[0];
    } else {
      // looks like we have multiple objects
      if (!t.isObjectExpression(objs[0])) {
        objs.unshift(t.objectExpression([]));
      }

      // spread it
      attribs = t.callExpression(file.addHelper("extends"), objs);
    }

    return attribs;
  }
784123
@Override
	public void listInsertBefore(final T currentElement, final T newElement) throws FrameworkException {

		if (currentElement.getUuid().equals(newElement.getUuid())) {
			throw new IllegalStateException("Cannot link a node to itself!");
		}

		final T previousElement = listGetPrevious(currentElement);
		if (previousElement == null) {

			linkNodes(getSiblingLinkType(), newElement, currentElement);

		} else {
			// delete old relationship
			unlinkNodes(getSiblingLinkType(), previousElement, currentElement);

			// dont create self link
			if (!previousElement.getUuid().equals(newElement.getUuid())) {
				linkNodes(getSiblingLinkType(), previousElement, newElement);
			}

			// dont create self link
			if (!newElement.getUuid().equals(currentElement.getUuid())) {
				linkNodes(getSiblingLinkType(), newElement, currentElement);
			}
		}
	}
994179
function initializeObjectAttribute( $contentObjectAttribute, $currentVersion, $originalContentObjectAttribute )
    {
        if ( $currentVersion == false )
        {
            $contentObjectAttribute->setAttribute( 'data_int', 0 );
        }
        else if (  $contentObjectAttribute->attribute( 'id' ) != 0  )
        {
            if ( $originalContentObjectAttribute->attribute( 'data_int' ) != 0 )
            {
                $gmapObject = $originalContentObjectAttribute->attribute( 'content' );
                $gmapObject->setAttribute( 'contentobject_attribute_id', $contentObjectAttribute->attribute( 'id' ) );//in case of copy
                $gmapObject->setAttribute( 'contentobject_version', $contentObjectAttribute->attribute( 'version' ) );
                $contentObjectAttribute->setContent( $gmapObject );
                $contentObjectAttribute->store();
            }
        }
    }
843348
static JSONObject processAttributesForCovering(Map<String, Object> attributes) {
    HashMap<String, Object> attributeMap = new HashMap<String, Object>();
    if (attributes.containsKey(Conversation.NAME)) {
      attributeMap.put(Conversation.NAME,
              attributes.get(Conversation.NAME));
    }
    Map<String, Object> innerAttribute = new HashMap<String, Object>();
    for (Map.Entry<String, Object> entry : attributes.entrySet()) {
      String k = entry.getKey();
      if (!Arrays.asList(Conversation.CONVERSATION_COLUMNS).contains(k)) {
        innerAttribute.put(k, entry.getValue());
      }
    }
    if (!innerAttribute.isEmpty()) {
      attributeMap.put(Conversation.ATTRIBUTE, innerAttribute);
    }
    if (attributeMap.isEmpty()) {
      return null;
    }
    return new JSONObject(attributeMap);
  }
1268120
function(arrayOrObjectArray) {
			
			return arrayOrObjectArray.reduce(function(prev, curr) {
				var returnValue = prev;
				var filteredArray = null;
				
				if (curr && Array.isArray(curr)) {
					filteredArray = curr.filter(function(element){
						return element; //filter out falsy elements
					});	
				}
				
				// add current proposal array to flattened array
				// skip current elements that are not arrays
				if (filteredArray && Array.isArray(filteredArray) && (filteredArray.length > 0)) {
					var first = filteredArray;
					var last = prev;
					var filteredArrayStyle = filteredArray[0].style;
					
					if (filteredArrayStyle && STYLES[filteredArrayStyle] && (0 === STYLES[filteredArrayStyle].indexOf(STYLES.noemphasis))) {
						// the style of the first element starts with noemphasis
						// add these proposals to the end of the array
						first = prev;
						last = filteredArray;
					}
					
					if (first.length > 0) {
						var firstArrayStyle = first[first.length - 1].style;
						if (firstArrayStyle && (STYLES.hr !== STYLES[firstArrayStyle])) {
							// add separator between proposals from different providers 
							// if the previous array didn't already end with a separator
							first = first.concat({
								proposal: '',
								name: '',
								description: '---------------------------------', //$NON-NLS-0$
								style: 'hr', //$NON-NLS-0$
								unselectable: true
							});
						}
					}
					
					returnValue = first.concat(last);
				}
				
				return returnValue;
			}, []);
		}
533397
function(attrs, options) {
    if (typeof attrs === 'object') {
      for(var k in attrs) {
        this.set(k, attrs[k], options);
      }
    } else {
      var value = options, name = attrs;
      options = arguments[2];
      if (this[name] && this[name] === value) return this;
      this._previous[name] = this[name];
      this[name] = value;
      this.trigger('change');
    }
    return this;
  }
1038022
function flattenArray(arrayToFlatten, arrayFlatten) {
    // check if the arg is a array, if not a error is thrown
    if(!Array.isArray(arrayToFlatten)) throw new Error('Only can flat arrays and you pass a ' + typeof arrayToFlatten)
    // set the default value of arrayFlatten, this validation is used only in the first call of
    // recursive function
    arrayFlatten = arrayFlatten || []
    // loop over the array to get flatten the array 
    for (let i = 0; i < arrayToFlatten.length; ++i) {
        // if the item in the arrray is a array then the flattenArray function is callen again
        if (Array.isArray(arrayToFlatten[i])) {
          // the function is called with the element what is a array and pass the arrayFlatten as second arg
          flattenArray(arrayToFlatten[i], arrayFlatten)
          // break the loop
          continue
        }
        // if the element is not a array only push the element
        arrayFlatten.push(arrayToFlatten[i]);
    }
    // return the array flatten
    return arrayFlatten
}
305186
function extend(prototype, attributes) {
    var object = {};
    Object.keys(prototype).forEach(function(key) {
      object[key] = prototype[key];
    });
    Object.keys(attributes).forEach(function(key) {
      object[key] = attributes[key];
    });
    return object;
  }
976814
def create_attributes(klass, attributes, previous_object=None):
        

        result = super(ContentType, klass).create_attributes(attributes, previous_object)

        if 'fields' not in result:
            result['fields'] = []
        return result
523381
function( attributes ) {
		var result = {},
			$element = this;
		$.each(attributes.split(/\s/), function( index, value ) {
			result[value] = $element.attr(value);
			$element.removeAttr(value);
		});
		return result;
	}
28419
function handleSimpleAttribute() {
    SIMPLEATTR.lastIndex = nextchar-1;
    var matched = SIMPLEATTR.exec(chars);
    if (!matched) throw new Error("should never happen");
    var name = matched[1];
    if (!name) return false;
    var value = matched[2];
    var len = value.length;
    switch(value[0]) {
    case '"':
    case "'":
      value = value.substring(1, len-1);
      nextchar += (matched[0].length-1);
      tokenizer = after_attribute_value_quoted_state;
      break;
    default:
      tokenizer = before_attribute_name_state;
      nextchar += (matched[0].length-1);
      value = value.substring(0, len-1);
      break;
    }

    // Make sure there isn't already an attribute with this name
    // If there is, ignore this one.
    for(var i = 0; i < attributes.length; i++) {
      if (attributes[i][0] === name) return true;
    }

    attributes.push([name, value]);
    return true;
  }
1061091
function (obj, f) {
      var r = [];
      each(obj, function(value, name) {
        r.push(f(value, name));
      });
      return r;
    }
1090926
function addNextNodesToASTObject(ASTObject) {
  const ASTObjectsForDepths = [ASTObject];
  function addNextNodes(ASTObject, depth) {
    const depthPlus1 = depth + 1;
    ASTObjectsForDepths[depthPlus1] = ASTObject;
    if (ASTObject.left)
      addNextNodes(ASTObject.left, depthPlus1);
    if (ASTObject.right)
      addNextNodes(ASTObject.right, depthPlus1);
    if (ASTObject.next) {
      const ASTObjectForDepth = ASTObjectsForDepths[depth];
      if (ASTObjectForDepth.nextNodes)
        ASTObjectForDepth.nextNodes.push(ASTObject.next);
      else
        ASTObjectForDepth.nextNodes = [ASTObject.next];
      addNextNodes(ASTObject.next, depth);
    }
  }
  addNextNodes(ASTObject, 0);
}
448798
function pushSingle(arr, element) {
    var index = arr.sortedIndex(element),
        _ = arr._sortedArray;

    // original push and unshift are faster than splice
    if (index === 0) {
        _.unshift.call(arr, element);
    } else if (index === arr.length) {
        _.push.call(arr, element);
    } else {
        _.splice.call(arr, index, 0, element);
    }
}
861969
function merge(target) {
	for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
		args[_key - 1] = arguments[_key];
	}

	for (var arg, len = args.length, index = 0; arg = args[index], index < len; index += 1) {
		for (var all in arg) {
			if (typeof HTMLElement !== 'undefined' && arg instanceof HTMLElement || typeof propDetails(arg, all).value !== 'undefined' && (!target[all] || propDetails(target, all).writable)) {
				if (all !== 'attributes') target[all] = arg[all];
			}
		}
	}

	return target;
}
527530
function( elems, callback, arg ) {
		var length, value,
			i = 0,
			ret = [];

		// Go through the array, translating each of the items to their new values
		if ( isArrayLike( elems ) ) {
			length = elems.length;
			for ( ; i < length; i++ ) {
				value = callback( elems[ i ], i, arg );

				if ( value != null ) {
					ret.push( value );
				}
			}

		// Go through every key on the object,
		} else {
			for ( i in elems ) {
				value = callback( elems[ i ], i, arg );

				if ( value != null ) {
					ret.push( value );
				}
			}
		}

		// Flatten any nested arrays
		return concat.apply( [], ret );
	}
330397
function() {
      var i        = 0,
          length   = arr.length,
          newArray = [];
      for (; i<length; i++) {
        newArray.push(arr[i]);
      }
      return newArray;
    }