Options
All
  • Public
  • Public/Protected
  • All
Menu

Namespace utils

Index

Functions

Const deepValue

  • deepValue(obj: any, path: any): any
  • Parameters

    • obj: any
    • path: any

    Returns any

Const flatten

  • flatten(data: any): {}
  • Parameters

    • data: any

    Returns {}

Const getDeletedValues

  • getDeletedValues(deletedFields: any, accumulator?: {}): any
  • Converts a list of field names to an object of deleted values.

    example

    const deletedFields = [ 'field.subField', 'field.subFieldArray[0]', 'fieldArray[0]', 'fieldArray[2].name', ]; getNestedDeletedValues(deletedFields); // => { 'field': { 'subField': null, 'subFieldArray': [null] }, 'fieldArray': [null, undefined, { name: null } }

    Parameters

    • deletedFields: any

      List of deleted field names or paths

    • accumulator: {} = {}

    Returns any

    Deleted values, with the structure defined by taking the received deleted fields as paths

Const getFieldType

  • getFieldType(fieldSchema: VulcanFieldSchema<any>): VulcanFieldType
  • Parameters

    • fieldSchema: VulcanFieldSchema<any>

    Returns VulcanFieldType

Const getNestedDeletedValues

  • getNestedDeletedValues(prefix: any, deletedFields: any, accumulator?: {}): any
  • Filters the given field names by prefix, removes it from each one of them and convert the list to an object of deleted values.

    example

    const deletedFields = [ 'field.subField', 'field.subFieldArray[0]', 'fieldArray[0]', 'fieldArray[2].name', ]; getNestedDeletedValues('field', deletedFields); // => { 'subField': null, 'subFieldArray': [null] } getNestedDeletedValues('fieldArray', deletedFields); // => { '0': null, '2': { 'name': null } } getNestedDeletedValues('fieldArray', deletedFields, []); // => [null, undefined, { 'name': null } ]

    Parameters

    • prefix: any

      Prefix to filter and remove from deleted fields

    • deletedFields: any

      List of deleted field names or paths

    • accumulator: {} = {}

    Returns any

    Object keyed with the given deleted fields, valued with null

Const getNullValue

  • getNullValue(datatype: any): null | false | "" | never[]
  • Get appropriate null value for various field types

    Parameters

    • datatype: any

      Field's datatype property

    Returns null | false | "" | never[]

Const isEmptyValue

  • isEmptyValue(value: any): boolean
  • Parameters

    • value: any

    Returns boolean

Const mergeValue

  • mergeValue(__namedParameters: Object): any
  • Merges values. It takes into account the current, original and deleted values, and the merge produces the proper type for simple objects or arrays.

    Parameters

    • __namedParameters: Object

    Returns any

    Merged value or undefined if no merge was performed

Generated using TypeDoc