4 min readUpdated Mar 2, 2026

Limit Logic Documentation

Purpose

The "limit" logic in the Vantage analytics and data platform is designed to restrict the quantity of output data in a functional data processing flow. It receives a dataset, processes it according to defined parameters, and returns a truncated version of that dataset based on predefined limits. This is especially useful in scenarios where only a subset of data is needed for analysis, visualization, or other logical operations.

Settings

The "limit" logic contains the following configurable settings:

1. Count

2. Max

How It Works

Upon invocation, the createLimitNode function evaluates the incoming parameters for count and max, ensuring that they meet the required criteria. Specifically, it checks for the type and value of count to ensure that it is a non-negative number, raising an error if it does not meet the criteria.

The function calculates the effective cap for data truncation using the maximum of the provided values. If max is positive and less than count, the cap is set to max. If max is not provided or invalid, it defaults to count. The logic then processes a given array of data, returning a sliced version based on the calculated cap.

Upon execution, if the provided data is not an array, an empty array is returned.

Expected Data

The "limit" logic expects the following type of data:

Use Cases & Examples

Use Case 1: Data Visualization

In a dashboard application, you may want to display the top 10 sales records from a dataset of thousands. The "limit" logic enables truncating the dataset to ensure viewers can see only pertinent information without overwhelming them.

Use Case 2: API Data Pagination

When fetching data from an API, you can implement the "limit" logic to limit the results returned to users. For example, returning a maximum of 50 results at a time enhances performance and usability.

Use Case 3: Data Sampling for Analytics

In a data processing pipeline, you may wish to analyze a sample of data rather than the full dataset to save on computational resources. The "limit" logic allows you to define a fixed number of records you want to work with.

Example Configuration

To implement the "limit" logic in a data processing scenario where we want to return only the top 5 records from a dataset of sales transactions:

javascript
const limitNode = createLimitNode({
  count: 5,
  max: 10 // This parameter can be included but will not affect the output since count is lower.
});

// Sample input data
const salesData = [
  { transactionId: 1, amount: 100 },
  { transactionId: 2, amount: 150 },
  { transactionId: 3, amount: 200 },
  { transactionId: 4, amount: 50 },
  { transactionId: 5, amount: 300 },
  { transactionId: 6, amount: 400 },
];

// Execute logic
const result = limitNode.execute(salesData);
console.log(result);

In this case, result would return the first 5 records from the salesData array, adhering to the constraints set by the count value. If max were specified and less than count, it would adjust accordingly, but given the current example, max does not alter the outcome.