import { flatten as flatleyFlatten , Coercion , FlatleyOptions } from "flatley" ; import { cloneDeep } from "lodash" ; const hasPeriodInKey = ( key ) => { if ( key . indexOf ( "." ) >= 0 ) { throw new Error ( "Key names must not have . in them" ) ; } return false ; } ; const filters = [ { test : hasPeriodInKey } ] ; param data param options export const flatten = ( data , options ? ) : any => { const newOptions = options ? cloneDeep ( options ) : { } ; if ( newOptions . coercion ) { newOptions . coercion . push ( ... filters ) ; } else { newOptions . coercion = filters ; } return flatleyFlatten ( data , newOptions ) ; } ;