-
-
Notifications
You must be signed in to change notification settings - Fork 184
Expand file tree
/
Copy pathSpread.ts
More file actions
15 lines (15 loc) · 441 Bytes
/
Spread.ts
File metadata and controls
15 lines (15 loc) · 441 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
export function __TS__Spread<T>(this: void, iterable: string | Iterable<T>): LuaMultiReturn<T[]> {
const arr: T[] = [];
if (typeof iterable === "string") {
for (const i of $range(0, iterable.length - 1)) {
arr[i] = iterable[i] as T;
}
} else {
let len = 0;
for (const item of iterable) {
len++;
arr[len - 1] = item;
}
}
return $multi(...arr);
}