repo
stringclasses
341 values
file_path
stringlengths
29
173
language
stringclasses
2 values
file_type
stringclasses
4 values
code
stringlengths
2
1.66M
tokens
int64
2
598k
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauDisk/array/product.luau
luau
.luau
local function product(array: {number}, initialValue: number?): number local result = if initialValue == nil then 1 else initialValue for _, element in array do result *= element end return result end return product
49
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauDisk/array/productBy.luau
luau
.luau
local function productBy<T>(array: {T}, map: (T) -> number, initialValue: number?): number local result = if initialValue == nil then 1 else initialValue for _, element in array do result *= map(element) end return result end return productBy
62
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauDisk/array/push.luau
luau
.luau
local function push<T>(array: {T}, ...: T?): {T} local newArray = table.clone(array) for i = 1, select("#", ...) do local element = select(i, ...) if element ~= nil then table.insert(newArray, element) end end return newArray end return push
72
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauDisk/array/range.luau
luau
.luau
local function range<T>(array: {T}, from: number, to: number?): {T} local length = #array if length == 0 then return array end local actualTo = if to == nil then length else to local normalizedFrom = if from < 0 then 1 + (from + length) else from local normalizedTo = if actualTo < 0 then 1 + (actualTo + length...
192
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauDisk/array/reduce.luau
luau
.luau
local function reduce<T, A>(array: {T}, reducer: (accumulator: A, value: T, index: number) -> A, accumulator: A?): A if accumulator == nil then for index, value in array do if index == 1 then accumulator = value :: any else accumulator = reducer(accumulator :: A, value, index) end end else for ...
223
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauDisk/array/removeIndexes.luau
luau
.luau
local removeSortedIndexes = require("./removeSortedIndexes") local sort = require("./sort") local function removeIndexes<T>(array: {T}, indexes: {number}): {T} local removeLength = #indexes local arrayLenth = #array if removeLength == 0 or arrayLenth == 0 then return array end local sortedIndexes = sort(index...
96
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauDisk/array/removeSortedIndexes.luau
luau
.luau
local function removeSortedIndexes<T>(array: {T}, indexes: {number}): {T} local removeLength = #indexes local arrayLenth = #array if removeLength == 0 or arrayLenth == 0 then return array end local startFrom = nil for i = removeLength, 1, -1 do local index = indexes[i] if index <= arrayLenth then start...
211
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauDisk/array/removeValues.luau
luau
.luau
local function removeValues<T>(array: {T}, ...: T?): {T} local removeLength = select("#", ...) local arrayLenth = #array if removeLength == 0 or arrayLenth == 0 then return array end local removeIndexes = {} for index, element in array do for i = 1, removeLength do local value: T? = select(i, ...) if...
203
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauDisk/array/reverse.luau
luau
.luau
local function reverse<T>(array: {T}): {T} local length = #array if length < 2 then return array end local newArray = table.clone(array) for i = 1, math.floor(length / 2) do local swapRight = length - i + 1 newArray[i], newArray[swapRight] = newArray[swapRight], newArray[i] end return newArray end re...
95
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauDisk/array/sort.luau
luau
.luau
local function sort<T>(array: {T}, comparator: ((T, T) -> boolean)?): {T} if #array <= 1 then return array end local result = table.clone(array) table.sort(result, comparator) return result end return sort
59
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauDisk/array/sortByKey.luau
luau
.luau
local map = require("./map") type KeyElement<K, V> = {key: K, element: V} local function sortByKey<T, Comparable>(array: {T}, key: (T) -> Comparable): {T} if #array <= 1 then return array end local result: {KeyElement<Comparable, T>} = map(array, function(element) return { key = key(element); element = e...
153
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauDisk/array/stepBy.luau
luau
.luau
local function stepBy<T>(array: {T}, step: number): {T} local length = #array if step == 1 then return array elseif step == -1 then local newArray = table.clone(array) for i = 1, math.floor(length / 2) do local swapRight = length - i + 1 newArray[i], newArray[swapRight] = newArray[swapRight], newArray...
207
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauDisk/array/sum.luau
luau
.luau
local function sum(array: {number}, initialValue: number?): number local result = if initialValue == nil then 0 else initialValue for _, element in array do result += element end return result end return sum
49
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauDisk/array/sumBy.luau
luau
.luau
local function sumBy<T>(array: {T}, map: (T) -> number, initialValue: number?): number local result = if initialValue == nil then 0 else initialValue for _, element in array do result += map(element) end return result end return sumBy
62
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauDisk/array/takeWhile.luau
luau
.luau
local function takeWhile<T>(array: {T}, predicate: (element: T, index: number) -> boolean, start: number?): {T} local arrayLength = #array if arrayLength == 0 then return array end local bound = arrayLength + 1 local actualStart = if start == nil then 1 else start if actualStart == 1 then for index, element...
302
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauDisk/array/zip.luau
luau
.luau
local reduce = require("./reduce") local function zip<T>(array: {T}, ...: {T}): {{T}} local alternateWith = {...} local minimumLength = reduce(alternateWith, function(minimum: number, value) return math.min(minimum, #value) end, #array) if minimumLength == 0 then return {} end local result = {} for i = ...
235
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauDisk/init.luau
luau
.luau
local setType = require("@self/set/type") export type Set<T> = setType.Set<T> local Disk = { Array = { all = require("@self/array/all"); alternate = require("@self/array/alternate"); any = require("@self/array/any"); average = require("@self/array/average"); averageBy = require("@self/array/averageBy"); ...
701
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauDisk/map/count.luau
luau
.luau
local function count<K, V>(map: {[K]: V}): number local length = 0 for _ in map do length += 1 end return length end return count
44
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauDisk/map/entries.luau
luau
.luau
local function entries<K, V>(map: {[K]: V}, keyIndex: any?, valueIndex: any?): {{[any]: K | V}} local useKeyIndex = if keyIndex == nil then 1 else keyIndex local useValueIndex = if valueIndex == nil then useKeyIndex + 1 else valueIndex local array = {} for key, value in map do table.insert(array, { [useKeyIn...
191
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauDisk/map/invert.luau
luau
.luau
local function invert<K, V>(map: {[K]: V}): {[V]: K} if next(map) == nil then return map :: any end local result = {} for key, value in map do result[value] = key end return result end return invert
64
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauDisk/map/keys.luau
luau
.luau
local function keys<K, V>(map: {[K]: V}): {K} local result = {} for key in map do table.insert(result, key) end return result end return keys
44
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauDisk/map/mapEntries.luau
luau
.luau
local function mapEntries<K, V, K2, V2>(map: {[K]: V}, mapFn: (key: K, value: V) -> (K2?, V2?)): {[K2]: V2} local result = {} for key, value in map do local newKey, newValue = mapFn(key, value) if newKey ~= nil and newValue ~= nil then result[newKey] = newValue end end return result end return mapEntrie...
108
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauDisk/map/mapValues.luau
luau
.luau
local None = require("../None") local function mapValues<K, V, W>(map: {[K]: V}, mapFn: (value: V, key: K) -> W?): {[K]: W} local result = {} for key, value in map do local newValue = mapFn(value, key) if newValue ~= nil and newValue ~= (None :: any) then result[key] = newValue end end return result end...
102
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauDisk/map/merge.luau
luau
.luau
local None = require("../None") local function merge<T, U...>(...: U...): any local first = nil local firstIndex = nil local length = select("#", ...) for i = 1, length do local mergeMap = select(i, ...) if mergeMap ~= nil then firstIndex = i first = mergeMap break end end if first == nil then ...
474
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauDisk/map/remove.luau
luau
.luau
local isEmpty = require("./isEmpty") local function remove<K, V>(map: {[K]: V}, ...: K?) local removeLength = select("#", ...) if removeLength == 0 or isEmpty(map) then return map else local result = nil for i = 1, removeLength do local key: K = select(i, ...) if key ~= nil and map[key] ~= nil then ...
128
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauDisk/map/values.luau
luau
.luau
local function values<K, V>(map: {[K]: V}): {V} local result = {} for _, value in map do table.insert(result, value) end return result end return values
45
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauDisk/set/fromArray.luau
luau
.luau
local type = require("./type") type Set<T> = type.Set<T> local function fromArray<T>(array: {T}): Set<T> local set: Set<T> = {} for _, element in array do set[element] = true end return set end return fromArray
63
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauDisk/set/type.luau
luau
.luau
export type Set<T> = {[T]: true} return nil
14
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPath/Component.luau
luau
.luau
--!optimize 2 local Prefix = require("./Prefix") local sysPath = require("./sys/path") local MAIN_SEPARATOR_STR = sysPath.MAIN_SEPARATOR_STR type Prefix = Prefix.Prefix export type PrefixComponent = { type: "prefix", raw: string, parsed: Prefix, } type NormalComponent = {type: "normal", value: string} type Comp...
658
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPath/Prefix.luau
luau
.luau
--!nolint LocalShadow --!optimize 2 --# selene:allow(shadowing) export type PrefixEnum = | {type: "Verbatim", value: string} | {type: "VerbatimUNC", hostName: string, shareName: string} | {type: "VerbatimDisk", value: string} | {type: "DeviceNS", value: string} | {type: "UNC", hostName: string, shareName: string}...
1,137
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPath/Rev.luau
luau
.luau
--!nolint LocalShadow --!optimize 2 --# selene:allow(shadowing) local function FromFunction<T>(generator: (index: number) -> T?): {T} local array = {} local length = 0 while true do local value = generator(length + 1) if value == nil then break end length += 1 array[length] = value end return arra...
595
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPath/init.luau
luau
.luau
--!optimize 2 local Path = require("@self/Path") type PrefixEnum = | {type: "Verbatim", value: string} | {type: "VerbatimUNC", hostName: string, shareName: string} | {type: "VerbatimDisk", value: string} | {type: "DeviceNS", value: string} | {type: "UNC", hostName: string, shareName: string} | {type: "Disk", va...
1,141
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPath/iterAfter.luau
luau
.luau
--!optimize 2 local Component = require("./Component") type Component = Component.Component type ComponentIterator = {next: (self: ComponentIterator) -> Component?} type Clone<T> = {clone: (T) -> T} local function iterAfter<T>( iter: T & ComponentIterator & Clone<ComponentIterator>, prefix: T & ComponentIterator ...
217
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPath/sys/path/PrefixParser.luau
luau
.luau
--!nolint LocalShadow --!optimize 2 --# selene:allow(shadowing) local PrefixParserSlice = require("./PrefixParserSlice") type PrefixParserSlice = PrefixParserSlice.PrefixParserSlice export type PrefixParser = { asSlice: (self: PrefixParser) -> PrefixParserSlice, } type Private = { _path: string, _prefix: string,...
323
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPath/sys/path/PrefixParserSlice.luau
luau
.luau
--!nolint LocalShadow --!optimize 2 --# selene:allow(shadowing) export type PrefixParserSlice = { stripPrefix: (self: PrefixParserSlice, prefix: string) -> PrefixParserSlice?, prefixBytes: (self: PrefixParserSlice) -> string, finish: (self: PrefixParserSlice) -> string, } type Private = { _path: string, _prefix:...
427
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPath/sys/path/init.luau
luau
.luau
--!nolint LocalShadow --!optimize 2 local Prefix = require("../../Prefix") local parsePrefixWindows = require("@self/parsePrefix") type Prefix = Prefix.Prefix local MAIN_SEPARATOR_STR = if _G.SYS_PATH_SEPARATOR == "\\" or _G.SYS_PATH_SEPARATOR == "/" then _G.SYS_PATH_SEPARATOR elseif (_G.LUA_ENV == "lune" or strin...
352
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/AssertionError/init.luau
luau
.luau
--!optimize 2 --!strict local AssertionErrorModule = require("@self/AssertionErrorGlobal") export type AssertionError = AssertionErrorModule.AssertionError return AssertionErrorModule.AssertionError
39
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/Boolean/init.luau
luau
.luau
--!optimize 2 --!strict return table.freeze({ toJSBoolean = require("@self/toJSBoolean"); })
26
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/Boolean/toJSBoolean.luau
luau
.luau
--!optimize 2 --!strict local Number = require("../Number") -- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean return function(value: any): boolean return not not value and value ~= 0 and value ~= "" and not Number.isNaN(value) end
68
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/Collections/Array/concat.luau
luau
.luau
--!optimize 2 --!strict local isArray = require("./isArray") local types = require("@packages/ES7Types") local __DEV__ = _G.__DEV__ type Array<T> = types.Array<T> local RECEIVED_OBJECT_ERROR = "Array.concat(...) only works with array-like tables but " .. "it received an object-like table.\nYou can avoid this error b...
445
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/Collections/Array/every.luau
luau
.luau
--!optimize 2 --!strict local types = require("@packages/ES7Types") local __DEV__ = _G.__DEV__ type Array<T> = types.Array<T> type Object = types.Object type callbackFn<T> = (element: T, index: number, array: Array<T>) -> boolean type callbackFnWithThisArg<T, U> = (self: U, element: T, index: number, array: Array<T>)...
360
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/Collections/Array/filter.luau
luau
.luau
--!optimize 2 --!strict local types = require("@packages/ES7Types") local __DEV__ = _G.__DEV__ type Array<T> = types.Array<T> type Object = types.Object type callbackFn<T> = (element: T, index: number, array: Array<T>) -> boolean type callbackFnWithThisArg<T, U> = (thisArg: U, element: T, index: number, array: Array<T...
408
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/Collections/Array/find.luau
luau
.luau
--!optimize 2 --!strict local types = require("@packages/ES7Types") type Array<T> = types.Array<T> type PredicateFunction<T> = (value: T, index: number, array: Array<T>) -> boolean return function<T>(array: Array<T>, predicate: PredicateFunction<T>): T? -- for i = 1, #array do -- local element = array[i] -- if p...
152
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/Collections/Array/findIndex.luau
luau
.luau
--!optimize 2 --!strict local types = require("@packages/ES7Types") type Array<T> = types.Array<T> type PredicateFunction<T> = (T, number, Array<T>) -> boolean return function<T>(array: Array<T>, predicate: PredicateFunction<T>): number -- for i = 1, #array do -- local element = array[i] -- if predicate(element,...
147
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/Collections/Array/flat.luau
luau
.luau
--!optimize 2 --!strict local isArray = require("./isArray") local types = require("@packages/ES7Types") local __DEV__ = _G.__DEV__ type Array<T> = types.Array<T> local function flat<T>(array: Array<T>, depth_: number?): Array<T> if __DEV__ then if type(array) ~= "table" then error(string.format("Array.flat ca...
248
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/Collections/Array/flatMap.luau
luau
.luau
--!optimize 2 --!strict local flat = require("./flat") local map = require("./map") local types = require("@packages/ES7Types") local __DEV__ = _G.__DEV__ type Array<T> = types.Array<T> type callbackFn<T, U> = (element: T, index: number, array: Array<T>) -> U type callbackFnWithThisArg<T, U, V> = (thisArg: V, elemen...
234
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/Collections/Array/forEach.luau
luau
.luau
--!optimize 2 --!strict local types = require("@packages/ES7Types") local __DEV__ = _G.__DEV__ type Array<T> = types.Array<T> type Object = types.Object type callbackFn<T> = (element: T, index: number, array: Array<T>) -> () type callbackFnWithThisArg<T, U> = (thisArg: U, element: T, index: number, array: Array<T>) ->...
354
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/Collections/Array/from.luau
luau
.luau
--!optimize 2 --!strict local ES7Types = require("@packages/ES7Types") local InstanceOf = require("@packages/InstanceOf") local Map = require("../Map/Map") local Set = require("../Set") local fromString = require("./fromString") local isArray = require("./isArray") type Array<T> = ES7Types.Array<T> type Map<K, V> = ...
1,138
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/Collections/Array/fromString.luau
luau
.luau
--!optimize 2 --!strict local ES7Types = require("@packages/ES7Types") type Object = ES7Types.Object type FromStringFunction<T, U> = (element: T, index: number) -> U type FromStringThisFunction<T, U> = (thisArg: any, element: T, index: number) -> U local function FromString<T, U>( value: string, callback: FromStri...
293
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/Collections/Array/includes.luau
luau
.luau
--!optimize 2 --!strict local indexOf = require("./indexOf") local types = require("@packages/ES7Types") type Array<T> = types.Array<T> return function<T>(array: Array<T>, searchElement: T, fromIndex: number?): boolean return indexOf(array, searchElement, fromIndex) ~= -1 end
74
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/Collections/Array/indexOf.luau
luau
.luau
--!optimize 2 --!strict local types = require("@packages/ES7Types") type Array<T> = types.Array<T> -- Implements equivalent functionality to JavaScript's `array.indexOf`, -- implementing the interface and behaviors defined at: -- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/i...
253
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/Collections/Array/init.luau
luau
.luau
--!optimize 2 --!strict export type Array<T> = {T} return table.freeze({ concat = require("@self/concat"); every = require("@self/every"); filter = require("@self/filter"); find = require("@self/find"); findIndex = require("@self/findIndex"); flat = require("@self/flat"); flatMap = require("@self/flatMap"); f...
213
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/Collections/Array/isArray.luau
luau
.luau
--!optimize 2 --!strict return function(value: any): boolean if type(value) ~= "table" then return false end if next(value) == nil then -- an empty table is an empty array return true end local length = #value if length == 0 then return false end local count = 0 local sum = 0 for key in next, val...
169
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/Collections/Array/join.luau
luau
.luau
--!optimize 2 --!strict local map = require("./map") type Array<T> = {T} return function<T>(arr: {T}, separator: string?): string if #arr == 0 then return "" end -- JS does tostring conversion implicitely but in Lua we need to do that explicitely return table.concat(map(arr, tostring), separator or ",") end
86
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/Collections/Array/map.luau
luau
.luau
--!optimize 2 --!strict local types = require("@packages/ES7Types") local __DEV__ = _G.__DEV__ type Array<T> = types.Array<T> type Object = types.Object type callbackFn<T, U> = (element: T, index: number, array: Array<T>) -> U type callbackFnWithThisArg<T, U, V> = (thisArg: V, element: T, index: number, array: Array<T...
375
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/Collections/Array/reduce.luau
luau
.luau
--!optimize 2 --!strict local types = require("@packages/ES7Types") local __DEV__ = _G.__DEV__ type Array<T> = types.Array<T> type reduceFn<T, U> = (previousValue: U, currentValue: T, currentIndex: number, array: Array<T>) -> U -- Implements Javascript's `Array.prototype.reduce` as defined below -- https://developer....
325
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/Collections/Array/reverse.luau
luau
.luau
--!optimize 2 --!strict -- https://programming-idioms.org/idiom/19/reverse-a-list/1314/lua local types = require("@packages/ES7Types") type Array<T> = types.Array<T> return function<T>(t: Array<T>): Array<T> local n = #t local i = 1 while i < n do t[i], t[n] = t[n], t[i] i += 1 n -= 1 end return t end
116
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/Collections/Array/shift.luau
luau
.luau
--!optimize 2 --!strict local isArray = require("./isArray") local types = require("@packages/ES7Types") local __DEV__ = _G.__DEV__ type Array<T> = types.Array<T> return function<T>(value: Array<T>): T? if __DEV__ and not isArray(value) then error(string.format("Array.shift called on non-array %s", typeof(value)))...
108
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/Collections/Array/slice.luau
luau
.luau
--!optimize 2 --!strict local types = require("@packages/ES7Types") type Array<T> = types.Array<T> -- Implements Javascript's `Array.prototype.slice` as defined below, but with 1-indexing -- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice return function<T>(t: Array<T>, st...
308
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/Collections/Array/some.luau
luau
.luau
--!optimize 2 --!strict local types = require("@packages/ES7Types") type Array<T> = types.Array<T> type Object = types.Object -- note: JS version can return anything that's truthy, but that won't work for us since Lua deviates (0 is truthy) type callbackFn<T> = (element: T, index: number, array: Array<T>) -> boolean ...
335
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/Collections/Array/sort.luau
luau
.luau
--!optimize 2 --!strict local None = require("../Object/None") local types = require("@packages/ES7Types") type Array<T> = types.Array<T> type Comparable = (any, any) -> number local defaultSort = function<T>(a: T, b: T): boolean return type(a) .. tostring(a) < type(b) .. tostring(b) end return function<T>(array: A...
289
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/Collections/Array/splice.luau
luau
.luau
--!optimize 2 --!strict local types = require("@packages/ES7Types") type Array<T> = types.Array<T> -- Implements equivalent functionality to JavaScript's `array.splice`, including -- the interface and behaviors defined at: -- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splic...
447
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/Collections/Array/unshift.luau
luau
.luau
--!optimize 2 --!strict local isArray = require("./isArray") local types = require("@packages/ES7Types") local __DEV__ = _G.__DEV__ type Array<T> = types.Array<T> return function<T>(array: Array<T>, ...: T): number if __DEV__ and not isArray(array) then error(string.format("Array.unshift called on non-array %s", ...
153
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/Collections/Map/Map.luau
luau
.luau
--!optimize 2 --!strict local ES7Types = require("@packages/ES7Types") local InstanceOf = require("@packages/InstanceOf") local arrayForEach = require("../Array/forEach") local arrayMap = require("../Array/map") local isArray = require("../Array/isArray") local __DEV__ = _G.__DEV__ type Object = ES7Types.Object typ...
1,426
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/Collections/Map/coerceToMap.luau
luau
.luau
--!optimize 2 --!strict local Map = require("./Map") local Object = require("../Object") local instanceOf = require("@packages/InstanceOf") local types = require("@packages/ES7Types") type Map<K, V> = types.Map<K, V> type Table<K, V> = types.Table<K, V> local function coerceToMap(mapLike: Map<any, any> | Table<any, ...
149
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/Collections/Map/coerceToTable.luau
luau
.luau
--!optimize 2 --!strict local Map = require("./Map") local arrayReduce = require("../Array/reduce") local instanceOf = require("@packages/InstanceOf") local types = require("@packages/ES7Types") type Map<K, V> = types.Map<K, V> type Table<K, V> = types.Table<K, V> local function coerceToTable(mapLike: Map<any, any> ...
168
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/Collections/Map/init.luau
luau
.luau
--!optimize 2 --!strict local ES7Types = require("@packages/ES7Types") local Map = require("@self/Map") local coerceToMap = require("@self/coerceToMap") local coerceToTable = require("@self/coerceToTable") export type Map<K, V> = ES7Types.Map<K, V> return table.freeze({ Map = Map; coerceToMap = coerceToMap; coerc...
103
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/Collections/Object/None.luau
luau
.luau
--!optimize 2 --!strict -- Marker used to specify that the value is nothing, because nil cannot be -- stored in tables. local None = newproxy(true) local metatable = getmetatable(None) metatable.__tostring = function() return "Object.None" end return None
63
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/Collections/Object/assign.luau
luau
.luau
--!optimize 2 --! local None = require("./None") local types = require("@packages/ES7Types") type Object = types.Object --[[ Merges values from zero or more tables onto a target table. If a value is set to None, it will instead be removed from the table. This function is identical in functionality to JavaScript'...
519
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/Collections/Object/freeze.luau
luau
.luau
--!optimize 2 --!strict local types = require("@packages/ES7Types") type Array<T> = types.Array<T> type Object = types.Object return function<T>(t: T & (Object | Array<any>)): T -- Luau FIXME: model freeze better so it passes through the type constraint and doesn't erase return (table.freeze(t :: any) :: any) :: T ...
90
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/Collections/Object/init.luau
luau
.luau
--!optimize 2 --!strict return table.freeze({ assign = require("@self/assign"); entries = require("@self/entries"); freeze = require("@self/freeze"); is = require("@self/is"); isFrozen = require("@self/isFrozen"); keys = require("@self/keys"); preventExtensions = require("@self/preventExtensions"); seal = requ...
131
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/Collections/Object/is.luau
luau
.luau
--!optimize 2 --!strict -- Implements Javascript's `Object.is` as defined below -- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is return function(value1: any, value2: any): boolean return if value1 == value2 then value1 ~= 0 or 1 / value1 == 1 / value2 else value1 ~= value...
97
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/Collections/Object/isFrozen.luau
luau
.luau
--!optimize 2 --!strict local types = require("@packages/ES7Types") type Array<T> = types.Array<T> type Object = types.Object local __DEV__ = _G.__DEV__ return function(t: Object | Array<any>): boolean if __DEV__ then print("Luau now has a direct table.isfrozen call that can save the overhead of this library func...
99
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/Collections/Object/keys.luau
luau
.luau
--!optimize 2 --!strict local ES7Types = require("@packages/ES7Types") local InstanceOf = require("@packages/InstanceOf") local Set = require("../Set") type Array<T> = ES7Types.Array<T> type Set<T> = ES7Types.Set<T> type Table = {[any]: any} return function(value: Set<any> | Table | string): Array<string> if value ...
215
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/Collections/Object/preventExtensions.luau
luau
.luau
--!optimize 2 --!strict local types = require("@packages/ES7Types") type Array<T> = types.Array<T> type Object = types.Object -- FIXME: This should be updated to be closer to the actual -- `Object.preventExtensions` functionality in JS. This requires additional -- support from the VM local function preventExtensions<...
168
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/Collections/Object/values.luau
luau
.luau
--!optimize 2 --!strict local types = require("@packages/ES7Types") type Array<T> = types.Array<T> -- TODO Luau: needs overloads to model this more correctly return function<T>(value: {[string]: T} | Array<T> | string): Array<T> | Array<string> if value == nil then error("cannot extract values from a nil value") ...
229
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/Collections/Set.luau
luau
.luau
--!optimize 2 --!nonstrict local arrayForEach = require("./Array/forEach") local arrayFromString = require("./Array/fromString") local inspect = require("./inspect") local isArray = require("./Array/isArray") local types = require("@packages/ES7Types") local __DEV__ = _G.__DEV__ type Array<T> = types.Array<T> type O...
1,051
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/Collections/WeakMap.luau
luau
.luau
--!optimize 2 --!strict local ES7Types = require("@packages/ES7Types") type WeakMap<K, V> = ES7Types.WeakMap<K, V> type WeakMapPrivate<K, V> = { _weakMap: {[K]: V}, -- method definitions get: (self: WeakMapPrivate<K, V>, K) -> V, set: (self: WeakMapPrivate<K, V>, K, V) -> WeakMapPrivate<K, V>, has: (self: WeakMa...
296
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/Collections/init.luau
luau
.luau
--!optimize 2 --!strict local Array = require("@self/Array") local Map = require("@self/Map") local Object = require("@self/Object") local Set = require("@self/Set") local WeakMap = require("@self/WeakMap") local inspect = require("@self/inspect") local types = require("@packages/ES7Types") export type Array<T> = typ...
191
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/Console/MakeConsole.luau
luau
.luau
--!optimize 2 --!strict local Chalk = require("@packages/Chalk") local Collections = require("../Collections") local Debug = require("@packages/Debug") local Map = Collections.Map local inspect = Collections.inspect local INDENT = " " local RED = Chalk.Rgb(243, 53, 53) local YELLOW = Chalk.Rgb(243, 174, 53) local...
1,329
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/Console/init.luau
luau
.luau
--!optimize 2 --!strict local MakeConsole = require("@self/MakeConsole") local console = MakeConsole() return console
30
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/Error.luau
luau
.luau
--!optimize 2 --!strict local ES7Types = require("@packages/ES7Types") type Function = ES7Types.Function export type Error = { name: string, message: string, stack: string?, } type Private = Error & {__stack: string?} local Error = {} local DEFAULT_NAME = "Error" Error.__index = Error Error.__tostring = function...
747
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/Math.luau
luau
.luau
--!optimize 2 --!strict return table.freeze({ clz32 = bit32.countlz; })
24
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/Number/MAX_SAFE_INTEGER.luau
luau
.luau
--!optimize 2 --!strict -- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER return 9007199254740991
44
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/Number/MIN_SAFE_INTEGER.luau
luau
.luau
--!optimize 2 --!strict -- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MIN_SAFE_INTEGER return -9007199254740991
44
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/Number/init.luau
luau
.luau
--!optimize 2 --!strict return table.freeze({ isFinite = require("@self/isFinite"); isInteger = require("@self/isInteger"); isNaN = require("@self/isNaN"); isSafeInteger = require("@self/isSafeInteger"); MAX_SAFE_INTEGER = require("@self/MAX_SAFE_INTEGER"); MIN_SAFE_INTEGER = require("@self/MIN_SAFE_INTEGER"); ...
99
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/Number/isFinite.luau
luau
.luau
--!optimize 2 --!strict return function(value: unknown) return type(value) == "number" and value == value and value ~= math.huge and value ~= -math.huge end
44
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/Number/isInteger.luau
luau
.luau
--!optimize 2 --!strict -- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger return function(value: unknown) return type(value) == "number" and value ~= math.huge and value == math.floor(value) end
62
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/Number/isNaN.luau
luau
.luau
--!optimize 2 --!strict -- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isNaN return function(value: unknown) return type(value) == "number" and value ~= value end
54
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/Number/isSafeInteger.luau
luau
.luau
--!optimize 2 --!strict -- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger local MAX_SAFE_INTEGER = require("./MAX_SAFE_INTEGER") local isInteger = require("./isInteger") return function(value: unknown) return isInteger(value) and math.abs(value :: number) <= MAX...
79
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/Number/toExponential.luau
luau
.luau
--!optimize 2 --!strict -- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toExponential return function(value: number | string, fractionDigits: number?): string? local num = value if type(value) == "string" then -- ROBLOX FIXME: add parseInt to encapsulate this logic and us...
285
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/Promise.luau
luau
.luau
--!optimize 2 -- this maps onto community promise libraries which won't support Luau, so we inline local Promise = require("@packages/Promise") export type PromiseLike<T> = { Then: ( self: PromiseLike<T>, resolve: ((T) -> ...(nil | T | PromiseLike<T>))?, reject: ((any) -> ...(nil | T | PromiseLike<T>))? ) -> ...
112
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/String/charCodeAt.luau
luau
.luau
--!optimize 2 --!strict local Number = require("../Number") local NaN = Number.NaN -- js https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charCodeAt -- lua http://www.lua.org/manual/5.4/manual.html#pdf-utf8.codepoint return function(value: string, index: number): number if typ...
245
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/String/endsWith.luau
luau
.luau
--!optimize 2 --!strict local function endsWith(value: string, substring: string, optionalLength: number?): boolean local substringLength = #substring if substringLength == 0 then return true end local valueLength = #value local length = optionalLength or valueLength if length > valueLength then length = va...
125
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/String/findOr.luau
luau
.luau
--!optimize 2 --!strict type Match = { index: number, match: string, } -- excluding the `+` and `*` character, since findOr tests and graphql use them explicitly local luauPatternCharacters = "([" .. string.gsub("$%^()-[].?", "(.)", "%%%1") .. "])" local function findOr(value: string, patternTable: {string}, initi...
425
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/String/includes.luau
luau
.luau
--!optimize 2 --!strict -- excluding the `+` and `*` character, since findOr tests and graphql use them explicitly local luauPatternCharacters = "([" .. string.gsub("$%^()-[].?", "(.)", "%%%1") .. "])" local function includes(value: string, substring: string, position: nil | number | string): boolean local stringLen...
248
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/String/indexOf.luau
luau
.luau
--!optimize 2 --!strict -- excluding the `+` and `*` character, since findOr tests and graphql use them explicitly local luauPatternCharacters = "([" .. string.gsub("$%^()-[].?", "(.)", "%%%1") .. "])" -- Implements equivalent functionality to JavaScript's `String.indexOf`, -- implementing the interface and behaviors...
274
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/String/init.luau
luau
.luau
--!optimize 2 --!strict return table.freeze({ charCodeAt = require("@self/charCodeAt"); endsWith = require("@self/endsWith"); findOr = require("@self/findOr"); includes = require("@self/includes"); indexOf = require("@self/indexOf"); lastIndexOf = require("@self/lastIndexOf"); slice = require("@self/slice"); s...
169
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/String/lastIndexOf.luau
luau
.luau
--!optimize 2 --!strict local function lastIndexOf(value: string, searchValue: string, fromIndex: number?): number local valueLength = #value local calculatedFromIndex if fromIndex then calculatedFromIndex = fromIndex else calculatedFromIndex = valueLength end if fromIndex and fromIndex < 1 then calculate...
322
howmanysmall/modern-roblox-ts-template
howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/String/slice.luau
luau
.luau
--!optimize 2 --!strict local function slice(value: string, startIndexStr: string | number, lastIndexStr: (string | number)?): string local strLen, invalidBytePosition = utf8.len(value) assert(strLen ~= nil, string.format("string `%*` has an invalid byte at position %*", value, invalidBytePosition)) local startInd...
333