RAS standard library
Arrays
These are array extension methods (ras_array of the RAS standard library). You can use them without importing anything. Only the methods you use are emitted into the VBA module RAS_Array.
export function customerNames(): string[] {
const values = Sheet1.range("A2:A100").toArray().flat(); // 2-D array → 1-D
return values.map(v => `${v}`).filter(s => s != "").unique();
}
Built-in methods such as map / filter / reduce / sort / includes are expanded into loops by the compiler (specification §4). For the range xs[1..^1], the from-end index xs[^1], step(n), toReversed() and transpose(), see the cheat sheet.
Reference
Extension method (T[]) Array.unique
function unique<T>(this: T[]): T[]
A new array without duplicates (in order of first appearance; the original array is unchanged). Elements are compared with == (as in includes).
Example: ["a", "b", "a"].unique() → ["a", "b"]; for the list of values of ws.columns(1).toColumn()
Extension method (T[][]) Array.flat
function flat<T>(this: T[][]): T[]
Flattens a 2-D array into a 1-D array, row by row from the left (the original array is unchanged).
Example: ws.range("A1:C3").toArray().flat() → 9 values