import { isFunction } from 'lodash' ; import { IFieldFormat , TextContextTypeConvert , FieldFormatsContentType } from '../types' ; import { asPrettyString } from '../utils' ; export const TEXT_CONTEXT_TYPE = 'text' ; export const setup = ( format , convert = asPrettyString ) : TextContextTypeConvert => { const recurse = ( value ) => { if ( ! value || ! isFunction ( value . map ) ) { return convert . call ( format , value ) ; } return JSON . stringify ( value . map ( recurse ) ) ; } ; return recurse ; } ;