Flatten the data

@param {Object} data
@returns
558419
function flatten(data, pre) {
  const prefix = pre || '';
  const keys = Object.keys(data);
  const result = {};
  keys.forEach((k) => {
    const value = data[k];
    const key = [prefix, k].join('-');
    if (isObject(value)) {
      Object.assign(result, flatten(value, key));
    } else {
      result[key] = value;
    }
  });
  return result;
}
160584
public static Object flatten(Object array) {
        Preconditions.checkArgument(array.getClass().isArray(), "array");

        Class<?> type = getType(array);
        int[] dimensions = getDimensions(array);
        int length = length(dimensions);

        Object flattened = Array.newInstance(type, length);

        flatten(array, flattened, dimensions, 0);

        return flattened;
    }
1121931
function flatten(array) {
    var result = [], i, n;

    for (i = 0, n = array.length; i < n; i++) {
      if (isArray(array[i])) {
        result = result.concat(flatten(array[i]));
      }
      else {
        result.push(array[i]);
      }
    }

    return result;
  }
659570
function flatten(obj,callback) {
    let arr = [];
    let iDepth, oDepth = 0;
    let state = {identityDetection:true};
    recurse(obj,state,function(obj,key,state){
        let entry = {};
        entry.name = key;
        entry.value = obj[key];
        entry.path = state.path;
        entry.parent = obj;
        entry.key = key;
        if (callback) entry = callback(entry);
        if (entry) {
            if (state.depth > iDepth) {
                oDepth++;
            }
            else if (state.depth < iDepth) {
                oDepth--;
            }
            entry.depth = oDepth;
            iDepth = state.depth;
            arr.push(entry);
        }
    });
    return arr;
}
1125851
function flatten(source, opts) {
  opts = opts || {};
  var delimiter = opts.delimiter = opts.delimiter || '.';
  var o = {};
  function iterate(source, parts) {
    var k, v;
    parts = parts || [];
    for(k in source) {
      v = source[k];
      if(v && typeof v === 'object' && Object.keys(v).length) {
        iterate(v, parts.concat(k));
      }else{
        o[parts.concat(k).join(delimiter)] = v;
      }
    }
  }
  iterate(source);
  return o;
}
814704
function (data, defaults, callback) {
  // Flatten everything for ease of use.
  var options = _.defaults({}, data, data.options, defaults)

  callback(null, options)
}
746069
function flatten (arr) {
  return arr.reduce(function (acc, curr) {
    return acc.concat(Array.isArray(curr) ? flatten(curr) : curr)
  }, [])
}
545256
function flattenElementsAr (ar) {
  return ar.reduce((acc, el) => {
    return isArray(el) ? [ ...acc, ...el ] : [ ...acc, el ]
  }, []).filter(notNull) // null means ignore
}
1275218
private static Map<String, Set<String>> flatten(Map<String, Set<String>> data) {
    Map<String, Set<String>> territories = new TreeMap<>();
    Set<String> keys = data.keySet();
    for (String key : keys) {
      Set<String> values = flatten(key, territories, data);
      territories.put(key, values);
    }
    return territories;
  }
543608
function flatten( a ) {
    var results;
    var isArray = ( a.length !== undefined && typeof a !== "string" );
    if ( isArray ) {
        results = []
        for ( var i = 0; i < a.length; i++ ) {
            var result = flatten( a[i] );
            results = results.concat( result );
        }
    } else {
        results = [ a ];
    }
    return results;
}
1279277
function flattenProperties (obj, prefix = null, globals = {}) {
    prefix = prefix ? (prefix + '.') : 'global.';

    for (const p in obj) {
        const key = prefix + p;
        const val = obj[p];
        globals[key] = val;

        if (typeof val === 'object' && !Array.isArray(val)) {
            flattenProperties(val, key, globals);
        }
    }
    return globals;
}
745398
function(arrays,result){
       var self = this,flat = result || [];
       this.forEach(arrays,function(a){

        if(self.isArray(a)){
         self.flatten(a,flat);
       }else{
         flat.push(a);
       }

     },self);

       return flat;
    }
477534
function FlattenIntoArray(target, source, sourceLen, start, depth) {
	var targetIndex = start;
	var sourceIndex = 0;

	var mapperFunction;
	if (arguments.length > 5) {
		mapperFunction = arguments[5];
	}

	while (sourceIndex < sourceLen) {
		var P = ES.ToString(sourceIndex);
		var exists = ES.HasProperty(source, P);
		if (exists) {
			var element = ES.Get(source, P);
			if (typeof mapperFunction !== 'undefined') {
				if (arguments.length <= 6) {
					throw new TypeError('Assertion failed: thisArg is required when mapperFunction is provided');
				}
				element = ES.Call(mapperFunction, arguments[6], [element, sourceIndex, source]);
			}
			var shouldFlatten = false;
			if (depth > 0) {
				shouldFlatten = ES.IsArray(element);
			}
			if (shouldFlatten) {
				var elementLen = ES.ToLength(ES.Get(element, 'length'));
				targetIndex = FlattenIntoArray(target, element, elementLen, targetIndex, depth - 1);
			} else {
				if (targetIndex >= MAX_SAFE_INTEGER) {
					throw new TypeError('index too large');
				}
				ES.CreateDataPropertyOrThrow(target, ES.ToString(targetIndex), element);
				targetIndex += 1;
			}
		}
		sourceIndex += 1;
	}

	return targetIndex;
}
1171966
function flatten( arr ) {
	var tmp;
	var out;
	var i;
	var j;
	
	out = [];
	for ( i = 0; i < arr.length; i++ ) {
		tmp = arr[ i ];
		if ( tmp ) {
			for ( j = 0; j < tmp.length; j++ ) {
				out.push( tmp[ j ] );
			}
		}
	}
	return out;
}
217322
def flatten_json(data, prefix = None):
    '''
    
    '''
    # iterate all items
    for item in data:
        # split the object
        flat, key, subs = split_obj(item, prefix)

        # just return fully flat objects
        if key is None:
            yield flat
            continue

        # otherwise recursively flatten the subobjects
        for sub in flatten_json(subs, key):
            sub.update(flat)
            yield sub
703097
function flatten(data) {
        var dim = data[0][0].length, result = { vertices: new Array(), holes: new Array(), dimensions: dim }, holeIndex = 0;
        for (var i = 0; i < data.length; i++) {
            for (var j = 0; j < data[i].length; j++) {
                for (var d = 0; d < dim; d++)
                    result.vertices.push(data[i][j][d]);
            }
            if (i > 0) {
                holeIndex += data[i - 1].length;
                result.holes.push(holeIndex);
            }
        }
        return result;
    }
1257468
function map(data) {
    var result = {}
      , i = this.properties.length;

    while (i--) result[this.properties[i]] = data[i];
    return result;
  }