Array Utilities

Array Repeat

Repeats an array elements a specified number of times, creating a new flattened array. Access via MCP in Cursor or other AI editors, or call GET /v1/array/repeat directly. Pass [1,2,3] with n=2 to get [1,2,3,1,2,3]. Deterministic operation perfect for generating test data or pattern creation in AI workflows.

API Endpoint

GET /v1/array/repeat

Code Examples

curl "https://tinyfn.io/v1/array/repeat" \
  -H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/array/repeat', {
  headers: { 'X-API-Key': 'YOUR_API_KEY' }
});
const data = await response.json();
console.log(data);
import requests

response = requests.get('https://tinyfn.io/v1/array/repeat',
    headers={'X-API-Key': 'YOUR_API_KEY'})
data = response.json()
print(data)

Use via MCP

Add to your AI agent

Connect your AI agent (Claude, Cursor, Windsurf, etc.) to TinyFn's array tools:

{
  "mcpServers": {
    "tinyfn-array": {
      "url": "https://tinyfn.io/mcp/array",
      "headers": {
        "X-API-Key": "YOUR_API_KEY"
      }
    }
  }
}

Learn more about MCP setup →

FAQ

How do I repeat an array multiple times with MCP?

Call the array_repeat tool with your array and repetition count. In Cursor or Claude Code, it returns the flattened result immediately without concatenation guesswork.

What happens when I repeat an array 0 times?

Returns an empty array []. Negative values typically return empty arrays too, following safe default behavior.

Does array repeat work with nested arrays and objects?

Yes, it preserves the exact structure of each element. [[1,2], {a:3}] repeated twice becomes [[1,2], {a:3}, [1,2], {a:3}].

What's the difference between array repeat and string repeat?

Array repeat duplicates entire array contents, while string repeat duplicates individual characters. Use array repeat for collections, string repeat for text patterns.

Can I use array repeat to generate test datasets?

Absolutely. Perfect for creating consistent test data patterns, mock API responses, or repeating configuration blocks in AI-generated code.

Try Array Repeat Now

Get your free API key and start using Array Repeat in seconds.

Get Free API Key