Array Utilities

Array Fill

Generate arrays populated with repeated values using `/v1/array/fill`. Specify length and fill value to create consistent datasets for testing, initialization, or placeholder content. Returns `[0, 0, 0, 0, 0]` when called with length 5 and value 0. Perfect for AI agents building mock data or initializing arrays in Cursor and other MCP-enabled editors.

API Endpoint

GET /v1/array/fill

Code Examples

curl "https://tinyfn.io/v1/array/fill" \
  -H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/array/fill', {
  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/fill',
    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 create an array filled with the same value?

Call `/v1/array/fill` with length and value parameters. For example, length=3 and value='test' returns ['test', 'test', 'test'].

What data types can I use as fill values?

Supports strings, numbers, booleans, and null. Complex objects or arrays as fill values depend on the specific implementation.

Can MCP tools use this to generate test data arrays?

Yes, AI agents in Cursor or Windsurf can call this tool to create consistent arrays for unit tests, mock datasets, or initialization.

What happens if I specify a length of 0?

Returns an empty array `[]`. Negative lengths typically return empty arrays or throw validation errors depending on implementation.

How does this compare to JavaScript's Array.fill()?

Similar functionality but accessible via REST API and MCP. Useful when you need deterministic array creation outside JavaScript runtime environments.

Try Array Fill Now

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

Get Free API Key