Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

192
Vistas
Wrap generic expressions into a function

I am part of n8n.io, an open source project, and we're looking for a way to help our users manipulate data.

Our tool allows users to get data from any source (database, http requests, queue services, etc), manipulate and do other stuff, such as send an email, create a lead on Hubspot, etc. It's a workflow automation tool.

We already provide ways for our users to map data from one place to another, such as get a username from a database and send it as the Lead's name to Hubspot. But users may want to manipulate this data before sending.

We want to add helper functions for this.

Our users can already use a template engine to make some interesting stuff, such as:

{{ username.toUpperCase() }}

Given that username in the example above is a string, and the toUpperCase() is the native string function.

We would like to extend this behavior. Add more functionality. For instance, something like {{ email.isEmail() ? email : '' }} where isEmail is a new function we would like to provide and email is simply a string.

One important note is that we would like these functions to be chainable instead of simply functions to avoid parenthesis hell.

I thought about extending the native prototypes, but this comes with a lot of side effects, especially because we also want to extend Object properties (with functions such as .hasField('username') or .removeField('name'). Extending prototypes ended up breaking a lot of stuff, so we cannot follow this path.

Also users can do math operations, such as {{ (age + 5) / 2 }}, so we need operations that work over numbers, strings, objects and arrays.

I would appreciate any ideas on how to achieve this: providing functions that can be chained to manipulate data.

We would like to avoid forcing our users to wrap their data in a helper function, like {{ _(name).firstName().toUpperCase() }}. In this case, we would implement the _ function as a helper and have all methods implemented inside of it, depending on the data type.

Is there a way to wrap any expression into a helper function, such as the above mentioned? A regular expression that is fail proof would be amazing.

Please bear in mind that expressions can be very arbitrary, such as:

{{ (5
+
2

).isPrime
() ? 'This is prime' : 42
}}

The above example is a perfectly valid expression, and my goal is to wrap the section (5+2) in our helper function so it the final result, before dispatching to our template engine, should look like this:

{{ _((5
+
2

)).isPrime
() ? 'This is prime' : 42
}}
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda