# Functions

Functions are self-contained blocks of code that can be invoked at any point to compute and retrieve specific data or results. Supernova comes with dozens of pre-defined functions that help you to obtain the data from the [Design System Model](/supernova-dsm/design-system-data.md) and some that help with additional tasks such as comparing values to other values, generating random test data, and many more.

### Syntax

Each function call starts with `@` symbol and is invoked using `()` brackets. For example, this is how you obtain all the data about all the tokens inside targeted design system:

```
{[ let tokens = @ds.allTokens() /]}
```

This creates a new variable `tokens` that is filled with data about all the screens in the current project. Function `allTokens` doesn't take any input parameters, so its invoked only with `()`.

### Input parameters

In some cases, functions require input parameters to be provided. For example, this is how you obtain data about a specific screen in the current project:

```
{[ let token = @ds.tokenById(tokenId) /]}
```

This again creates a new variable `token` that is filled with data about a specific token. We have specified which token by providing `tokenId` to the function call.

### Multiple input arguments

Some functions also require more than just one input argument. In this case, you separate them with `,` . Note that spaces between arguments are ignored, so we recommend writing them after each separator, which helps readability a lot:

```
{[ let result = @multiArgumentFunction(arg1, arg2)
```

### Variadic functions

Some functions you'll encounter are variadic. This means that they take any number of input parameters and they all contribute to the output of the function. A good example is `@boolean.and` function used for boolean operations:

```
{[ let isPartialSuccess @boolean.and(result1, result2) /]}
{[ let isSuccess @boolean.and(result1, result2, result3, result4) /]}
```

`@boolean.and` is a variadic function and you can use it to test whether all parameters are true - be it 2 in the first definition, or 4 in the second one.

### Custom functionality

Missing some functionality Pulsar is not covering? You can extend the language capabilities by using javascript and provide your own [functions](/supernova-dsm/pulsar-language/functions.md), [transformers](/supernova-dsm/pulsar-language/transformers.md), or even test and configuration data. We dedicate an entire chapter to this topic.

{% content-ref url="/pages/-MWYlOJBFVNhkDvrNEdC" %}
[Using Javascript](/supernova-dsm/building-exporters/creating-new-exporter/using-javascript.md)
{% endcontent-ref %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://supernova-developers.gitbook.io/supernova-dsm/pulsar-language/functions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
