The Object Manipulator board was developed to work initially with the For Each Board, targeting scenarios such as the Simple Hacker News Search board. The main purpose is to trim and drop properties from responses efficiently.
Key Features
- Selective Property Handling: The board allows you to manage object properties by specifying which ones to keep or omit.
- Modes of Operation:
- Pick Mode: Retains only the keys specified.
- Omit Mode: Drops the keys specified.
- Strict Mode: Option to throw an error if a specified key is absent in both pick and omit modes.
How It Works
- Input Configuration:
- Define the keys you are interested in.
- Choose between pick and omit modes based on your requirements.
- Sample Object Handling:
- Apply the configuration to a sample object to observe the effects.
- Strict Mode Activation:
- Enable strict mode to ensure keys’ presence according to the chosen operation mode.
Usage Example
Pick Mode
- Configuration: Picking
name
andsurname
from the input object. - Output:
Omit Mode
- Configuration: Omitting
surname
from the input object. - Output:
Error Handling
Enabling strict mode ensures that any absence of specified keys results in an error, maintaining the integrity of the operation.
Strict Mode Example
- Scenario: Omitting
surname
in strict mode. - Result: Error is thrown if
surname
is not present in the input object.
Conclusion
The Object Manipulator board provides a solution for managing object properties, whether by picking specific keys or omitting unnecessary ones. The inclusion of strict mode ensures error handling, making it a versatile tool for data manipulation tasks.
This board is used in the Simple Hacker News Search board to apply the manipulation to each element with the Board for Each board.