JohT/data-restructor-js

Option to remove empty fields

Open

#11 opened on Jun 7, 2021

 (0 comments) (0 reactions) (0 assignees)JavaScript (0 forks)auto 404
good first issueoptimizationpriority: should (2)

Repository metrics

Stars
 (3 stars)
PR merge metrics
 (PR metrics pending)

Description

Describe the solution you'd like

To further optimize the output structure and get it as small as possible, these fields could be removed if they are empty by setting a new option:

  • Fields that are used for advanced cases:
    • category
    • type
  • Optional fields that may be not used at all:
    • abbreviation
    • image
  • Fields that are only used for grouping and could be removed afterwards:
    • index

These mandatory fields shouldn't be affected by the new option. They should remain even if their value is empty:

  • displayName
  • fieldName
  • value

The new option could be placed inside the Transform object like setRemoveDuplicationAboveRecursionDepth and could be named setRemoveEmptyOptionalFields(true/false) whereas the default value should be false to not change the current behavior.

Describe alternatives you've considered The removal could be build outside the module but would be less efficient, especially if it would be possible to remove those fields in an earlier stage or even skip them at all.

Contributor guide