typescript-to-lua 1.1.1 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/dist/LuaAST.d.ts +1 -0
- package/dist/LuaAST.js +10 -2
- package/dist/LuaLib.d.ts +4 -3
- package/dist/LuaLib.js +6 -5
- package/dist/LuaPrinter.d.ts +11 -4
- package/dist/LuaPrinter.js +58 -15
- package/dist/lualib/ArrayFlat.lua +1 -1
- package/dist/lualib/ArrayFlatMap.lua +1 -1
- package/dist/lualib/ArrayIsArray.lua +1 -1
- package/dist/lualib/ArrayReduce.lua +7 -1
- package/dist/lualib/ArrayReduceRight.lua +7 -1
- package/dist/lualib/ArraySetLength.lua +1 -1
- package/dist/lualib/ArraySplice.lua +5 -5
- package/dist/lualib/Await.lua +21 -13
- package/dist/lualib/CloneDescriptor.lua +7 -7
- package/dist/lualib/Decorate.lua +1 -1
- package/dist/lualib/DelegatedYield.lua +1 -3
- package/dist/lualib/Delete.lua +6 -6
- package/dist/lualib/Error.lua +47 -44
- package/dist/lualib/Generator.lua +1 -5
- package/dist/lualib/InstanceOf.lua +1 -1
- package/dist/lualib/InstanceOfObject.lua +1 -1
- package/dist/lualib/Map.lua +130 -134
- package/dist/lualib/MathSign.lua +8 -0
- package/dist/lualib/Number.lua +1 -1
- package/dist/lualib/NumberIsFinite.lua +1 -1
- package/dist/lualib/NumberToString.lua +3 -5
- package/dist/lualib/ObjectDefineProperty.lua +40 -8
- package/dist/lualib/ParseFloat.lua +9 -5
- package/dist/lualib/ParseInt.lua +15 -3
- package/dist/lualib/Promise.lua +28 -24
- package/dist/lualib/Set.lua +119 -123
- package/dist/lualib/SetDescriptor.lua +7 -1
- package/dist/lualib/SourceMapTraceBack.lua +1 -1
- package/dist/lualib/SparseArrayNew.lua +5 -0
- package/dist/lualib/SparseArrayPush.lua +9 -0
- package/dist/lualib/SparseArraySpread.lua +4 -0
- package/dist/lualib/StringAccess.lua +1 -1
- package/dist/lualib/StringCharCodeAt.lua +1 -1
- package/dist/lualib/StringEndsWith.lua +2 -2
- package/dist/lualib/StringPadEnd.lua +2 -2
- package/dist/lualib/StringPadStart.lua +2 -2
- package/dist/lualib/StringReplace.lua +7 -1
- package/dist/lualib/StringSlice.lua +2 -2
- package/dist/lualib/StringSplit.lua +3 -3
- package/dist/lualib/StringStartsWith.lua +1 -1
- package/dist/lualib/StringSubstr.lua +1 -1
- package/dist/lualib/StringSubstring.lua +2 -2
- package/dist/lualib/Symbol.lua +3 -5
- package/dist/lualib/WeakMap.lua +40 -42
- package/dist/lualib/WeakSet.lua +36 -38
- package/dist/lualib/lualib_bundle.lua +804 -735
- package/dist/transformation/builtins/array.js +1 -2
- package/dist/transformation/builtins/function.js +6 -4
- package/dist/transformation/builtins/index.d.ts +1 -1
- package/dist/transformation/builtins/index.js +41 -6
- package/dist/transformation/builtins/math.js +7 -1
- package/dist/transformation/builtins/object.d.ts +2 -1
- package/dist/transformation/builtins/object.js +1 -2
- package/dist/transformation/builtins/string.js +1 -2
- package/dist/transformation/context/context.d.ts +12 -0
- package/dist/transformation/context/context.js +102 -3
- package/dist/transformation/utils/diagnostics.d.ts +9 -6
- package/dist/transformation/utils/diagnostics.js +4 -3
- package/dist/transformation/utils/language-extensions.d.ts +2 -0
- package/dist/transformation/utils/language-extensions.js +7 -1
- package/dist/transformation/utils/lua-ast.d.ts +0 -1
- package/dist/transformation/utils/lua-ast.js +14 -23
- package/dist/transformation/utils/preceding-statements.d.ts +3 -0
- package/dist/transformation/utils/preceding-statements.js +11 -0
- package/dist/transformation/utils/safe-names.d.ts +4 -2
- package/dist/transformation/utils/safe-names.js +11 -5
- package/dist/transformation/utils/scope.d.ts +3 -1
- package/dist/transformation/utils/scope.js +9 -1
- package/dist/transformation/utils/typescript/index.d.ts +1 -0
- package/dist/transformation/utils/typescript/index.js +16 -1
- package/dist/transformation/utils/typescript/types.d.ts +3 -1
- package/dist/transformation/utils/typescript/types.js +40 -13
- package/dist/transformation/visitors/access.d.ts +3 -0
- package/dist/transformation/visitors/access.js +63 -36
- package/dist/transformation/visitors/binary-expression/assignments.d.ts +3 -2
- package/dist/transformation/visitors/binary-expression/assignments.js +66 -57
- package/dist/transformation/visitors/binary-expression/compound.d.ts +5 -4
- package/dist/transformation/visitors/binary-expression/compound.js +66 -68
- package/dist/transformation/visitors/binary-expression/destructuring-assignments.d.ts +2 -2
- package/dist/transformation/visitors/binary-expression/destructuring-assignments.js +54 -25
- package/dist/transformation/visitors/binary-expression/index.d.ts +3 -1
- package/dist/transformation/visitors/binary-expression/index.js +65 -23
- package/dist/transformation/visitors/call.d.ts +3 -2
- package/dist/transformation/visitors/call.js +95 -141
- package/dist/transformation/visitors/class/index.js +5 -8
- package/dist/transformation/visitors/class/members/constructor.js +3 -1
- package/dist/transformation/visitors/class/new.js +4 -6
- package/dist/transformation/visitors/conditional.js +30 -37
- package/dist/transformation/visitors/delete.js +4 -0
- package/dist/transformation/visitors/errors.js +11 -9
- package/dist/transformation/visitors/expression-list.d.ts +7 -0
- package/dist/transformation/visitors/expression-list.js +120 -0
- package/dist/transformation/visitors/expression-statement.d.ts +3 -1
- package/dist/transformation/visitors/expression-statement.js +21 -19
- package/dist/transformation/visitors/function.d.ts +2 -0
- package/dist/transformation/visitors/function.js +63 -13
- package/dist/transformation/visitors/identifier.js +5 -0
- package/dist/transformation/visitors/language-extensions/index.d.ts +4 -0
- package/dist/transformation/visitors/language-extensions/index.js +17 -0
- package/dist/transformation/visitors/language-extensions/operators.d.ts +1 -1
- package/dist/transformation/visitors/language-extensions/operators.js +7 -2
- package/dist/transformation/visitors/language-extensions/pairsIterable.d.ts +5 -0
- package/dist/transformation/visitors/language-extensions/pairsIterable.js +53 -0
- package/dist/transformation/visitors/language-extensions/table.d.ts +1 -8
- package/dist/transformation/visitors/language-extensions/table.js +55 -53
- package/dist/transformation/visitors/literal.js +69 -16
- package/dist/transformation/visitors/loops/do-while.js +34 -8
- package/dist/transformation/visitors/loops/for-of.js +4 -0
- package/dist/transformation/visitors/loops/for.js +25 -5
- package/dist/transformation/visitors/loops/utils.d.ts +1 -0
- package/dist/transformation/visitors/loops/utils.js +19 -3
- package/dist/transformation/visitors/modules/export.js +1 -1
- package/dist/transformation/visitors/namespace.js +1 -1
- package/dist/transformation/visitors/optional-chaining.d.ts +16 -0
- package/dist/transformation/visitors/optional-chaining.js +172 -0
- package/dist/transformation/visitors/sourceFile.js +4 -1
- package/dist/transformation/visitors/spread.js +14 -7
- package/dist/transformation/visitors/switch.js +29 -9
- package/dist/transformation/visitors/template.js +5 -2
- package/dist/transformation/visitors/typeof.js +3 -1
- package/dist/transformation/visitors/variable-declaration.js +37 -8
- package/dist/transformation/visitors/void.d.ts +1 -4
- package/dist/transformation/visitors/void.js +7 -12
- package/dist/transpilation/transformers.js +4 -1
- package/dist/transpilation/utils.js +2 -1
- package/language-extensions/index.d.ts +11 -1
- package/package.json +5 -5
- package/dist/lualib/OptionalChainAccess.lua +0 -6
- package/dist/lualib/OptionalFunctionCall.lua +0 -6
- package/dist/lualib/OptionalMethodCall.lua +0 -11
- package/dist/transformation/utils/transform.d.ts +0 -8
- package/dist/transformation/utils/transform.js +0 -14
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function __TS__ArrayIsArray(value)
|
|
2
|
-
return
|
|
2
|
+
return type(value) == "table" and (value[1] ~= nil or next(value, nil) == nil)
|
|
3
3
|
end
|
|
4
4
|
|
|
5
5
|
function __TS__ArrayConcat(arr1, ...)
|
|
@@ -199,7 +199,13 @@ function __TS__ArrayReduce(arr, callbackFn, ...)
|
|
|
199
199
|
error("Reduce of empty array with no initial value", 0)
|
|
200
200
|
end
|
|
201
201
|
for i = k, len - 1 do
|
|
202
|
-
accumulator = callbackFn(
|
|
202
|
+
accumulator = callbackFn(
|
|
203
|
+
_G,
|
|
204
|
+
accumulator,
|
|
205
|
+
arr[i + 1],
|
|
206
|
+
i,
|
|
207
|
+
arr
|
|
208
|
+
)
|
|
203
209
|
end
|
|
204
210
|
return accumulator
|
|
205
211
|
end
|
|
@@ -217,7 +223,13 @@ function __TS__ArrayReduceRight(arr, callbackFn, ...)
|
|
|
217
223
|
error("Reduce of empty array with no initial value", 0)
|
|
218
224
|
end
|
|
219
225
|
for i = k, 0, -1 do
|
|
220
|
-
accumulator = callbackFn(
|
|
226
|
+
accumulator = callbackFn(
|
|
227
|
+
_G,
|
|
228
|
+
accumulator,
|
|
229
|
+
arr[i + 1],
|
|
230
|
+
i,
|
|
231
|
+
arr
|
|
232
|
+
)
|
|
221
233
|
end
|
|
222
234
|
return accumulator
|
|
223
235
|
end
|
|
@@ -342,7 +354,7 @@ function __TS__ArraySplice(list, ...)
|
|
|
342
354
|
if itemCount < actualDeleteCount then
|
|
343
355
|
do
|
|
344
356
|
local k = actualStart
|
|
345
|
-
while k <
|
|
357
|
+
while k < len - actualDeleteCount do
|
|
346
358
|
local from = k + actualDeleteCount
|
|
347
359
|
local to = k + itemCount
|
|
348
360
|
if list[from + 1] then
|
|
@@ -355,7 +367,7 @@ function __TS__ArraySplice(list, ...)
|
|
|
355
367
|
end
|
|
356
368
|
do
|
|
357
369
|
local k = len
|
|
358
|
-
while k >
|
|
370
|
+
while k > len - actualDeleteCount + itemCount do
|
|
359
371
|
list[k] = nil
|
|
360
372
|
k = k - 1
|
|
361
373
|
end
|
|
@@ -364,8 +376,8 @@ function __TS__ArraySplice(list, ...)
|
|
|
364
376
|
do
|
|
365
377
|
local k = len - actualDeleteCount
|
|
366
378
|
while k > actualStart do
|
|
367
|
-
local from =
|
|
368
|
-
local to =
|
|
379
|
+
local from = k + actualDeleteCount - 1
|
|
380
|
+
local to = k + itemCount - 1
|
|
369
381
|
if list[from + 1] then
|
|
370
382
|
list[to + 1] = list[from + 1]
|
|
371
383
|
else
|
|
@@ -382,7 +394,7 @@ function __TS__ArraySplice(list, ...)
|
|
|
382
394
|
end
|
|
383
395
|
do
|
|
384
396
|
local k = #list - 1
|
|
385
|
-
while k >=
|
|
397
|
+
while k >= len - actualDeleteCount + itemCount do
|
|
386
398
|
list[k + 1] = nil
|
|
387
399
|
k = k - 1
|
|
388
400
|
end
|
|
@@ -408,7 +420,7 @@ function __TS__ArrayFlat(array, depth)
|
|
|
408
420
|
end
|
|
409
421
|
local result = {}
|
|
410
422
|
for ____, value in ipairs(array) do
|
|
411
|
-
if
|
|
423
|
+
if depth > 0 and __TS__ArrayIsArray(value) then
|
|
412
424
|
result = __TS__ArrayConcat(
|
|
413
425
|
result,
|
|
414
426
|
__TS__ArrayFlat(value, depth - 1)
|
|
@@ -426,7 +438,7 @@ function __TS__ArrayFlatMap(array, callback)
|
|
|
426
438
|
local i = 0
|
|
427
439
|
while i < #array do
|
|
428
440
|
local value = callback(_G, array[i + 1], i, array)
|
|
429
|
-
if
|
|
441
|
+
if type(value) == "table" and __TS__ArrayIsArray(value) then
|
|
430
442
|
result = __TS__ArrayConcat(result, value)
|
|
431
443
|
else
|
|
432
444
|
result[#result + 1] = value
|
|
@@ -438,7 +450,7 @@ function __TS__ArrayFlatMap(array, callback)
|
|
|
438
450
|
end
|
|
439
451
|
|
|
440
452
|
function __TS__ArraySetLength(arr, length)
|
|
441
|
-
if
|
|
453
|
+
if length < 0 or length ~= length or length == math.huge or math.floor(length) ~= length then
|
|
442
454
|
error(
|
|
443
455
|
"invalid array length: " .. tostring(length),
|
|
444
456
|
0
|
|
@@ -454,11 +466,9 @@ function __TS__ArraySetLength(arr, length)
|
|
|
454
466
|
return length
|
|
455
467
|
end
|
|
456
468
|
|
|
457
|
-
____symbolMetatable = {
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
end
|
|
461
|
-
}
|
|
469
|
+
____symbolMetatable = {__tostring = function(self)
|
|
470
|
+
return ("Symbol(" .. (self.description or "")) .. ")"
|
|
471
|
+
end}
|
|
462
472
|
function __TS__Symbol(description)
|
|
463
473
|
return setmetatable({description = description}, ____symbolMetatable)
|
|
464
474
|
end
|
|
@@ -474,7 +484,7 @@ function __TS__InstanceOf(obj, classTbl)
|
|
|
474
484
|
error("Right-hand side of 'instanceof' is not an object", 0)
|
|
475
485
|
end
|
|
476
486
|
if classTbl[Symbol.hasInstance] ~= nil then
|
|
477
|
-
return not
|
|
487
|
+
return not not classTbl[Symbol.hasInstance](classTbl, obj)
|
|
478
488
|
end
|
|
479
489
|
if type(obj) == "table" then
|
|
480
490
|
local luaClass = obj.constructor
|
|
@@ -494,30 +504,244 @@ function __TS__New(target, ...)
|
|
|
494
504
|
return instance
|
|
495
505
|
end
|
|
496
506
|
|
|
507
|
+
function __TS__Class(self)
|
|
508
|
+
local c = {prototype = {}}
|
|
509
|
+
c.prototype.__index = c.prototype
|
|
510
|
+
c.prototype.constructor = c
|
|
511
|
+
return c
|
|
512
|
+
end
|
|
513
|
+
|
|
514
|
+
__TS__Unpack = table.unpack or unpack
|
|
515
|
+
|
|
516
|
+
function __TS__FunctionBind(fn, thisArg, ...)
|
|
517
|
+
local boundArgs = {...}
|
|
518
|
+
return function(____, ...)
|
|
519
|
+
local args = {...}
|
|
520
|
+
do
|
|
521
|
+
local i = 0
|
|
522
|
+
while i < #boundArgs do
|
|
523
|
+
table.insert(args, i + 1, boundArgs[i + 1])
|
|
524
|
+
i = i + 1
|
|
525
|
+
end
|
|
526
|
+
end
|
|
527
|
+
return fn(
|
|
528
|
+
thisArg,
|
|
529
|
+
__TS__Unpack(args)
|
|
530
|
+
)
|
|
531
|
+
end
|
|
532
|
+
end
|
|
533
|
+
|
|
534
|
+
__TS__PromiseState = __TS__PromiseState or ({})
|
|
535
|
+
__TS__PromiseState.Pending = 0
|
|
536
|
+
__TS__PromiseState[__TS__PromiseState.Pending] = "Pending"
|
|
537
|
+
__TS__PromiseState.Fulfilled = 1
|
|
538
|
+
__TS__PromiseState[__TS__PromiseState.Fulfilled] = "Fulfilled"
|
|
539
|
+
__TS__PromiseState.Rejected = 2
|
|
540
|
+
__TS__PromiseState[__TS__PromiseState.Rejected] = "Rejected"
|
|
541
|
+
function __TS__PromiseDeferred(self)
|
|
542
|
+
local resolve
|
|
543
|
+
local reject
|
|
544
|
+
local promise = __TS__New(
|
|
545
|
+
__TS__Promise,
|
|
546
|
+
function(____, res, rej)
|
|
547
|
+
resolve = res
|
|
548
|
+
reject = rej
|
|
549
|
+
end
|
|
550
|
+
)
|
|
551
|
+
return {promise = promise, resolve = resolve, reject = reject}
|
|
552
|
+
end
|
|
553
|
+
function __TS__IsPromiseLike(self, thing)
|
|
554
|
+
return __TS__InstanceOf(thing, __TS__Promise)
|
|
555
|
+
end
|
|
556
|
+
__TS__Promise = __TS__Class()
|
|
557
|
+
__TS__Promise.name = "__TS__Promise"
|
|
558
|
+
function __TS__Promise.prototype.____constructor(self, executor)
|
|
559
|
+
self.state = __TS__PromiseState.Pending
|
|
560
|
+
self.fulfilledCallbacks = {}
|
|
561
|
+
self.rejectedCallbacks = {}
|
|
562
|
+
self.finallyCallbacks = {}
|
|
563
|
+
do
|
|
564
|
+
local function ____catch(e)
|
|
565
|
+
self:reject(e)
|
|
566
|
+
end
|
|
567
|
+
local ____try, ____hasReturned = pcall(function()
|
|
568
|
+
executor(
|
|
569
|
+
_G,
|
|
570
|
+
__TS__FunctionBind(self.resolve, self),
|
|
571
|
+
__TS__FunctionBind(self.reject, self)
|
|
572
|
+
)
|
|
573
|
+
end)
|
|
574
|
+
if not ____try then
|
|
575
|
+
____catch(____hasReturned)
|
|
576
|
+
end
|
|
577
|
+
end
|
|
578
|
+
end
|
|
579
|
+
function __TS__Promise.resolve(data)
|
|
580
|
+
local promise = __TS__New(
|
|
581
|
+
__TS__Promise,
|
|
582
|
+
function()
|
|
583
|
+
end
|
|
584
|
+
)
|
|
585
|
+
promise.state = __TS__PromiseState.Fulfilled
|
|
586
|
+
promise.value = data
|
|
587
|
+
return promise
|
|
588
|
+
end
|
|
589
|
+
function __TS__Promise.reject(reason)
|
|
590
|
+
local promise = __TS__New(
|
|
591
|
+
__TS__Promise,
|
|
592
|
+
function()
|
|
593
|
+
end
|
|
594
|
+
)
|
|
595
|
+
promise.state = __TS__PromiseState.Rejected
|
|
596
|
+
promise.rejectionReason = reason
|
|
597
|
+
return promise
|
|
598
|
+
end
|
|
599
|
+
__TS__Promise.prototype["then"] = function(self, onFulfilled, onRejected)
|
|
600
|
+
local ____TS__PromiseDeferred_result_0 = __TS__PromiseDeferred(_G)
|
|
601
|
+
local promise = ____TS__PromiseDeferred_result_0.promise
|
|
602
|
+
local resolve = ____TS__PromiseDeferred_result_0.resolve
|
|
603
|
+
local reject = ____TS__PromiseDeferred_result_0.reject
|
|
604
|
+
local isFulfilled = self.state == __TS__PromiseState.Fulfilled
|
|
605
|
+
local isRejected = self.state == __TS__PromiseState.Rejected
|
|
606
|
+
if onFulfilled then
|
|
607
|
+
local internalCallback = self:createPromiseResolvingCallback(onFulfilled, resolve, reject)
|
|
608
|
+
__TS__ArrayPush(self.fulfilledCallbacks, internalCallback)
|
|
609
|
+
if isFulfilled then
|
|
610
|
+
internalCallback(_G, self.value)
|
|
611
|
+
end
|
|
612
|
+
else
|
|
613
|
+
__TS__ArrayPush(
|
|
614
|
+
self.fulfilledCallbacks,
|
|
615
|
+
function() return resolve(_G, nil) end
|
|
616
|
+
)
|
|
617
|
+
end
|
|
618
|
+
if onRejected then
|
|
619
|
+
local internalCallback = self:createPromiseResolvingCallback(onRejected, resolve, reject)
|
|
620
|
+
__TS__ArrayPush(self.rejectedCallbacks, internalCallback)
|
|
621
|
+
if isRejected then
|
|
622
|
+
internalCallback(_G, self.rejectionReason)
|
|
623
|
+
end
|
|
624
|
+
end
|
|
625
|
+
if isFulfilled then
|
|
626
|
+
resolve(_G, self.value)
|
|
627
|
+
end
|
|
628
|
+
if isRejected then
|
|
629
|
+
reject(_G, self.rejectionReason)
|
|
630
|
+
end
|
|
631
|
+
return promise
|
|
632
|
+
end
|
|
633
|
+
function __TS__Promise.prototype.catch(self, onRejected)
|
|
634
|
+
return self["then"](self, nil, onRejected)
|
|
635
|
+
end
|
|
636
|
+
function __TS__Promise.prototype.finally(self, onFinally)
|
|
637
|
+
if onFinally then
|
|
638
|
+
__TS__ArrayPush(self.finallyCallbacks, onFinally)
|
|
639
|
+
if self.state ~= __TS__PromiseState.Pending then
|
|
640
|
+
onFinally(_G)
|
|
641
|
+
end
|
|
642
|
+
end
|
|
643
|
+
return self
|
|
644
|
+
end
|
|
645
|
+
function __TS__Promise.prototype.resolve(self, data)
|
|
646
|
+
if __TS__InstanceOf(data, __TS__Promise) then
|
|
647
|
+
data["then"](
|
|
648
|
+
data,
|
|
649
|
+
function(____, v) return self:resolve(v) end,
|
|
650
|
+
function(____, err) return self:reject(err) end
|
|
651
|
+
)
|
|
652
|
+
return
|
|
653
|
+
end
|
|
654
|
+
if self.state == __TS__PromiseState.Pending then
|
|
655
|
+
self.state = __TS__PromiseState.Fulfilled
|
|
656
|
+
self.value = data
|
|
657
|
+
for ____, callback in ipairs(self.fulfilledCallbacks) do
|
|
658
|
+
callback(_G, data)
|
|
659
|
+
end
|
|
660
|
+
for ____, callback in ipairs(self.finallyCallbacks) do
|
|
661
|
+
callback(_G)
|
|
662
|
+
end
|
|
663
|
+
end
|
|
664
|
+
end
|
|
665
|
+
function __TS__Promise.prototype.reject(self, reason)
|
|
666
|
+
if self.state == __TS__PromiseState.Pending then
|
|
667
|
+
self.state = __TS__PromiseState.Rejected
|
|
668
|
+
self.rejectionReason = reason
|
|
669
|
+
for ____, callback in ipairs(self.rejectedCallbacks) do
|
|
670
|
+
callback(_G, reason)
|
|
671
|
+
end
|
|
672
|
+
for ____, callback in ipairs(self.finallyCallbacks) do
|
|
673
|
+
callback(_G)
|
|
674
|
+
end
|
|
675
|
+
end
|
|
676
|
+
end
|
|
677
|
+
function __TS__Promise.prototype.createPromiseResolvingCallback(self, f, resolve, reject)
|
|
678
|
+
return function(____, value)
|
|
679
|
+
do
|
|
680
|
+
local function ____catch(e)
|
|
681
|
+
reject(_G, e)
|
|
682
|
+
end
|
|
683
|
+
local ____try, ____hasReturned = pcall(function()
|
|
684
|
+
self:handleCallbackData(
|
|
685
|
+
f(_G, value),
|
|
686
|
+
resolve,
|
|
687
|
+
reject
|
|
688
|
+
)
|
|
689
|
+
end)
|
|
690
|
+
if not ____try then
|
|
691
|
+
____catch(____hasReturned)
|
|
692
|
+
end
|
|
693
|
+
end
|
|
694
|
+
end
|
|
695
|
+
end
|
|
696
|
+
function __TS__Promise.prototype.handleCallbackData(self, data, resolve, reject)
|
|
697
|
+
if __TS__IsPromiseLike(_G, data) then
|
|
698
|
+
local nextpromise = data
|
|
699
|
+
if nextpromise.state == __TS__PromiseState.Fulfilled then
|
|
700
|
+
resolve(_G, nextpromise.value)
|
|
701
|
+
elseif nextpromise.state == __TS__PromiseState.Rejected then
|
|
702
|
+
reject(_G, nextpromise.rejectionReason)
|
|
703
|
+
else
|
|
704
|
+
data["then"](data, resolve, reject)
|
|
705
|
+
end
|
|
706
|
+
else
|
|
707
|
+
resolve(_G, data)
|
|
708
|
+
end
|
|
709
|
+
end
|
|
710
|
+
|
|
497
711
|
function __TS__AsyncAwaiter(generator)
|
|
498
712
|
return __TS__New(
|
|
499
713
|
__TS__Promise,
|
|
500
714
|
function(____, resolve, reject)
|
|
501
715
|
local adopt, fulfilled, rejected, step, asyncCoroutine
|
|
502
716
|
function adopt(self, value)
|
|
503
|
-
|
|
717
|
+
local ____temp_0
|
|
718
|
+
if __TS__InstanceOf(value, __TS__Promise) then
|
|
719
|
+
____temp_0 = value
|
|
720
|
+
else
|
|
721
|
+
____temp_0 = __TS__Promise.resolve(value)
|
|
722
|
+
end
|
|
723
|
+
return ____temp_0
|
|
504
724
|
end
|
|
505
725
|
function fulfilled(self, value)
|
|
506
726
|
local success, errorOrErrorHandler, resultOrError = coroutine.resume(asyncCoroutine, value)
|
|
507
727
|
if success then
|
|
508
728
|
step(_G, resultOrError, errorOrErrorHandler)
|
|
509
729
|
else
|
|
510
|
-
reject(_G,
|
|
730
|
+
reject(_G, errorOrErrorHandler)
|
|
511
731
|
end
|
|
512
732
|
end
|
|
513
733
|
function rejected(self, handler)
|
|
514
734
|
if handler then
|
|
515
735
|
return function(____, value)
|
|
516
|
-
local success,
|
|
736
|
+
local success, hasReturnedOrError, returnedValue = pcall(handler, value)
|
|
517
737
|
if success then
|
|
518
|
-
|
|
738
|
+
if hasReturnedOrError then
|
|
739
|
+
resolve(_G, returnedValue)
|
|
740
|
+
else
|
|
741
|
+
step(_G, hasReturnedOrError, handler)
|
|
742
|
+
end
|
|
519
743
|
else
|
|
520
|
-
reject(_G,
|
|
744
|
+
reject(_G, hasReturnedOrError)
|
|
521
745
|
end
|
|
522
746
|
end
|
|
523
747
|
else
|
|
@@ -530,14 +754,12 @@ function __TS__AsyncAwaiter(generator)
|
|
|
530
754
|
if coroutine.status(asyncCoroutine) == "dead" then
|
|
531
755
|
resolve(_G, result)
|
|
532
756
|
else
|
|
533
|
-
(
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
)
|
|
540
|
-
end)()
|
|
757
|
+
local ____self_1 = adopt(_G, result)
|
|
758
|
+
____self_1["then"](
|
|
759
|
+
____self_1,
|
|
760
|
+
fulfilled,
|
|
761
|
+
rejected(_G, errorHandler)
|
|
762
|
+
)
|
|
541
763
|
end
|
|
542
764
|
end
|
|
543
765
|
asyncCoroutine = coroutine.create(generator)
|
|
@@ -554,13 +776,6 @@ function __TS__Await(errorHandler, thing)
|
|
|
554
776
|
return coroutine.yield(errorHandler, thing)
|
|
555
777
|
end
|
|
556
778
|
|
|
557
|
-
function __TS__Class(self)
|
|
558
|
-
local c = {prototype = {}}
|
|
559
|
-
c.prototype.__index = c.prototype
|
|
560
|
-
c.prototype.constructor = c
|
|
561
|
-
return c
|
|
562
|
-
end
|
|
563
|
-
|
|
564
779
|
function __TS__ClassExtends(target, base)
|
|
565
780
|
target.____super = base
|
|
566
781
|
local staticMetatable = setmetatable({__index = base}, base)
|
|
@@ -587,21 +802,21 @@ function __TS__ClassExtends(target, base)
|
|
|
587
802
|
end
|
|
588
803
|
|
|
589
804
|
function __TS__CloneDescriptor(____bindingPattern0)
|
|
805
|
+
local value
|
|
806
|
+
local writable
|
|
807
|
+
local set
|
|
808
|
+
local get
|
|
809
|
+
local configurable
|
|
590
810
|
local enumerable
|
|
591
811
|
enumerable = ____bindingPattern0.enumerable
|
|
592
|
-
local configurable
|
|
593
812
|
configurable = ____bindingPattern0.configurable
|
|
594
|
-
local get
|
|
595
813
|
get = ____bindingPattern0.get
|
|
596
|
-
local set
|
|
597
814
|
set = ____bindingPattern0.set
|
|
598
|
-
local writable
|
|
599
815
|
writable = ____bindingPattern0.writable
|
|
600
|
-
local value
|
|
601
816
|
value = ____bindingPattern0.value
|
|
602
817
|
local descriptor = {enumerable = enumerable == true, configurable = configurable == true}
|
|
603
|
-
local hasGetterOrSetter =
|
|
604
|
-
local hasValueOrWritableAttribute =
|
|
818
|
+
local hasGetterOrSetter = get ~= nil or set ~= nil
|
|
819
|
+
local hasValueOrWritableAttribute = writable ~= nil or value ~= nil
|
|
605
820
|
if hasGetterOrSetter and hasValueOrWritableAttribute then
|
|
606
821
|
error("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute.", 0)
|
|
607
822
|
end
|
|
@@ -679,7 +894,13 @@ function __TS__SetDescriptor(target, key, desc, isPrototype)
|
|
|
679
894
|
if isPrototype == nil then
|
|
680
895
|
isPrototype = false
|
|
681
896
|
end
|
|
682
|
-
local
|
|
897
|
+
local ____isPrototype_0
|
|
898
|
+
if isPrototype then
|
|
899
|
+
____isPrototype_0 = target
|
|
900
|
+
else
|
|
901
|
+
____isPrototype_0 = getmetatable(target)
|
|
902
|
+
end
|
|
903
|
+
local metatable = ____isPrototype_0
|
|
683
904
|
if not metatable then
|
|
684
905
|
metatable = {}
|
|
685
906
|
setmetatable(target, metatable)
|
|
@@ -724,7 +945,7 @@ function __TS__Decorate(decorators, target, key, desc)
|
|
|
724
945
|
local value = rawget(target, key)
|
|
725
946
|
local descriptor = __TS__ObjectGetOwnPropertyDescriptor(target, key) or ({configurable = true, writable = true, value = value})
|
|
726
947
|
local desc = decorator(_G, target, key, descriptor) or descriptor
|
|
727
|
-
local isSimpleValue =
|
|
948
|
+
local isSimpleValue = desc.configurable == true and desc.writable == true and not desc.get and not desc.set
|
|
728
949
|
if isSimpleValue then
|
|
729
950
|
rawset(target, key, desc.value)
|
|
730
951
|
else
|
|
@@ -759,28 +980,107 @@ function __TS__ObjectGetOwnPropertyDescriptors(object)
|
|
|
759
980
|
return rawget(metatable, "_descriptors") or ({})
|
|
760
981
|
end
|
|
761
982
|
|
|
983
|
+
function __TS__GetErrorStack(self, constructor)
|
|
984
|
+
local level = 1
|
|
985
|
+
while true do
|
|
986
|
+
local info = debug.getinfo(level, "f")
|
|
987
|
+
level = level + 1
|
|
988
|
+
if not info then
|
|
989
|
+
level = 1
|
|
990
|
+
break
|
|
991
|
+
elseif info.func == constructor then
|
|
992
|
+
break
|
|
993
|
+
end
|
|
994
|
+
end
|
|
995
|
+
return debug.traceback(nil, level)
|
|
996
|
+
end
|
|
997
|
+
function __TS__WrapErrorToString(self, getDescription)
|
|
998
|
+
return function(self)
|
|
999
|
+
local description = getDescription(self)
|
|
1000
|
+
local caller = debug.getinfo(3, "f")
|
|
1001
|
+
if _VERSION == "Lua 5.1" or caller and caller.func ~= error then
|
|
1002
|
+
return description
|
|
1003
|
+
else
|
|
1004
|
+
return (tostring(description) .. "\n") .. self.stack
|
|
1005
|
+
end
|
|
1006
|
+
end
|
|
1007
|
+
end
|
|
1008
|
+
function __TS__InitErrorClass(self, Type, name)
|
|
1009
|
+
Type.name = name
|
|
1010
|
+
return setmetatable(
|
|
1011
|
+
Type,
|
|
1012
|
+
{__call = function(____, _self, message) return __TS__New(Type, message) end}
|
|
1013
|
+
)
|
|
1014
|
+
end
|
|
1015
|
+
local ____TS__InitErrorClass_3 = __TS__InitErrorClass
|
|
1016
|
+
local ____G_2 = _G
|
|
1017
|
+
____class_0 = __TS__Class()
|
|
1018
|
+
____class_0.name = ""
|
|
1019
|
+
function ____class_0.prototype.____constructor(self, message)
|
|
1020
|
+
if message == nil then
|
|
1021
|
+
message = ""
|
|
1022
|
+
end
|
|
1023
|
+
self.message = message
|
|
1024
|
+
self.name = "Error"
|
|
1025
|
+
self.stack = __TS__GetErrorStack(_G, self.constructor.new)
|
|
1026
|
+
local metatable = getmetatable(self)
|
|
1027
|
+
if not metatable.__errorToStringPatched then
|
|
1028
|
+
metatable.__errorToStringPatched = true
|
|
1029
|
+
metatable.__tostring = __TS__WrapErrorToString(_G, metatable.__tostring)
|
|
1030
|
+
end
|
|
1031
|
+
end
|
|
1032
|
+
function ____class_0.prototype.__tostring(self)
|
|
1033
|
+
local ____temp_1
|
|
1034
|
+
if self.message ~= "" then
|
|
1035
|
+
____temp_1 = (self.name .. ": ") .. self.message
|
|
1036
|
+
else
|
|
1037
|
+
____temp_1 = self.name
|
|
1038
|
+
end
|
|
1039
|
+
return ____temp_1
|
|
1040
|
+
end
|
|
1041
|
+
Error = ____TS__InitErrorClass_3(____G_2, ____class_0, "Error")
|
|
1042
|
+
for ____, errorName in ipairs({
|
|
1043
|
+
"RangeError",
|
|
1044
|
+
"ReferenceError",
|
|
1045
|
+
"SyntaxError",
|
|
1046
|
+
"TypeError",
|
|
1047
|
+
"URIError"
|
|
1048
|
+
}) do
|
|
1049
|
+
local ____G_7 = _G
|
|
1050
|
+
local ____TS__InitErrorClass_6 = __TS__InitErrorClass
|
|
1051
|
+
local ____G_5 = _G
|
|
1052
|
+
local ____class_4 = __TS__Class()
|
|
1053
|
+
____class_4.name = ____class_4.name
|
|
1054
|
+
__TS__ClassExtends(____class_4, Error)
|
|
1055
|
+
function ____class_4.prototype.____constructor(self, ...)
|
|
1056
|
+
Error.prototype.____constructor(self, ...)
|
|
1057
|
+
self.name = errorName
|
|
1058
|
+
end
|
|
1059
|
+
____G_7[errorName] = ____TS__InitErrorClass_6(____G_5, ____class_4, errorName)
|
|
1060
|
+
end
|
|
1061
|
+
|
|
762
1062
|
function __TS__Delete(target, key)
|
|
763
1063
|
local descriptors = __TS__ObjectGetOwnPropertyDescriptors(target)
|
|
764
1064
|
local descriptor = descriptors[key]
|
|
765
1065
|
if descriptor then
|
|
766
1066
|
if not descriptor.configurable then
|
|
767
1067
|
error(
|
|
768
|
-
(
|
|
1068
|
+
__TS__New(
|
|
1069
|
+
TypeError,
|
|
1070
|
+
((("Cannot delete property " .. tostring(key)) .. " of ") .. tostring(target)) .. "."
|
|
1071
|
+
),
|
|
769
1072
|
0
|
|
770
1073
|
)
|
|
771
1074
|
end
|
|
772
1075
|
descriptors[key] = nil
|
|
773
1076
|
return true
|
|
774
1077
|
end
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
return true
|
|
778
|
-
end
|
|
779
|
-
return false
|
|
1078
|
+
target[key] = nil
|
|
1079
|
+
return true
|
|
780
1080
|
end
|
|
781
1081
|
|
|
782
1082
|
function __TS__StringAccess(self, index)
|
|
783
|
-
if
|
|
1083
|
+
if index >= 0 and index < #self then
|
|
784
1084
|
return string.sub(self, index + 1, index + 1)
|
|
785
1085
|
end
|
|
786
1086
|
end
|
|
@@ -788,9 +1088,7 @@ end
|
|
|
788
1088
|
function __TS__DelegatedYield(iterable)
|
|
789
1089
|
if type(iterable) == "string" then
|
|
790
1090
|
for index = 0, #iterable - 1 do
|
|
791
|
-
coroutine.yield(
|
|
792
|
-
__TS__StringAccess(iterable, index)
|
|
793
|
-
)
|
|
1091
|
+
coroutine.yield(__TS__StringAccess(iterable, index))
|
|
794
1092
|
end
|
|
795
1093
|
elseif iterable.____coroutine ~= nil then
|
|
796
1094
|
local co = iterable.____coroutine
|
|
@@ -822,102 +1120,6 @@ function __TS__DelegatedYield(iterable)
|
|
|
822
1120
|
end
|
|
823
1121
|
end
|
|
824
1122
|
|
|
825
|
-
function __TS__GetErrorStack(self, constructor)
|
|
826
|
-
local level = 1
|
|
827
|
-
while true do
|
|
828
|
-
local info = debug.getinfo(level, "f")
|
|
829
|
-
level = level + 1
|
|
830
|
-
if not info then
|
|
831
|
-
level = 1
|
|
832
|
-
break
|
|
833
|
-
elseif info.func == constructor then
|
|
834
|
-
break
|
|
835
|
-
end
|
|
836
|
-
end
|
|
837
|
-
return debug.traceback(nil, level)
|
|
838
|
-
end
|
|
839
|
-
function __TS__WrapErrorToString(self, getDescription)
|
|
840
|
-
return function(self)
|
|
841
|
-
local description = getDescription(self)
|
|
842
|
-
local caller = debug.getinfo(3, "f")
|
|
843
|
-
if (_VERSION == "Lua 5.1") or (caller and (caller.func ~= error)) then
|
|
844
|
-
return description
|
|
845
|
-
else
|
|
846
|
-
return (tostring(description) .. "\n") .. self.stack
|
|
847
|
-
end
|
|
848
|
-
end
|
|
849
|
-
end
|
|
850
|
-
function __TS__InitErrorClass(self, Type, name)
|
|
851
|
-
Type.name = name
|
|
852
|
-
return setmetatable(
|
|
853
|
-
Type,
|
|
854
|
-
{
|
|
855
|
-
__call = function(____, _self, message) return __TS__New(Type, message) end
|
|
856
|
-
}
|
|
857
|
-
)
|
|
858
|
-
end
|
|
859
|
-
Error = __TS__InitErrorClass(
|
|
860
|
-
_G,
|
|
861
|
-
(function()
|
|
862
|
-
local ____ = __TS__Class()
|
|
863
|
-
____.name = ""
|
|
864
|
-
function ____.prototype.____constructor(self, message)
|
|
865
|
-
if message == nil then
|
|
866
|
-
message = ""
|
|
867
|
-
end
|
|
868
|
-
self.message = message
|
|
869
|
-
self.name = "Error"
|
|
870
|
-
self.stack = __TS__GetErrorStack(_G, self.constructor.new)
|
|
871
|
-
local metatable = getmetatable(self)
|
|
872
|
-
if not metatable.__errorToStringPatched then
|
|
873
|
-
metatable.__errorToStringPatched = true
|
|
874
|
-
metatable.__tostring = __TS__WrapErrorToString(_G, metatable.__tostring)
|
|
875
|
-
end
|
|
876
|
-
end
|
|
877
|
-
function ____.prototype.__tostring(self)
|
|
878
|
-
return (((self.message ~= "") and (function() return (self.name .. ": ") .. self.message end)) or (function() return self.name end))()
|
|
879
|
-
end
|
|
880
|
-
return ____
|
|
881
|
-
end)(),
|
|
882
|
-
"Error"
|
|
883
|
-
)
|
|
884
|
-
for ____, errorName in ipairs({"RangeError", "ReferenceError", "SyntaxError", "TypeError", "URIError"}) do
|
|
885
|
-
_G[errorName] = __TS__InitErrorClass(
|
|
886
|
-
_G,
|
|
887
|
-
(function()
|
|
888
|
-
local ____ = __TS__Class()
|
|
889
|
-
____.name = ____.name
|
|
890
|
-
__TS__ClassExtends(____, Error)
|
|
891
|
-
function ____.prototype.____constructor(self, ...)
|
|
892
|
-
Error.prototype.____constructor(self, ...)
|
|
893
|
-
self.name = errorName
|
|
894
|
-
end
|
|
895
|
-
return ____
|
|
896
|
-
end)(),
|
|
897
|
-
errorName
|
|
898
|
-
)
|
|
899
|
-
end
|
|
900
|
-
|
|
901
|
-
__TS__Unpack = table.unpack or unpack
|
|
902
|
-
|
|
903
|
-
function __TS__FunctionBind(fn, thisArg, ...)
|
|
904
|
-
local boundArgs = {...}
|
|
905
|
-
return function(____, ...)
|
|
906
|
-
local args = {...}
|
|
907
|
-
do
|
|
908
|
-
local i = 0
|
|
909
|
-
while i < #boundArgs do
|
|
910
|
-
table.insert(args, i + 1, boundArgs[i + 1])
|
|
911
|
-
i = i + 1
|
|
912
|
-
end
|
|
913
|
-
end
|
|
914
|
-
return fn(
|
|
915
|
-
thisArg,
|
|
916
|
-
__TS__Unpack(args)
|
|
917
|
-
)
|
|
918
|
-
end
|
|
919
|
-
end
|
|
920
|
-
|
|
921
1123
|
function __TS__GeneratorIterator(self)
|
|
922
1124
|
return self
|
|
923
1125
|
end
|
|
@@ -940,11 +1142,7 @@ function __TS__Generator(fn)
|
|
|
940
1142
|
local args = {...}
|
|
941
1143
|
local argsLength = select("#", ...)
|
|
942
1144
|
return {
|
|
943
|
-
____coroutine = coroutine.create(
|
|
944
|
-
function() return fn(
|
|
945
|
-
(unpack or table.unpack)(args, 1, argsLength)
|
|
946
|
-
) end
|
|
947
|
-
),
|
|
1145
|
+
____coroutine = coroutine.create(function() return fn((unpack or table.unpack)(args, 1, argsLength)) end),
|
|
948
1146
|
[Symbol.iterator] = __TS__GeneratorIterator,
|
|
949
1147
|
next = __TS__GeneratorNext
|
|
950
1148
|
}
|
|
@@ -953,7 +1151,7 @@ end
|
|
|
953
1151
|
|
|
954
1152
|
function __TS__InstanceOfObject(value)
|
|
955
1153
|
local valueType = type(value)
|
|
956
|
-
return
|
|
1154
|
+
return valueType == "table" or valueType == "function"
|
|
957
1155
|
end
|
|
958
1156
|
|
|
959
1157
|
function __TS__IteratorGeneratorStep(self)
|
|
@@ -994,153 +1192,158 @@ function __TS__Iterator(iterable)
|
|
|
994
1192
|
end
|
|
995
1193
|
end
|
|
996
1194
|
|
|
997
|
-
Map = (
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
return
|
|
1008
|
-
end
|
|
1009
|
-
local iterable = entries
|
|
1010
|
-
if iterable[Symbol.iterator] then
|
|
1011
|
-
local iterator = iterable[Symbol.iterator](iterable)
|
|
1012
|
-
while true do
|
|
1013
|
-
local result = iterator:next()
|
|
1014
|
-
if result.done then
|
|
1015
|
-
break
|
|
1016
|
-
end
|
|
1017
|
-
local value = result.value
|
|
1018
|
-
self:set(value[1], value[2])
|
|
1019
|
-
end
|
|
1020
|
-
else
|
|
1021
|
-
local array = entries
|
|
1022
|
-
for ____, kvp in ipairs(array) do
|
|
1023
|
-
self:set(kvp[1], kvp[2])
|
|
1024
|
-
end
|
|
1025
|
-
end
|
|
1195
|
+
Map = __TS__Class()
|
|
1196
|
+
Map.name = "Map"
|
|
1197
|
+
function Map.prototype.____constructor(self, entries)
|
|
1198
|
+
self[Symbol.toStringTag] = "Map"
|
|
1199
|
+
self.items = {}
|
|
1200
|
+
self.size = 0
|
|
1201
|
+
self.nextKey = {}
|
|
1202
|
+
self.previousKey = {}
|
|
1203
|
+
if entries == nil then
|
|
1204
|
+
return
|
|
1026
1205
|
end
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
end
|
|
1035
|
-
function Map.prototype.delete(self, key)
|
|
1036
|
-
local contains = self:has(key)
|
|
1037
|
-
if contains then
|
|
1038
|
-
self.size = self.size - 1
|
|
1039
|
-
local next = self.nextKey[key]
|
|
1040
|
-
local previous = self.previousKey[key]
|
|
1041
|
-
if next and previous then
|
|
1042
|
-
self.nextKey[previous] = next
|
|
1043
|
-
self.previousKey[next] = previous
|
|
1044
|
-
elseif next then
|
|
1045
|
-
self.firstKey = next
|
|
1046
|
-
self.previousKey[next] = nil
|
|
1047
|
-
elseif previous then
|
|
1048
|
-
self.lastKey = previous
|
|
1049
|
-
self.nextKey[previous] = nil
|
|
1050
|
-
else
|
|
1051
|
-
self.firstKey = nil
|
|
1052
|
-
self.lastKey = nil
|
|
1206
|
+
local iterable = entries
|
|
1207
|
+
if iterable[Symbol.iterator] then
|
|
1208
|
+
local iterator = iterable[Symbol.iterator](iterable)
|
|
1209
|
+
while true do
|
|
1210
|
+
local result = iterator:next()
|
|
1211
|
+
if result.done then
|
|
1212
|
+
break
|
|
1053
1213
|
end
|
|
1054
|
-
|
|
1055
|
-
self
|
|
1214
|
+
local value = result.value
|
|
1215
|
+
self:set(value[1], value[2])
|
|
1056
1216
|
end
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1217
|
+
else
|
|
1218
|
+
local array = entries
|
|
1219
|
+
for ____, kvp in ipairs(array) do
|
|
1220
|
+
self:set(kvp[1], kvp[2])
|
|
1221
|
+
end
|
|
1222
|
+
end
|
|
1223
|
+
end
|
|
1224
|
+
function Map.prototype.clear(self)
|
|
1225
|
+
self.items = {}
|
|
1226
|
+
self.nextKey = {}
|
|
1227
|
+
self.previousKey = {}
|
|
1228
|
+
self.firstKey = nil
|
|
1229
|
+
self.lastKey = nil
|
|
1230
|
+
self.size = 0
|
|
1231
|
+
end
|
|
1232
|
+
function Map.prototype.delete(self, key)
|
|
1233
|
+
local contains = self:has(key)
|
|
1234
|
+
if contains then
|
|
1235
|
+
self.size = self.size - 1
|
|
1236
|
+
local next = self.nextKey[key]
|
|
1237
|
+
local previous = self.previousKey[key]
|
|
1238
|
+
if next and previous then
|
|
1239
|
+
self.nextKey[previous] = next
|
|
1240
|
+
self.previousKey[next] = previous
|
|
1241
|
+
elseif next then
|
|
1242
|
+
self.firstKey = next
|
|
1243
|
+
self.previousKey[next] = nil
|
|
1244
|
+
elseif previous then
|
|
1245
|
+
self.lastKey = previous
|
|
1246
|
+
self.nextKey[previous] = nil
|
|
1247
|
+
else
|
|
1248
|
+
self.firstKey = nil
|
|
1249
|
+
self.lastKey = nil
|
|
1065
1250
|
end
|
|
1251
|
+
self.nextKey[key] = nil
|
|
1252
|
+
self.previousKey[key] = nil
|
|
1066
1253
|
end
|
|
1067
|
-
|
|
1068
|
-
|
|
1254
|
+
self.items[key] = nil
|
|
1255
|
+
return contains
|
|
1256
|
+
end
|
|
1257
|
+
function Map.prototype.forEach(self, callback)
|
|
1258
|
+
for ____, key in __TS__Iterator(self:keys()) do
|
|
1259
|
+
callback(_G, self.items[key], key, self)
|
|
1069
1260
|
end
|
|
1070
|
-
|
|
1071
|
-
|
|
1261
|
+
end
|
|
1262
|
+
function Map.prototype.get(self, key)
|
|
1263
|
+
return self.items[key]
|
|
1264
|
+
end
|
|
1265
|
+
function Map.prototype.has(self, key)
|
|
1266
|
+
return self.nextKey[key] ~= nil or self.lastKey == key
|
|
1267
|
+
end
|
|
1268
|
+
function Map.prototype.set(self, key, value)
|
|
1269
|
+
local isNewValue = not self:has(key)
|
|
1270
|
+
if isNewValue then
|
|
1271
|
+
self.size = self.size + 1
|
|
1272
|
+
end
|
|
1273
|
+
self.items[key] = value
|
|
1274
|
+
if self.firstKey == nil then
|
|
1275
|
+
self.firstKey = key
|
|
1276
|
+
self.lastKey = key
|
|
1277
|
+
elseif isNewValue then
|
|
1278
|
+
self.nextKey[self.lastKey] = key
|
|
1279
|
+
self.previousKey[key] = self.lastKey
|
|
1280
|
+
self.lastKey = key
|
|
1072
1281
|
end
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1282
|
+
return self
|
|
1283
|
+
end
|
|
1284
|
+
Map.prototype[Symbol.iterator] = function(self)
|
|
1285
|
+
return self:entries()
|
|
1286
|
+
end
|
|
1287
|
+
function Map.prototype.entries(self)
|
|
1288
|
+
local ____temp_0 = self
|
|
1289
|
+
local items = ____temp_0.items
|
|
1290
|
+
local nextKey = ____temp_0.nextKey
|
|
1291
|
+
local key = self.firstKey
|
|
1292
|
+
return {
|
|
1293
|
+
[Symbol.iterator] = function(self)
|
|
1294
|
+
return self
|
|
1295
|
+
end,
|
|
1296
|
+
next = function(self)
|
|
1297
|
+
local result = {done = not key, value = {key, items[key]}}
|
|
1298
|
+
key = nextKey[key]
|
|
1299
|
+
return result
|
|
1077
1300
|
end
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
self
|
|
1301
|
+
}
|
|
1302
|
+
end
|
|
1303
|
+
function Map.prototype.keys(self)
|
|
1304
|
+
local nextKey = self.nextKey
|
|
1305
|
+
local key = self.firstKey
|
|
1306
|
+
return {
|
|
1307
|
+
[Symbol.iterator] = function(self)
|
|
1308
|
+
return self
|
|
1309
|
+
end,
|
|
1310
|
+
next = function(self)
|
|
1311
|
+
local result = {done = not key, value = key}
|
|
1312
|
+
key = nextKey[key]
|
|
1313
|
+
return result
|
|
1086
1314
|
end
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
end
|
|
1108
|
-
function Map.prototype.keys(self)
|
|
1109
|
-
local nextKey = self.nextKey
|
|
1110
|
-
local key = self.firstKey
|
|
1111
|
-
return {
|
|
1112
|
-
[Symbol.iterator] = function(self)
|
|
1113
|
-
return self
|
|
1114
|
-
end,
|
|
1115
|
-
next = function(self)
|
|
1116
|
-
local result = {done = not key, value = key}
|
|
1117
|
-
key = nextKey[key]
|
|
1118
|
-
return result
|
|
1119
|
-
end
|
|
1120
|
-
}
|
|
1121
|
-
end
|
|
1122
|
-
function Map.prototype.values(self)
|
|
1123
|
-
local ____ = self
|
|
1124
|
-
local items = ____.items
|
|
1125
|
-
local nextKey = ____.nextKey
|
|
1126
|
-
local key = self.firstKey
|
|
1127
|
-
return {
|
|
1128
|
-
[Symbol.iterator] = function(self)
|
|
1129
|
-
return self
|
|
1130
|
-
end,
|
|
1131
|
-
next = function(self)
|
|
1132
|
-
local result = {done = not key, value = items[key]}
|
|
1133
|
-
key = nextKey[key]
|
|
1134
|
-
return result
|
|
1135
|
-
end
|
|
1136
|
-
}
|
|
1137
|
-
end
|
|
1138
|
-
Map[Symbol.species] = Map
|
|
1139
|
-
return Map
|
|
1140
|
-
end)()
|
|
1315
|
+
}
|
|
1316
|
+
end
|
|
1317
|
+
function Map.prototype.values(self)
|
|
1318
|
+
local ____temp_1 = self
|
|
1319
|
+
local items = ____temp_1.items
|
|
1320
|
+
local nextKey = ____temp_1.nextKey
|
|
1321
|
+
local key = self.firstKey
|
|
1322
|
+
return {
|
|
1323
|
+
[Symbol.iterator] = function(self)
|
|
1324
|
+
return self
|
|
1325
|
+
end,
|
|
1326
|
+
next = function(self)
|
|
1327
|
+
local result = {done = not key, value = items[key]}
|
|
1328
|
+
key = nextKey[key]
|
|
1329
|
+
return result
|
|
1330
|
+
end
|
|
1331
|
+
}
|
|
1332
|
+
end
|
|
1333
|
+
Map[Symbol.species] = Map
|
|
1334
|
+
Map = Map
|
|
1141
1335
|
|
|
1142
1336
|
__TS__MathAtan2 = math.atan2 or math.atan
|
|
1143
1337
|
|
|
1338
|
+
function __TS__MathSign(val)
|
|
1339
|
+
if val > 0 then
|
|
1340
|
+
return 1
|
|
1341
|
+
elseif val < 0 then
|
|
1342
|
+
return -1
|
|
1343
|
+
end
|
|
1344
|
+
return 0
|
|
1345
|
+
end
|
|
1346
|
+
|
|
1144
1347
|
function __TS__Number(value)
|
|
1145
1348
|
local valueType = type(value)
|
|
1146
1349
|
if valueType == "number" then
|
|
@@ -1162,14 +1365,14 @@ function __TS__Number(value)
|
|
|
1162
1365
|
end
|
|
1163
1366
|
return 0 / 0
|
|
1164
1367
|
elseif valueType == "boolean" then
|
|
1165
|
-
return
|
|
1368
|
+
return value and 1 or 0
|
|
1166
1369
|
else
|
|
1167
1370
|
return 0 / 0
|
|
1168
1371
|
end
|
|
1169
1372
|
end
|
|
1170
1373
|
|
|
1171
1374
|
function __TS__NumberIsFinite(value)
|
|
1172
|
-
return
|
|
1375
|
+
return type(value) == "number" and value == value and value ~= math.huge and value ~= -math.huge
|
|
1173
1376
|
end
|
|
1174
1377
|
|
|
1175
1378
|
function __TS__NumberIsNaN(value)
|
|
@@ -1178,16 +1381,14 @@ end
|
|
|
1178
1381
|
|
|
1179
1382
|
____radixChars = "0123456789abcdefghijklmnopqrstuvwxyz"
|
|
1180
1383
|
function __TS__NumberToString(self, radix)
|
|
1181
|
-
if
|
|
1384
|
+
if radix == nil or radix == 10 or self == math.huge or self == -math.huge or self ~= self then
|
|
1182
1385
|
return tostring(self)
|
|
1183
1386
|
end
|
|
1184
1387
|
radix = math.floor(radix)
|
|
1185
|
-
if
|
|
1388
|
+
if radix < 2 or radix > 36 then
|
|
1186
1389
|
error("toString() radix argument must be between 2 and 36", 0)
|
|
1187
1390
|
end
|
|
1188
|
-
local integer, fraction = math.modf(
|
|
1189
|
-
math.abs(self)
|
|
1190
|
-
)
|
|
1391
|
+
local integer, fraction = math.modf(math.abs(self))
|
|
1191
1392
|
local result = ""
|
|
1192
1393
|
if radix == 8 then
|
|
1193
1394
|
result = string.format("%o", integer)
|
|
@@ -1221,9 +1422,15 @@ function __TS__NumberToString(self, radix)
|
|
|
1221
1422
|
end
|
|
1222
1423
|
|
|
1223
1424
|
function __TS__ObjectDefineProperty(target, key, desc)
|
|
1224
|
-
local
|
|
1425
|
+
local ____temp_0
|
|
1426
|
+
if type(key) == "number" then
|
|
1427
|
+
____temp_0 = key + 1
|
|
1428
|
+
else
|
|
1429
|
+
____temp_0 = key
|
|
1430
|
+
end
|
|
1431
|
+
local luaKey = ____temp_0
|
|
1225
1432
|
local value = rawget(target, luaKey)
|
|
1226
|
-
local hasGetterOrSetter =
|
|
1433
|
+
local hasGetterOrSetter = desc.get ~= nil or desc.set ~= nil
|
|
1227
1434
|
local descriptor
|
|
1228
1435
|
if hasGetterOrSetter then
|
|
1229
1436
|
if value ~= nil then
|
|
@@ -1235,13 +1442,39 @@ function __TS__ObjectDefineProperty(target, key, desc)
|
|
|
1235
1442
|
descriptor = desc
|
|
1236
1443
|
else
|
|
1237
1444
|
local valueExists = value ~= nil
|
|
1445
|
+
local ____desc_set_5 = desc.set
|
|
1446
|
+
local ____desc_get_6 = desc.get
|
|
1447
|
+
local ____temp_1
|
|
1448
|
+
if desc.configurable ~= nil then
|
|
1449
|
+
____temp_1 = desc.configurable
|
|
1450
|
+
else
|
|
1451
|
+
____temp_1 = valueExists
|
|
1452
|
+
end
|
|
1453
|
+
local ____temp_2
|
|
1454
|
+
if desc.enumerable ~= nil then
|
|
1455
|
+
____temp_2 = desc.enumerable
|
|
1456
|
+
else
|
|
1457
|
+
____temp_2 = valueExists
|
|
1458
|
+
end
|
|
1459
|
+
local ____temp_3
|
|
1460
|
+
if desc.writable ~= nil then
|
|
1461
|
+
____temp_3 = desc.writable
|
|
1462
|
+
else
|
|
1463
|
+
____temp_3 = valueExists
|
|
1464
|
+
end
|
|
1465
|
+
local ____temp_4
|
|
1466
|
+
if desc.value ~= nil then
|
|
1467
|
+
____temp_4 = desc.value
|
|
1468
|
+
else
|
|
1469
|
+
____temp_4 = value
|
|
1470
|
+
end
|
|
1238
1471
|
descriptor = {
|
|
1239
|
-
set =
|
|
1240
|
-
get =
|
|
1241
|
-
configurable =
|
|
1242
|
-
enumerable =
|
|
1243
|
-
writable =
|
|
1244
|
-
value =
|
|
1472
|
+
set = ____desc_set_5,
|
|
1473
|
+
get = ____desc_get_6,
|
|
1474
|
+
configurable = ____temp_1,
|
|
1475
|
+
enumerable = ____temp_2,
|
|
1476
|
+
writable = ____temp_3,
|
|
1477
|
+
value = ____temp_4
|
|
1245
1478
|
}
|
|
1246
1479
|
end
|
|
1247
1480
|
__TS__SetDescriptor(target, luaKey, descriptor)
|
|
@@ -1303,41 +1536,19 @@ function __TS__ObjectValues(obj)
|
|
|
1303
1536
|
return result
|
|
1304
1537
|
end
|
|
1305
1538
|
|
|
1306
|
-
function __TS__OptionalChainAccess(____table, key)
|
|
1307
|
-
if ____table then
|
|
1308
|
-
return ____table[key]
|
|
1309
|
-
end
|
|
1310
|
-
return nil
|
|
1311
|
-
end
|
|
1312
|
-
|
|
1313
|
-
function __TS__OptionalFunctionCall(f, ...)
|
|
1314
|
-
if f then
|
|
1315
|
-
return f(...)
|
|
1316
|
-
end
|
|
1317
|
-
return nil
|
|
1318
|
-
end
|
|
1319
|
-
|
|
1320
|
-
function __TS__OptionalMethodCall(____table, methodName, isMethodOptional, ...)
|
|
1321
|
-
if ____table then
|
|
1322
|
-
local method = ____table[methodName]
|
|
1323
|
-
if method then
|
|
1324
|
-
return method(____table, ...)
|
|
1325
|
-
elseif not isMethodOptional then
|
|
1326
|
-
error(methodName .. " is not a function", 0)
|
|
1327
|
-
end
|
|
1328
|
-
end
|
|
1329
|
-
return nil
|
|
1330
|
-
end
|
|
1331
|
-
|
|
1332
1539
|
function __TS__ParseFloat(numberString)
|
|
1333
1540
|
local infinityMatch = string.match(numberString, "^%s*(-?Infinity)")
|
|
1334
1541
|
if infinityMatch then
|
|
1335
|
-
|
|
1542
|
+
local ____temp_0
|
|
1543
|
+
if __TS__StringAccess(infinityMatch, 0) == "-" then
|
|
1544
|
+
____temp_0 = -math.huge
|
|
1545
|
+
else
|
|
1546
|
+
____temp_0 = math.huge
|
|
1547
|
+
end
|
|
1548
|
+
return ____temp_0
|
|
1336
1549
|
end
|
|
1337
|
-
local number = tonumber(
|
|
1338
|
-
|
|
1339
|
-
)
|
|
1340
|
-
return number or (0 / 0)
|
|
1550
|
+
local number = tonumber(string.match(numberString, "^%s*(-?%d+%.?%d*)"))
|
|
1551
|
+
return number or 0 / 0
|
|
1341
1552
|
end
|
|
1342
1553
|
|
|
1343
1554
|
function __TS__StringSubstr(self, from, length)
|
|
@@ -1345,7 +1556,7 @@ function __TS__StringSubstr(self, from, length)
|
|
|
1345
1556
|
from = 0
|
|
1346
1557
|
end
|
|
1347
1558
|
if length ~= nil then
|
|
1348
|
-
if
|
|
1559
|
+
if length ~= length or length <= 0 then
|
|
1349
1560
|
return ""
|
|
1350
1561
|
end
|
|
1351
1562
|
length = length + from
|
|
@@ -1360,7 +1571,7 @@ function __TS__StringSubstring(self, start, ____end)
|
|
|
1360
1571
|
if ____end ~= ____end then
|
|
1361
1572
|
____end = 0
|
|
1362
1573
|
end
|
|
1363
|
-
if
|
|
1574
|
+
if ____end ~= nil and start > ____end then
|
|
1364
1575
|
start, ____end = ____end, start
|
|
1365
1576
|
end
|
|
1366
1577
|
if start >= 0 then
|
|
@@ -1368,7 +1579,7 @@ function __TS__StringSubstring(self, start, ____end)
|
|
|
1368
1579
|
else
|
|
1369
1580
|
start = 1
|
|
1370
1581
|
end
|
|
1371
|
-
if
|
|
1582
|
+
if ____end ~= nil and ____end < 0 then
|
|
1372
1583
|
____end = 0
|
|
1373
1584
|
end
|
|
1374
1585
|
return string.sub(self, start, ____end)
|
|
@@ -1381,13 +1592,25 @@ function __TS__ParseInt(numberString, base)
|
|
|
1381
1592
|
local hexMatch = string.match(numberString, "^%s*-?0[xX]")
|
|
1382
1593
|
if hexMatch then
|
|
1383
1594
|
base = 16
|
|
1384
|
-
|
|
1595
|
+
local ____string_match_result__0_0
|
|
1596
|
+
if string.match(hexMatch, "-") then
|
|
1597
|
+
____string_match_result__0_0 = "-" .. __TS__StringSubstr(numberString, #hexMatch)
|
|
1598
|
+
else
|
|
1599
|
+
____string_match_result__0_0 = __TS__StringSubstr(numberString, #hexMatch)
|
|
1600
|
+
end
|
|
1601
|
+
numberString = ____string_match_result__0_0
|
|
1385
1602
|
end
|
|
1386
1603
|
end
|
|
1387
|
-
if
|
|
1604
|
+
if base < 2 or base > 36 then
|
|
1388
1605
|
return 0 / 0
|
|
1389
1606
|
end
|
|
1390
|
-
local
|
|
1607
|
+
local ____temp_1
|
|
1608
|
+
if base <= 10 then
|
|
1609
|
+
____temp_1 = __TS__StringSubstring(__TS__parseInt_base_pattern, 0, base)
|
|
1610
|
+
else
|
|
1611
|
+
____temp_1 = __TS__StringSubstr(__TS__parseInt_base_pattern, 0, 10 + 2 * (base - 10))
|
|
1612
|
+
end
|
|
1613
|
+
local allowedDigits = ____temp_1
|
|
1391
1614
|
local pattern = ("^%s*(-?[" .. allowedDigits) .. "]*)"
|
|
1392
1615
|
local number = tonumber(
|
|
1393
1616
|
string.match(numberString, pattern),
|
|
@@ -1403,179 +1626,6 @@ function __TS__ParseInt(numberString, base)
|
|
|
1403
1626
|
end
|
|
1404
1627
|
end
|
|
1405
1628
|
|
|
1406
|
-
__TS__PromiseState = __TS__PromiseState or ({})
|
|
1407
|
-
__TS__PromiseState.Pending = 0
|
|
1408
|
-
__TS__PromiseState[__TS__PromiseState.Pending] = "Pending"
|
|
1409
|
-
__TS__PromiseState.Fulfilled = 1
|
|
1410
|
-
__TS__PromiseState[__TS__PromiseState.Fulfilled] = "Fulfilled"
|
|
1411
|
-
__TS__PromiseState.Rejected = 2
|
|
1412
|
-
__TS__PromiseState[__TS__PromiseState.Rejected] = "Rejected"
|
|
1413
|
-
function __TS__PromiseDeferred(self)
|
|
1414
|
-
local resolve
|
|
1415
|
-
local reject
|
|
1416
|
-
local promise = __TS__New(
|
|
1417
|
-
__TS__Promise,
|
|
1418
|
-
function(____, res, rej)
|
|
1419
|
-
resolve = res
|
|
1420
|
-
reject = rej
|
|
1421
|
-
end
|
|
1422
|
-
)
|
|
1423
|
-
return {promise = promise, resolve = resolve, reject = reject}
|
|
1424
|
-
end
|
|
1425
|
-
function __TS__IsPromiseLike(self, thing)
|
|
1426
|
-
return __TS__InstanceOf(thing, __TS__Promise)
|
|
1427
|
-
end
|
|
1428
|
-
__TS__Promise = __TS__Class()
|
|
1429
|
-
__TS__Promise.name = "__TS__Promise"
|
|
1430
|
-
function __TS__Promise.prototype.____constructor(self, executor)
|
|
1431
|
-
self.state = __TS__PromiseState.Pending
|
|
1432
|
-
self.fulfilledCallbacks = {}
|
|
1433
|
-
self.rejectedCallbacks = {}
|
|
1434
|
-
self.finallyCallbacks = {}
|
|
1435
|
-
do
|
|
1436
|
-
local function ____catch(e)
|
|
1437
|
-
self:reject(e)
|
|
1438
|
-
end
|
|
1439
|
-
local ____try, ____hasReturned = pcall(
|
|
1440
|
-
function()
|
|
1441
|
-
executor(
|
|
1442
|
-
_G,
|
|
1443
|
-
__TS__FunctionBind(self.resolve, self),
|
|
1444
|
-
__TS__FunctionBind(self.reject, self)
|
|
1445
|
-
)
|
|
1446
|
-
end
|
|
1447
|
-
)
|
|
1448
|
-
if not ____try then
|
|
1449
|
-
____hasReturned, ____returnValue = ____catch(____hasReturned)
|
|
1450
|
-
end
|
|
1451
|
-
end
|
|
1452
|
-
end
|
|
1453
|
-
function __TS__Promise.resolve(data)
|
|
1454
|
-
local promise = __TS__New(
|
|
1455
|
-
__TS__Promise,
|
|
1456
|
-
function()
|
|
1457
|
-
end
|
|
1458
|
-
)
|
|
1459
|
-
promise.state = __TS__PromiseState.Fulfilled
|
|
1460
|
-
promise.value = data
|
|
1461
|
-
return promise
|
|
1462
|
-
end
|
|
1463
|
-
function __TS__Promise.reject(reason)
|
|
1464
|
-
local promise = __TS__New(
|
|
1465
|
-
__TS__Promise,
|
|
1466
|
-
function()
|
|
1467
|
-
end
|
|
1468
|
-
)
|
|
1469
|
-
promise.state = __TS__PromiseState.Rejected
|
|
1470
|
-
promise.rejectionReason = reason
|
|
1471
|
-
return promise
|
|
1472
|
-
end
|
|
1473
|
-
__TS__Promise.prototype["then"] = function(self, onFulfilled, onRejected)
|
|
1474
|
-
local ____ = __TS__PromiseDeferred(_G)
|
|
1475
|
-
local promise = ____.promise
|
|
1476
|
-
local resolve = ____.resolve
|
|
1477
|
-
local reject = ____.reject
|
|
1478
|
-
local isFulfilled = self.state == __TS__PromiseState.Fulfilled
|
|
1479
|
-
local isRejected = self.state == __TS__PromiseState.Rejected
|
|
1480
|
-
if onFulfilled then
|
|
1481
|
-
local internalCallback = self:createPromiseResolvingCallback(onFulfilled, resolve, reject)
|
|
1482
|
-
__TS__ArrayPush(self.fulfilledCallbacks, internalCallback)
|
|
1483
|
-
if isFulfilled then
|
|
1484
|
-
internalCallback(_G, self.value)
|
|
1485
|
-
end
|
|
1486
|
-
else
|
|
1487
|
-
__TS__ArrayPush(
|
|
1488
|
-
self.fulfilledCallbacks,
|
|
1489
|
-
function() return resolve(_G, nil) end
|
|
1490
|
-
)
|
|
1491
|
-
end
|
|
1492
|
-
if onRejected then
|
|
1493
|
-
local internalCallback = self:createPromiseResolvingCallback(onRejected, resolve, reject)
|
|
1494
|
-
__TS__ArrayPush(self.rejectedCallbacks, internalCallback)
|
|
1495
|
-
if isRejected then
|
|
1496
|
-
internalCallback(_G, self.rejectionReason)
|
|
1497
|
-
end
|
|
1498
|
-
end
|
|
1499
|
-
if isFulfilled then
|
|
1500
|
-
resolve(_G, self.value)
|
|
1501
|
-
end
|
|
1502
|
-
if isRejected then
|
|
1503
|
-
reject(_G, self.rejectionReason)
|
|
1504
|
-
end
|
|
1505
|
-
return promise
|
|
1506
|
-
end
|
|
1507
|
-
function __TS__Promise.prototype.catch(self, onRejected)
|
|
1508
|
-
return self["then"](self, nil, onRejected)
|
|
1509
|
-
end
|
|
1510
|
-
function __TS__Promise.prototype.finally(self, onFinally)
|
|
1511
|
-
if onFinally then
|
|
1512
|
-
__TS__ArrayPush(self.finallyCallbacks, onFinally)
|
|
1513
|
-
if self.state ~= __TS__PromiseState.Pending then
|
|
1514
|
-
onFinally(_G)
|
|
1515
|
-
end
|
|
1516
|
-
end
|
|
1517
|
-
return self
|
|
1518
|
-
end
|
|
1519
|
-
function __TS__Promise.prototype.resolve(self, data)
|
|
1520
|
-
if self.state == __TS__PromiseState.Pending then
|
|
1521
|
-
self.state = __TS__PromiseState.Fulfilled
|
|
1522
|
-
self.value = data
|
|
1523
|
-
for ____, callback in ipairs(self.fulfilledCallbacks) do
|
|
1524
|
-
callback(_G, data)
|
|
1525
|
-
end
|
|
1526
|
-
for ____, callback in ipairs(self.finallyCallbacks) do
|
|
1527
|
-
callback(_G)
|
|
1528
|
-
end
|
|
1529
|
-
end
|
|
1530
|
-
end
|
|
1531
|
-
function __TS__Promise.prototype.reject(self, reason)
|
|
1532
|
-
if self.state == __TS__PromiseState.Pending then
|
|
1533
|
-
self.state = __TS__PromiseState.Rejected
|
|
1534
|
-
self.rejectionReason = reason
|
|
1535
|
-
for ____, callback in ipairs(self.rejectedCallbacks) do
|
|
1536
|
-
callback(_G, reason)
|
|
1537
|
-
end
|
|
1538
|
-
for ____, callback in ipairs(self.finallyCallbacks) do
|
|
1539
|
-
callback(_G)
|
|
1540
|
-
end
|
|
1541
|
-
end
|
|
1542
|
-
end
|
|
1543
|
-
function __TS__Promise.prototype.createPromiseResolvingCallback(self, f, resolve, reject)
|
|
1544
|
-
return function(____, value)
|
|
1545
|
-
do
|
|
1546
|
-
local function ____catch(e)
|
|
1547
|
-
reject(_G, e)
|
|
1548
|
-
end
|
|
1549
|
-
local ____try, ____hasReturned = pcall(
|
|
1550
|
-
function()
|
|
1551
|
-
self:handleCallbackData(
|
|
1552
|
-
f(_G, value),
|
|
1553
|
-
resolve,
|
|
1554
|
-
reject
|
|
1555
|
-
)
|
|
1556
|
-
end
|
|
1557
|
-
)
|
|
1558
|
-
if not ____try then
|
|
1559
|
-
____hasReturned, ____returnValue = ____catch(____hasReturned)
|
|
1560
|
-
end
|
|
1561
|
-
end
|
|
1562
|
-
end
|
|
1563
|
-
end
|
|
1564
|
-
function __TS__Promise.prototype.handleCallbackData(self, data, resolve, reject)
|
|
1565
|
-
if __TS__IsPromiseLike(_G, data) then
|
|
1566
|
-
local nextpromise = data
|
|
1567
|
-
if nextpromise.state == __TS__PromiseState.Fulfilled then
|
|
1568
|
-
resolve(_G, nextpromise.value)
|
|
1569
|
-
elseif nextpromise.state == __TS__PromiseState.Rejected then
|
|
1570
|
-
reject(_G, nextpromise.rejectionReason)
|
|
1571
|
-
else
|
|
1572
|
-
data["then"](data, resolve, reject)
|
|
1573
|
-
end
|
|
1574
|
-
else
|
|
1575
|
-
resolve(_G, data)
|
|
1576
|
-
end
|
|
1577
|
-
end
|
|
1578
|
-
|
|
1579
1629
|
function __TS__PromiseAll(iterable)
|
|
1580
1630
|
local results = {}
|
|
1581
1631
|
local toResolve = {}
|
|
@@ -1741,226 +1791,239 @@ function __TS__PromiseRace(iterable)
|
|
|
1741
1791
|
)
|
|
1742
1792
|
end
|
|
1743
1793
|
|
|
1744
|
-
Set = (
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
return
|
|
1754
|
-
end
|
|
1755
|
-
local iterable = values
|
|
1756
|
-
if iterable[Symbol.iterator] then
|
|
1757
|
-
local iterator = iterable[Symbol.iterator](iterable)
|
|
1758
|
-
while true do
|
|
1759
|
-
local result = iterator:next()
|
|
1760
|
-
if result.done then
|
|
1761
|
-
break
|
|
1762
|
-
end
|
|
1763
|
-
self:add(result.value)
|
|
1764
|
-
end
|
|
1765
|
-
else
|
|
1766
|
-
local array = values
|
|
1767
|
-
for ____, value in ipairs(array) do
|
|
1768
|
-
self:add(value)
|
|
1769
|
-
end
|
|
1770
|
-
end
|
|
1771
|
-
end
|
|
1772
|
-
function Set.prototype.add(self, value)
|
|
1773
|
-
local isNewValue = not self:has(value)
|
|
1774
|
-
if isNewValue then
|
|
1775
|
-
self.size = self.size + 1
|
|
1776
|
-
end
|
|
1777
|
-
if self.firstKey == nil then
|
|
1778
|
-
self.firstKey = value
|
|
1779
|
-
self.lastKey = value
|
|
1780
|
-
elseif isNewValue then
|
|
1781
|
-
self.nextKey[self.lastKey] = value
|
|
1782
|
-
self.previousKey[value] = self.lastKey
|
|
1783
|
-
self.lastKey = value
|
|
1784
|
-
end
|
|
1785
|
-
return self
|
|
1794
|
+
Set = __TS__Class()
|
|
1795
|
+
Set.name = "Set"
|
|
1796
|
+
function Set.prototype.____constructor(self, values)
|
|
1797
|
+
self[Symbol.toStringTag] = "Set"
|
|
1798
|
+
self.size = 0
|
|
1799
|
+
self.nextKey = {}
|
|
1800
|
+
self.previousKey = {}
|
|
1801
|
+
if values == nil then
|
|
1802
|
+
return
|
|
1786
1803
|
end
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
function Set.prototype.delete(self, value)
|
|
1795
|
-
local contains = self:has(value)
|
|
1796
|
-
if contains then
|
|
1797
|
-
self.size = self.size - 1
|
|
1798
|
-
local next = self.nextKey[value]
|
|
1799
|
-
local previous = self.previousKey[value]
|
|
1800
|
-
if next and previous then
|
|
1801
|
-
self.nextKey[previous] = next
|
|
1802
|
-
self.previousKey[next] = previous
|
|
1803
|
-
elseif next then
|
|
1804
|
-
self.firstKey = next
|
|
1805
|
-
self.previousKey[next] = nil
|
|
1806
|
-
elseif previous then
|
|
1807
|
-
self.lastKey = previous
|
|
1808
|
-
self.nextKey[previous] = nil
|
|
1809
|
-
else
|
|
1810
|
-
self.firstKey = nil
|
|
1811
|
-
self.lastKey = nil
|
|
1804
|
+
local iterable = values
|
|
1805
|
+
if iterable[Symbol.iterator] then
|
|
1806
|
+
local iterator = iterable[Symbol.iterator](iterable)
|
|
1807
|
+
while true do
|
|
1808
|
+
local result = iterator:next()
|
|
1809
|
+
if result.done then
|
|
1810
|
+
break
|
|
1812
1811
|
end
|
|
1813
|
-
self.
|
|
1814
|
-
self.previousKey[value] = nil
|
|
1812
|
+
self:add(result.value)
|
|
1815
1813
|
end
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
self:keys()
|
|
1821
|
-
) do
|
|
1822
|
-
callback(_G, key, key, self)
|
|
1814
|
+
else
|
|
1815
|
+
local array = values
|
|
1816
|
+
for ____, value in ipairs(array) do
|
|
1817
|
+
self:add(value)
|
|
1823
1818
|
end
|
|
1824
1819
|
end
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
end
|
|
1831
|
-
function Set.prototype.entries(self)
|
|
1832
|
-
local nextKey = self.nextKey
|
|
1833
|
-
local key = self.firstKey
|
|
1834
|
-
return {
|
|
1835
|
-
[Symbol.iterator] = function(self)
|
|
1836
|
-
return self
|
|
1837
|
-
end,
|
|
1838
|
-
next = function(self)
|
|
1839
|
-
local result = {done = not key, value = {key, key}}
|
|
1840
|
-
key = nextKey[key]
|
|
1841
|
-
return result
|
|
1842
|
-
end
|
|
1843
|
-
}
|
|
1844
|
-
end
|
|
1845
|
-
function Set.prototype.keys(self)
|
|
1846
|
-
local nextKey = self.nextKey
|
|
1847
|
-
local key = self.firstKey
|
|
1848
|
-
return {
|
|
1849
|
-
[Symbol.iterator] = function(self)
|
|
1850
|
-
return self
|
|
1851
|
-
end,
|
|
1852
|
-
next = function(self)
|
|
1853
|
-
local result = {done = not key, value = key}
|
|
1854
|
-
key = nextKey[key]
|
|
1855
|
-
return result
|
|
1856
|
-
end
|
|
1857
|
-
}
|
|
1820
|
+
end
|
|
1821
|
+
function Set.prototype.add(self, value)
|
|
1822
|
+
local isNewValue = not self:has(value)
|
|
1823
|
+
if isNewValue then
|
|
1824
|
+
self.size = self.size + 1
|
|
1858
1825
|
end
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
next = function(self)
|
|
1867
|
-
local result = {done = not key, value = key}
|
|
1868
|
-
key = nextKey[key]
|
|
1869
|
-
return result
|
|
1870
|
-
end
|
|
1871
|
-
}
|
|
1826
|
+
if self.firstKey == nil then
|
|
1827
|
+
self.firstKey = value
|
|
1828
|
+
self.lastKey = value
|
|
1829
|
+
elseif isNewValue then
|
|
1830
|
+
self.nextKey[self.lastKey] = value
|
|
1831
|
+
self.previousKey[value] = self.lastKey
|
|
1832
|
+
self.lastKey = value
|
|
1872
1833
|
end
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
local
|
|
1888
|
-
if
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
end
|
|
1834
|
+
return self
|
|
1835
|
+
end
|
|
1836
|
+
function Set.prototype.clear(self)
|
|
1837
|
+
self.nextKey = {}
|
|
1838
|
+
self.previousKey = {}
|
|
1839
|
+
self.firstKey = nil
|
|
1840
|
+
self.lastKey = nil
|
|
1841
|
+
self.size = 0
|
|
1842
|
+
end
|
|
1843
|
+
function Set.prototype.delete(self, value)
|
|
1844
|
+
local contains = self:has(value)
|
|
1845
|
+
if contains then
|
|
1846
|
+
self.size = self.size - 1
|
|
1847
|
+
local next = self.nextKey[value]
|
|
1848
|
+
local previous = self.previousKey[value]
|
|
1849
|
+
if next and previous then
|
|
1850
|
+
self.nextKey[previous] = next
|
|
1851
|
+
self.previousKey[next] = previous
|
|
1852
|
+
elseif next then
|
|
1853
|
+
self.firstKey = next
|
|
1854
|
+
self.previousKey[next] = nil
|
|
1855
|
+
elseif previous then
|
|
1856
|
+
self.lastKey = previous
|
|
1857
|
+
self.nextKey[previous] = nil
|
|
1898
1858
|
else
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
end
|
|
1859
|
+
self.firstKey = nil
|
|
1860
|
+
self.lastKey = nil
|
|
1902
1861
|
end
|
|
1862
|
+
self.nextKey[value] = nil
|
|
1863
|
+
self.previousKey[value] = nil
|
|
1903
1864
|
end
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
function WeakMap.prototype.get(self, key)
|
|
1910
|
-
return self.items[key]
|
|
1865
|
+
return contains
|
|
1866
|
+
end
|
|
1867
|
+
function Set.prototype.forEach(self, callback)
|
|
1868
|
+
for ____, key in __TS__Iterator(self:keys()) do
|
|
1869
|
+
callback(_G, key, key, self)
|
|
1911
1870
|
end
|
|
1912
|
-
|
|
1913
|
-
|
|
1871
|
+
end
|
|
1872
|
+
function Set.prototype.has(self, value)
|
|
1873
|
+
return self.nextKey[value] ~= nil or self.lastKey == value
|
|
1874
|
+
end
|
|
1875
|
+
Set.prototype[Symbol.iterator] = function(self)
|
|
1876
|
+
return self:values()
|
|
1877
|
+
end
|
|
1878
|
+
function Set.prototype.entries(self)
|
|
1879
|
+
local nextKey = self.nextKey
|
|
1880
|
+
local key = self.firstKey
|
|
1881
|
+
return {
|
|
1882
|
+
[Symbol.iterator] = function(self)
|
|
1883
|
+
return self
|
|
1884
|
+
end,
|
|
1885
|
+
next = function(self)
|
|
1886
|
+
local result = {done = not key, value = {key, key}}
|
|
1887
|
+
key = nextKey[key]
|
|
1888
|
+
return result
|
|
1889
|
+
end
|
|
1890
|
+
}
|
|
1891
|
+
end
|
|
1892
|
+
function Set.prototype.keys(self)
|
|
1893
|
+
local nextKey = self.nextKey
|
|
1894
|
+
local key = self.firstKey
|
|
1895
|
+
return {
|
|
1896
|
+
[Symbol.iterator] = function(self)
|
|
1897
|
+
return self
|
|
1898
|
+
end,
|
|
1899
|
+
next = function(self)
|
|
1900
|
+
local result = {done = not key, value = key}
|
|
1901
|
+
key = nextKey[key]
|
|
1902
|
+
return result
|
|
1903
|
+
end
|
|
1904
|
+
}
|
|
1905
|
+
end
|
|
1906
|
+
function Set.prototype.values(self)
|
|
1907
|
+
local nextKey = self.nextKey
|
|
1908
|
+
local key = self.firstKey
|
|
1909
|
+
return {
|
|
1910
|
+
[Symbol.iterator] = function(self)
|
|
1911
|
+
return self
|
|
1912
|
+
end,
|
|
1913
|
+
next = function(self)
|
|
1914
|
+
local result = {done = not key, value = key}
|
|
1915
|
+
key = nextKey[key]
|
|
1916
|
+
return result
|
|
1917
|
+
end
|
|
1918
|
+
}
|
|
1919
|
+
end
|
|
1920
|
+
Set[Symbol.species] = Set
|
|
1921
|
+
Set = Set
|
|
1922
|
+
|
|
1923
|
+
function __TS__SparseArrayNew(...)
|
|
1924
|
+
local sparseArray = {...}
|
|
1925
|
+
sparseArray.sparseLength = select("#", ...)
|
|
1926
|
+
return sparseArray
|
|
1927
|
+
end
|
|
1928
|
+
|
|
1929
|
+
function __TS__SparseArrayPush(sparseArray, ...)
|
|
1930
|
+
local args = {...}
|
|
1931
|
+
local argsLen = select("#", ...)
|
|
1932
|
+
local listLen = sparseArray.sparseLength
|
|
1933
|
+
for i = 1, argsLen do
|
|
1934
|
+
sparseArray[listLen + i] = args[i]
|
|
1914
1935
|
end
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1936
|
+
sparseArray.sparseLength = listLen + argsLen
|
|
1937
|
+
end
|
|
1938
|
+
|
|
1939
|
+
function __TS__SparseArraySpread(sparseArray)
|
|
1940
|
+
local _unpack = unpack or table.unpack
|
|
1941
|
+
return _unpack(sparseArray, 1, sparseArray.sparseLength)
|
|
1942
|
+
end
|
|
1943
|
+
|
|
1944
|
+
WeakMap = __TS__Class()
|
|
1945
|
+
WeakMap.name = "WeakMap"
|
|
1946
|
+
function WeakMap.prototype.____constructor(self, entries)
|
|
1947
|
+
self[Symbol.toStringTag] = "WeakMap"
|
|
1948
|
+
self.items = {}
|
|
1949
|
+
setmetatable(self.items, {__mode = "k"})
|
|
1950
|
+
if entries == nil then
|
|
1951
|
+
return
|
|
1918
1952
|
end
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
function WeakSet.prototype.____constructor(self, values)
|
|
1927
|
-
self[Symbol.toStringTag] = "WeakSet"
|
|
1928
|
-
self.items = {}
|
|
1929
|
-
setmetatable(self.items, {__mode = "k"})
|
|
1930
|
-
if values == nil then
|
|
1931
|
-
return
|
|
1932
|
-
end
|
|
1933
|
-
local iterable = values
|
|
1934
|
-
if iterable[Symbol.iterator] then
|
|
1935
|
-
local iterator = iterable[Symbol.iterator](iterable)
|
|
1936
|
-
while true do
|
|
1937
|
-
local result = iterator:next()
|
|
1938
|
-
if result.done then
|
|
1939
|
-
break
|
|
1940
|
-
end
|
|
1941
|
-
self.items[result.value] = true
|
|
1942
|
-
end
|
|
1943
|
-
else
|
|
1944
|
-
for ____, value in ipairs(values) do
|
|
1945
|
-
self.items[value] = true
|
|
1953
|
+
local iterable = entries
|
|
1954
|
+
if iterable[Symbol.iterator] then
|
|
1955
|
+
local iterator = iterable[Symbol.iterator](iterable)
|
|
1956
|
+
while true do
|
|
1957
|
+
local result = iterator:next()
|
|
1958
|
+
if result.done then
|
|
1959
|
+
break
|
|
1946
1960
|
end
|
|
1961
|
+
local value = result.value
|
|
1962
|
+
self.items[value[1]] = value[2]
|
|
1963
|
+
end
|
|
1964
|
+
else
|
|
1965
|
+
for ____, kvp in ipairs(entries) do
|
|
1966
|
+
self.items[kvp[1]] = kvp[2]
|
|
1947
1967
|
end
|
|
1948
1968
|
end
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1969
|
+
end
|
|
1970
|
+
function WeakMap.prototype.delete(self, key)
|
|
1971
|
+
local contains = self:has(key)
|
|
1972
|
+
self.items[key] = nil
|
|
1973
|
+
return contains
|
|
1974
|
+
end
|
|
1975
|
+
function WeakMap.prototype.get(self, key)
|
|
1976
|
+
return self.items[key]
|
|
1977
|
+
end
|
|
1978
|
+
function WeakMap.prototype.has(self, key)
|
|
1979
|
+
return self.items[key] ~= nil
|
|
1980
|
+
end
|
|
1981
|
+
function WeakMap.prototype.set(self, key, value)
|
|
1982
|
+
self.items[key] = value
|
|
1983
|
+
return self
|
|
1984
|
+
end
|
|
1985
|
+
WeakMap[Symbol.species] = WeakMap
|
|
1986
|
+
WeakMap = WeakMap
|
|
1987
|
+
|
|
1988
|
+
WeakSet = __TS__Class()
|
|
1989
|
+
WeakSet.name = "WeakSet"
|
|
1990
|
+
function WeakSet.prototype.____constructor(self, values)
|
|
1991
|
+
self[Symbol.toStringTag] = "WeakSet"
|
|
1992
|
+
self.items = {}
|
|
1993
|
+
setmetatable(self.items, {__mode = "k"})
|
|
1994
|
+
if values == nil then
|
|
1995
|
+
return
|
|
1957
1996
|
end
|
|
1958
|
-
|
|
1959
|
-
|
|
1997
|
+
local iterable = values
|
|
1998
|
+
if iterable[Symbol.iterator] then
|
|
1999
|
+
local iterator = iterable[Symbol.iterator](iterable)
|
|
2000
|
+
while true do
|
|
2001
|
+
local result = iterator:next()
|
|
2002
|
+
if result.done then
|
|
2003
|
+
break
|
|
2004
|
+
end
|
|
2005
|
+
self.items[result.value] = true
|
|
2006
|
+
end
|
|
2007
|
+
else
|
|
2008
|
+
for ____, value in ipairs(values) do
|
|
2009
|
+
self.items[value] = true
|
|
2010
|
+
end
|
|
1960
2011
|
end
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
2012
|
+
end
|
|
2013
|
+
function WeakSet.prototype.add(self, value)
|
|
2014
|
+
self.items[value] = true
|
|
2015
|
+
return self
|
|
2016
|
+
end
|
|
2017
|
+
function WeakSet.prototype.delete(self, value)
|
|
2018
|
+
local contains = self:has(value)
|
|
2019
|
+
self.items[value] = nil
|
|
2020
|
+
return contains
|
|
2021
|
+
end
|
|
2022
|
+
function WeakSet.prototype.has(self, value)
|
|
2023
|
+
return self.items[value] == true
|
|
2024
|
+
end
|
|
2025
|
+
WeakSet[Symbol.species] = WeakSet
|
|
2026
|
+
WeakSet = WeakSet
|
|
1964
2027
|
|
|
1965
2028
|
function __TS__SourceMapTraceBack(fileName, sourceMap)
|
|
1966
2029
|
_G.__TS__sourcemap = _G.__TS__sourcemap or ({})
|
|
@@ -1969,7 +2032,7 @@ function __TS__SourceMapTraceBack(fileName, sourceMap)
|
|
|
1969
2032
|
_G.__TS__originalTraceback = debug.traceback
|
|
1970
2033
|
debug.traceback = function(thread, message, level)
|
|
1971
2034
|
local trace
|
|
1972
|
-
if
|
|
2035
|
+
if thread == nil and message == nil and level == nil then
|
|
1973
2036
|
trace = _G.__TS__originalTraceback()
|
|
1974
2037
|
else
|
|
1975
2038
|
trace = _G.__TS__originalTraceback(thread, message, level)
|
|
@@ -2038,7 +2101,7 @@ function __TS__StringCharCodeAt(self, index)
|
|
|
2038
2101
|
if index < 0 then
|
|
2039
2102
|
return 0 / 0
|
|
2040
2103
|
end
|
|
2041
|
-
return string.byte(self, index + 1) or
|
|
2104
|
+
return string.byte(self, index + 1) or 0 / 0
|
|
2042
2105
|
end
|
|
2043
2106
|
|
|
2044
2107
|
function __TS__StringConcat(str1, ...)
|
|
@@ -2051,10 +2114,10 @@ function __TS__StringConcat(str1, ...)
|
|
|
2051
2114
|
end
|
|
2052
2115
|
|
|
2053
2116
|
function __TS__StringEndsWith(self, searchString, endPosition)
|
|
2054
|
-
if
|
|
2117
|
+
if endPosition == nil or endPosition > #self then
|
|
2055
2118
|
endPosition = #self
|
|
2056
2119
|
end
|
|
2057
|
-
return string.sub(self,
|
|
2120
|
+
return string.sub(self, endPosition - #searchString + 1, endPosition) == searchString
|
|
2058
2121
|
end
|
|
2059
2122
|
|
|
2060
2123
|
function __TS__StringIncludes(self, searchString, position)
|
|
@@ -2074,10 +2137,10 @@ function __TS__StringPadEnd(self, maxLength, fillString)
|
|
|
2074
2137
|
if maxLength ~= maxLength then
|
|
2075
2138
|
maxLength = 0
|
|
2076
2139
|
end
|
|
2077
|
-
if
|
|
2140
|
+
if maxLength == -math.huge or maxLength == math.huge then
|
|
2078
2141
|
error("Invalid string length", 0)
|
|
2079
2142
|
end
|
|
2080
|
-
if
|
|
2143
|
+
if #self >= maxLength or #fillString == 0 then
|
|
2081
2144
|
return self
|
|
2082
2145
|
end
|
|
2083
2146
|
maxLength = maxLength - #self
|
|
@@ -2101,10 +2164,10 @@ function __TS__StringPadStart(self, maxLength, fillString)
|
|
|
2101
2164
|
if maxLength ~= maxLength then
|
|
2102
2165
|
maxLength = 0
|
|
2103
2166
|
end
|
|
2104
|
-
if
|
|
2167
|
+
if maxLength == -math.huge or maxLength == math.huge then
|
|
2105
2168
|
error("Invalid string length", 0)
|
|
2106
2169
|
end
|
|
2107
|
-
if
|
|
2170
|
+
if #self >= maxLength or #fillString == 0 then
|
|
2108
2171
|
return self
|
|
2109
2172
|
end
|
|
2110
2173
|
maxLength = maxLength - #self
|
|
@@ -2128,7 +2191,13 @@ function __TS__StringReplace(source, searchValue, replaceValue)
|
|
|
2128
2191
|
end
|
|
2129
2192
|
local sub = string.sub
|
|
2130
2193
|
local before = sub(source, 1, startPos - 1)
|
|
2131
|
-
local
|
|
2194
|
+
local ____temp_0
|
|
2195
|
+
if type(replaceValue) == "string" then
|
|
2196
|
+
____temp_0 = replaceValue
|
|
2197
|
+
else
|
|
2198
|
+
____temp_0 = replaceValue(_G, searchValue, startPos - 1, source)
|
|
2199
|
+
end
|
|
2200
|
+
local replacement = ____temp_0
|
|
2132
2201
|
local after = sub(source, endPos + 1)
|
|
2133
2202
|
return (before .. replacement) .. after
|
|
2134
2203
|
end
|
|
@@ -2170,7 +2239,7 @@ function __TS__StringReplaceAll(source, searchValue, replaceValue)
|
|
|
2170
2239
|
end
|
|
2171
2240
|
|
|
2172
2241
|
function __TS__StringSlice(self, start, ____end)
|
|
2173
|
-
if
|
|
2242
|
+
if start == nil or start ~= start then
|
|
2174
2243
|
start = 0
|
|
2175
2244
|
end
|
|
2176
2245
|
if ____end ~= ____end then
|
|
@@ -2179,7 +2248,7 @@ function __TS__StringSlice(self, start, ____end)
|
|
|
2179
2248
|
if start >= 0 then
|
|
2180
2249
|
start = start + 1
|
|
2181
2250
|
end
|
|
2182
|
-
if
|
|
2251
|
+
if ____end ~= nil and ____end < 0 then
|
|
2183
2252
|
____end = ____end - 1
|
|
2184
2253
|
end
|
|
2185
2254
|
return string.sub(self, start, ____end)
|
|
@@ -2195,8 +2264,8 @@ function __TS__StringSplit(source, separator, limit)
|
|
|
2195
2264
|
local out = {}
|
|
2196
2265
|
local index = 0
|
|
2197
2266
|
local count = 0
|
|
2198
|
-
if
|
|
2199
|
-
while
|
|
2267
|
+
if separator == nil or separator == "" then
|
|
2268
|
+
while index < #source - 1 and count < limit do
|
|
2200
2269
|
out[count + 1] = __TS__StringAccess(source, index)
|
|
2201
2270
|
count = count + 1
|
|
2202
2271
|
index = index + 1
|
|
@@ -2204,7 +2273,7 @@ function __TS__StringSplit(source, separator, limit)
|
|
|
2204
2273
|
else
|
|
2205
2274
|
local separatorLength = #separator
|
|
2206
2275
|
local nextIndex = (string.find(source, separator, nil, true) or 0) - 1
|
|
2207
|
-
while
|
|
2276
|
+
while nextIndex >= 0 and count < limit do
|
|
2208
2277
|
out[count + 1] = __TS__StringSubstring(source, index, nextIndex)
|
|
2209
2278
|
count = count + 1
|
|
2210
2279
|
index = nextIndex + separatorLength
|
|
@@ -2223,7 +2292,7 @@ function __TS__StringSplit(source, separator, limit)
|
|
|
2223
2292
|
end
|
|
2224
2293
|
|
|
2225
2294
|
function __TS__StringStartsWith(self, searchString, position)
|
|
2226
|
-
if
|
|
2295
|
+
if position == nil or position < 0 then
|
|
2227
2296
|
position = 0
|
|
2228
2297
|
end
|
|
2229
2298
|
return string.sub(self, position + 1, #searchString + position) == searchString
|