repo stringclasses 254
values | file_path stringlengths 29 241 | code stringlengths 100 233k | tokens int64 14 69.4k |
|---|---|---|---|
howmanysmall/modern-roblox-ts-template | howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauDisk/array/sum.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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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/LuauPath/Component.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 | --!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 | --!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 | --!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 | --!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 | --!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 | --!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 | --!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 | --!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/toJSBoolean.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 | --!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 | --!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 | --!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 | --!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 | --!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 | --!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 | --!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 | --!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 | --!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 | --!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 | --!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 | --!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 | --!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 | --!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 | --!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 | --!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 | --!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 | --!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 | --!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 | --!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 | --!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 | --!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 | --!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 | --!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 | --!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 | --!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 | --!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 | --!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 | --!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 | --!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 | --!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 | --!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 | --!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 | --!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 | --!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 | --!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 | --!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 | --!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 | --!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 | --!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 | --!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 | --!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 | --!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/Number/MAX_SAFE_INTEGER.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 | --!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 | --!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 | --!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 | --!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 | --!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 | --!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 | --!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 | --!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 | --!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 | --!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 | --!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 | --!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 | --!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 | --!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 | --!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 | --!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 |
howmanysmall/modern-roblox-ts-template | howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/String/split.luau | --!optimize 2
--!strict
local Number = require("../Number")
local findOr = require("./findOr")
local slice = require("./slice")
local MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER
type Array<T> = {T}
type Pattern = string | Array<string>
local function split(str: string, _pattern: Pattern?, _limit: number?): Array<str... | 484 |
howmanysmall/modern-roblox-ts-template | howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/String/startsWith.luau | --!optimize 2
--!strict
local function startsWith(value: string, substring: string, position: number?): boolean
if #substring == 0 then
return true
end
-- Luau FIXME: we have to use a tmp variable, as Luau doesn't understand the logic below narrow position to `number`
local position_
if position == nil or posit... | 136 |
howmanysmall/modern-roblox-ts-template | howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/String/substr.luau | --!optimize 2
--!strict
return function(value: string, startIndex: number, numberOfCharacters: number?): string
if numberOfCharacters and numberOfCharacters <= 0 then
return ""
end
return string.sub(value, startIndex, numberOfCharacters and startIndex + numberOfCharacters - 1 or nil)
end
| 65 |
howmanysmall/modern-roblox-ts-template | howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/String/trim.luau | --!optimize 2
--!strict
local trimEnd = require("./trimEnd")
local trimStart = require("./trimStart")
return function(source: string): string
return trimStart(trimEnd(source))
end
| 45 |
howmanysmall/modern-roblox-ts-template | howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/String/trimEnd.luau | --!optimize 2
--!strict
return function(source: string): string
return (string.gsub(source, "[%s]+$", ""))
end
| 31 |
howmanysmall/modern-roblox-ts-template | howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/String/trimStart.luau | --!optimize 2
--!strict
return function(source: string): string
return (string.gsub(source, "^[%s]+", ""))
end
| 32 |
howmanysmall/modern-roblox-ts-template | howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/Symbol/RegistryGlobal.luau | --!optimize 2
--!strict
local Symbol = require("./Symbol")
local GlobalRegistry: {[string]: Symbol.Symbol} = {}
return table.freeze({
getOrInit = function(name: string): Symbol.Symbol
if GlobalRegistry[name] == nil then
GlobalRegistry[name] = Symbol.new(name)
end
return GlobalRegistry[name]
end;
-- Use... | 96 |
howmanysmall/modern-roblox-ts-template | howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/Symbol/Symbol.luau | --!optimize 2
--!strict
--[[
Symbols have the type 'userdata', but when printed or coerced to a string,
the symbol will turn into the string given as its name.
**This implementation provides only the `Symbol()` constructor and the
global registry via `Symbol.for_`.**
Other behaviors, including the ability to fin... | 176 |
howmanysmall/modern-roblox-ts-template | howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/Symbol/init.luau | --!optimize 2
--!strict
--[[
A 'Symbol' is an opaque marker type, implemented to behave similarly to JS:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol
]]
local GlobalRegistry = require("@self/RegistryGlobal")
local Symbol = require("@self/Symbol")
export type Symbol = Symbo... | 175 |
howmanysmall/modern-roblox-ts-template | howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/Timers/init.luau | --!optimize 2
--!strict
local task = require("@lune/task")
local MakeInterval = require("@self/makeIntervalImpl")
local MakeTimer = require("@self/makeTimerImpl")
export type Timeout = MakeTimer.Timeout
export type Interval = MakeInterval.Interval
local Interval = MakeInterval(task.delay)
local Timer = MakeTimer(ta... | 113 |
howmanysmall/modern-roblox-ts-template | howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/Timers/makeIntervalImpl.luau | --!optimize 2
--!strict
local Status = newproxy(false)
type TaskStatus = number
export type Interval = {[typeof(Status)]: TaskStatus}
local SCHEDULED = 1
local CANCELLED = 3
return function(taskDelay)
local function setInterval(callback, intervalTime: number?, ...): Interval
local arguments = {...}
local inter... | 265 |
howmanysmall/modern-roblox-ts-template | howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/Timers/makeTimerImpl.luau | --!optimize 2
local Status = newproxy(false)
type TaskStatus = number
export type Timeout = {[typeof(Status)]: TaskStatus}
local SCHEDULED = 1
local DONE = 2
local CANCELLED = 3
return function(taskDelay)
local function setTimeout(callback, delayTime: number?, ...): Timeout
local arguments = {...}
local timeout... | 256 |
howmanysmall/modern-roblox-ts-template | howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/encodeURIComponent.luau | --!optimize 2
--!strict
-- reference documentation: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent
local Error = require("./Error")
local String = require("./String")
local net = require("@lune/net")
local charCodeAt = String.charCodeAt
local function encodeURICom... | 385 |
howmanysmall/modern-roblox-ts-template | howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/extends.luau | --!optimize 2
--!strict
--[[
deviation: Our constructors currently have no notion of 'super' so any
such behavior in upstream JS must be implemented manually by setting fields
A constructor passed to this class would typically look along the lines of:
function(self, arg, otherArg)
self.arg = arg
self.otherArg... | 294 |
howmanysmall/modern-roblox-ts-template | howmanysmall-modern-roblox-ts-template-8515fd5/.lune/Packages/LuauPolyfill/init.luau | --!optimize 2
--!strict
local AssertionError = require("@self/AssertionError")
local Boolean = require("@self/Boolean")
local Collections = require("@self/Collections")
local Console = require("@self/Console")
local Error = require("@self/Error")
local Math = require("@self/Math")
local Number = require("@self/Number"... | 428 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.