Epsilon functions allow you to run Javascript functions in a bag as part of your ZAZA.rocks solution.

An Epsilon function has the following structure:

function epsilon(event) {
  return new Response(“Hello world 👋”)
}

Create a global function called 'epsilon'. The function should take an event  parameter and return a Response object.

🤖 Only a string is currently supported as the Response body.
🤖 The event parameter is currently unused. It is a placeholder for passing input.

Epsilon functions are executed on our servers so you don't have to worry about users trying to inspect your code.

Fetch

Epsilon functions can use the Fetch API to access data.

const url = 'https://api.example.com'

epsilon = async (event) => {
  let response = await fetch(url)
  let data = await response.json()

  return new Response(data.theOnlyInterestingValue)
}

This example is already a little more complex. Is shows:

Note the importance of using async/await in this case. If your function returns a promise we will automatically wait for it to resolve. Be careful with using asynchronous logic in your function! If you do not return a promise we can't and therefore don't wait for any asynchronous logic to complete before cleaning up the function.

Libraries

It is possible to use libraries inside an epsilon function. However, we do not support require or other types of import statements. If you want to use libraries you have to bundle all your dependencies into the function using a tool such as browserify or rollup.

🤖 In the future we will provide the ZAZA SDK to Epsilon functions by default.

Virtual files

Currently we feature Epsilon function as a way to provide content to a virtual file. Click 'Add virtual file' and select 'Epsilon'.

Next give your virtual file a name and enter your Epsilon script.

⭐This feature is currently available for Pro and Enterprise bags.

Resource limits

We currently limit the run-time of an epsilon function to 10 seconds.

🤖 These limits are still subject to change.

Did this answer your question?