lodash

n8n node for executing Lodash functions

Package Information

Downloads: 33 weekly / 84 monthly
Latest Version: 1.1.3

Documentation

n8n-nodes-lodash

NPM Version
NPM Downloads
License: MIT
n8n

This is an n8n community node that allows you to execute Lodash functions directly within your workflows. It provides access to a wide range of utility functions for manipulating arrays, objects, strings, and more.

n8n Version Compatibility

This node has been tested with n8n version 1.0.0 and later.

Installation

  1. Go to Settings > Community Nodes.
  2. Select Install.
  3. Enter n8n-nodes-lodash in the Enter npm package name field.
  4. Agree to the risks of using community nodes.
  5. Click Install.

After installation, the Lodash Function node will be available in the "Transform" section of the nodes panel.

How to Use

The node is designed to be flexible, allowing you to apply any supported Lodash function to your input data.

Node Parameters

  • Category: First, select the category of the Lodash function you want to use (e.g., Array, Object, String).
  • Function: Based on the selected category, this dropdown will show the available Lodash functions.
  • Input Source: Choose where the primary input for the Lodash function comes from:
    • Full Item: Uses the entire incoming JSON item as input.
    • Specific Field: Uses the value of a specific field from the incoming item.
    • Custom Expression: Uses an n8n expression to define the input.
  • Additional Arguments (JSON): Provide any additional arguments required by the Lodash function. The arguments must be formatted as a JSON array. For example, if you are using _.chunk(array, size), the size would be provided here as [2].
  • Output Field: Specify the field name where the result of the Lodash function will be stored. Defaults to result.
  • Keep Input Data: If enabled, the output field will be merged with the original input item. If disabled, the output will be a new item containing only the result.

Example Workflow

Let's say you have an array in your workflow and you want to split it into smaller chunks using _.chunk().

  1. Input Data:
    An upstream node provides the following JSON item:

    {
      "my_array": [1, 2, 3, 4, 5, 6, 7]
    }
    
  2. Lodash Function Node Configuration:

    • Category: Array
    • Function: chunk
    • Input Source: Specific Field
    • Field Name: my_array
    • Additional Arguments (JSON): [3] (This is the size argument for _.chunk)
    • Output Field: chunked_result
  3. Output Data:
    The node will produce the following output:

    {
      "my_array": [1, 2, 3, 4, 5, 6, 7],
      "chunked_result": [
        [1, 2, 3],
        [4, 5, 6],
        [7]
      ]
    }
    

Supported Functions

This node supports a wide variety of Lodash functions, grouped into the following categories directly in the node UI:

  • Array
  • Collection
  • Object
  • String
  • Number
  • Math
  • Util

Resources

License

MIT

Discussion