File tree Expand file tree Collapse file tree 4 files changed +22
-5
lines changed
Expand file tree Collapse file tree 4 files changed +22
-5
lines changed Original file line number Diff line number Diff line change 11import { __TS__SparseArray } from "./SparseArray" ;
2+ import { __TS__Unpack } from "./Unpack" ;
23
34export function __TS__SparseArraySpread < T > ( this : void , sparseArray : __TS__SparseArray < T > ) : LuaMultiReturn < T [ ] > {
4- return unpack ( sparseArray , 1 , sparseArray . sparseLength ) ;
5+ return __TS__Unpack ( sparseArray , 1 , sparseArray . sparseLength ) ;
56}
Original file line number Diff line number Diff line change 1- export const __TS__Unpack = unpack ;
1+ /** @noSelfInFile */
2+
3+ // We're not interested in emulating all of the behaviors of unpack() from Lua
4+ // 5.1, just the ones needed by other parts of lualib.
5+ export function __TS__Unpack < T > ( list : T [ ] , i : number , j ?: number ) : LuaMultiReturn < T [ ] > {
6+ if ( i === 1 && j === undefined ) {
7+ return unpack ( list ) ;
8+ } else {
9+ j ??= list . length ;
10+ const slice : T [ ] = [ ] ;
11+ for ( let n = i ; n <= j ; n ++ ) {
12+ slice [ n - i ] = list [ n - 1 ] ; // We don't want to add 1 to the index into list.
13+ }
14+ return $multi ( ...slice ) ;
15+ }
16+ }
Original file line number Diff line number Diff line change @@ -18,9 +18,6 @@ interface LuaClassInstance extends LuaMetatable<any> {
1818 constructor : LuaClass ;
1919}
2020
21- // Declare unpack for versions that have it instead of table.unpack
22- declare const unpack : typeof table . unpack | undefined ;
23-
2421// Declare math atan2 for versions that have it instead of math.atan
2522declare namespace math {
2623 const atan2 : typeof atan ;
Original file line number Diff line number Diff line change 1+ /** @noSelfInFile */
2+
3+ // Declare unpack for versions that have it instead of table.unpack
4+ declare const unpack : typeof table . unpack | undefined ;
You can’t perform that action at this time.
0 commit comments