Skip to content

Commit e300eea

Browse files
committed
Added map, push, ternary
1 parent be164b2 commit e300eea

File tree

5 files changed

+24
-3
lines changed

5 files changed

+24
-3
lines changed

src/Compiler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,10 @@ export function compileFilesWithOptions(fileNames: string[], options: CompilerOp
9797
});
9898

9999
// Copy lualib to target dir
100-
fs.copyFileSync(
100+
/*fs.copyFileSync(
101101
path.resolve(__dirname, "../dist/lualib/typescript.lua"),
102102
path.join(options.outDir, "typescript_lualib.lua")
103-
);
103+
); */
104104
}
105105

106106
export function createTranspiler(checker: ts.TypeChecker,

src/lualib/ArrayForEach.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
function __TS__ArrayForEach<T>(arr: T[], callbackFn: (value: T, index?: number, array?: any[]) => void) {
1+
function __TS__ArrayForEach<T>(arr: T[], callbackFn: (value: T, index?: number, array?: any[]) => void, thisArg?: any) {
2+
const self = thisArg;
23
for (let i = 0; i < arr.length; i++) {
34
callbackFn(arr[i], i, arr);
45
}

src/lualib/ArrayMap.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
function __TS__ArrayMap<T, U>(arr: T[], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[] {
2+
const self = thisArg;
3+
const newArray: U[] = [];
4+
for (let i = 0; i < arr.length; i++) {
5+
newArray[i] = callbackfn(arr[i], i, arr);
6+
}
7+
return newArray;
8+
}

src/lualib/ArrayPush.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
function __TS__ArrayPush<T>(arr: T[], ...items: T[]) {
2+
for (const item of items) {
3+
arr[arr.length] = item;
4+
}
5+
}

src/lualib/Ternary.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
function __TS__Ternary(condition: any, cb1: () => void, cb2: () => void) {
2+
if (condition) {
3+
cb1();
4+
} else {
5+
cb2();
6+
}
7+
}

0 commit comments

Comments
 (0)