Skip to main content

Array and string expressions

Shared lookup, slicing, splitting, joining and Unicode case conversion

Native libraries, desktop scripts and browser main/Worker hosts use the shared evaluator.

ExpressionUsage
at['at', index, array]; index must be an in-range nonnegative integer
length['length', stringOrArray]
in['in', item, array], or a substring in a string
index-of['index-of', item, stringOrArray, from?]; -1 when absent
slice['slice', stringOrArray, start, end?]; includes start, excludes end
split/join['split', string, separator] / ['join', array, separator]
upcase/downcaseOne string argument; Unicode case conversion
map.setPaintProperty('points', 'circle-radius', [
  'at', 1, ['get', 'sizes']
]);
await map.sqs.flush({ render: true });

String indices count Unicode code points: a Chinese character or emoji occupies one position. They do not count bytes, UTF-16 units or grapheme clusters; combining marks remain separate. Negative slice indices count from the end and bounds clamp; numeric indices truncate. index-of truncates its start and clamps it to nonnegative; beyond the length returns -1. at rejects fractions and out-of-range indices.

split with an empty separator splits code points; other separators preserve empty parts. join uses shared scalar formatting: null becomes empty, numbers use decimal formatting, composite values use JSON. JavaScript nested-array coercion compatibility is not claimed. Case conversion uses Rust Unicode rules with no locale parameter.

Scans consume the existing 8192-step budget, charged by UTF-8 byte count for strings. join/case output is limited to 4096 bytes; excess returns RESOURCE_LIMIT. Invalid static types reject before mutation; invalid runtime data uses paint defaults/warnings.

The complete HTML exposes four controls and every handler; the shared script covers 13 checks. Syntax follows the public MapLibre specification; SqsMap implements its own evaluator. Locale sorting/formatting, special values and remaining expressions stay in the task list. Device verification is recorded separately.

Common join now fixes nested array/object conversion while preserving split and budgets; seejoin value conversion.