utils.js
function dotFlattenFn(object, sep, flattenedMap, optPathSoFar) {
  let levelKeys = Object.keys(object);

  for (let i = 0, j = levelKeys.length; i < j; i++) {
    let key       = levelKeys[i];
    let value     = object[key];
    let pathSoFar = cloneDeep(optPathSoFar) || [];

    pathSoFar.push(key);

    if (isPlainObject(value)) {
      dotFlattenFn(value, sep, flattenedMap, pathSoFar);
    }
    else {
      flattenedMap[pathSoFar.join(sep)] = value;
    }
  }
}
function dotFlattenFn(object, sep, flattenedMap, optPathSoFar) {
  let levelKeys = Object.keys(object);

  for (let i = 0, j = levelKeys.length; i < j; i++) {
    let key       = levelKeys[i];
    let value     = object[key];
    let pathSoFar = cloneDeep(optPathSoFar) || [];

    pathSoFar.push(key);

    if (isPlainObject(value)) {
      dotFlattenFn(value, sep, flattenedMap, pathSoFar);
    }
    else {
      flattenedMap[pathSoFar.join(sep)] = value;
    }
  }
}
function dotFlattenFn ( object , sep , flattenedMap , optPathSoFar ) { let levelKeys = Object . keys ( object ) ; for ( let i = 0 , j = levelKeys . length ; i < j ; i ++ ) { let key = levelKeys [ i ] ; let value = object [ key ] ; let pathSoFar = cloneDeep ( optPathSoFar ) || [ ] ; pathSoFar . push ( key ) ; if ( isPlainObject ( value ) ) { dotFlattenFn ( value , sep , flattenedMap , pathSoFar ) ; } else { flattenedMap [ pathSoFar . join ( sep ) ] = value ; } } }
The real workhorse of the `dotFlatten` function.
A recursive function that fills a map when found the object leaves.

@param  {Object} object
@param  {String} sep               - The separator between nested properties.
@param  {Object} flattenedMap      - The resulting object map of the flattening process.
@param  {Array} [optPathSoFar]     - The path that we have processed so far.
@return {Object}
The real workhorse of the dotFlatten function . A recursive function that fills a map when found the object leaves .