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 |
|---|---|---|---|---|---|
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/GreenTea/init.luau | luau | .luau | --!optimize 2
--!strict
local GreenTea = require("./GreenTea")
local tCompat = require("./tCompat")
export type Cause = GreenTea.Cause
export type Type = GreenTea.Type
export type TuplePacked<T...> = GreenTea.TuplePacked<T...>
local export = {}
export.t = tCompat
export.isGreenTeaType = GreenTea.isGreenTeaType
exp... | 591 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/GreenTea/tCompat.luau | luau | .luau | --!optimize 2
--!strict
local GreenTea = require("./GreenTea")
local t = {}
type Typechecker = (...any) -> (boolean, any?)
type TypecheckerConstr<T... = ()> = (T...) -> Typechecker
local function asPlainFn(fn: (...any) -> ...any): Typechecker
return function()
return fn()
end
end
local function asGreenTeaType... | 2,380 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/GreenTeaUtilities/EasyLiteral.luau | luau | .luau | --!optimize 2
--!strict
local GreenTea = require("../GreenTea")
local function EasyLiteral<T>(...: any)
local count = select("#", ...)
local array = table.create(count)
for index = 1, count do
local value = select(index, ...)
array[index] = GreenTea.literal(value)
end
return GreenTea.union(table.unpack(arr... | 93 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/GreenTeaUtilities/IntersectionPlus.luau | luau | .luau | --!optimize 2
--!strict
local GreenTea = require("../GreenTea")
type IntersectionType =
(<T1, T2>(T1, T2) -> T1 & T2)
& (<T1, T2, T3>(T1, T2, T3) -> T1 & T2 & T3)
& (<T1, T2, T3, T4>(T1, T2, T3, T4) -> T1 & T2 & T3 & T4)
& (<T1, T2, T3, T4, T5>(T1, T2, T3, T4, T5) -> T1 & T2 & T3 & T4 & T5)
& (<T1, T2, T3, T4, T... | 596 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/GreenTeaUtilities/UnionPlus.luau | luau | .luau | --!optimize 2
--!strict
local GreenTea = require("../GreenTea")
type UnionType =
(<T1, T2>(T1, T2) -> T1 | T2)
& (<T1, T2, T3>(T1, T2, T3) -> T1 | T2 | T3)
& (<T1, T2, T3, T4>(T1, T2, T3, T4) -> T1 | T2 | T3 | T4)
& (<T1, T2, T3, T4, T5>(T1, T2, T3, T4, T5) -> T1 | T2 | T3 | T4 | T5)
& (<T1, T2, T3, T4, T5, T6>(... | 596 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/GreenTeaUtilities/init.luau | luau | .luau | --!optimize 2
--!strict
local EasyLiteral = require("./EasyLiteral")
local IntersectionPlus = require("./IntersectionPlus")
local UnionPlus = require("./UnionPlus")
local GreenTeaUtilities = table.freeze({
EasyLiteral = EasyLiteral;
Intersection = IntersectionPlus;
IntersectionPlus = IntersectionPlus;
Union = Uni... | 86 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauDisk/init.luau | luau | .luau | local setType = require("./set/type")
export type Set<T> = setType.Set<T>
local Disk = {
Array = {
all = require("./array/all");
alternate = require("./array/alternate");
any = require("./array/any");
average = require("./array/average");
averageBy = require("./array/averageBy");
concat = require("./arra... | 638 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPath/Prefix.luau | luau | .luau | --!nolint LocalShadow
--!optimize 2
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}
| {type: "Disk", value: stri... | 1,135 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPath/Rev.luau | luau | .luau | --!nolint LocalShadow
--!optimize 2
local Disk = require("@packages/LuauDisk")
local Array = Disk.Array
export type Rev<T> = {
next: (self: Rev<T>) -> T?,
collect: (self: Rev<T>) -> {T},
rev: (self: Rev<T>) -> Rev<T>,
-- DoubleEndedIterator
nextBack: (self: Rev<T>) -> T?,
clone: (self: Rev<T>) -> Rev<T>,
}
t... | 525 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPath/init.luau | luau | .luau | --!optimize 2
local Path = require("./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", value: s... | 1,136 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPath/sys/path/PrefixParser.luau | luau | .luau | --!nolint LocalShadow
--!optimize 2
local PrefixParserSlice = require("./PrefixParserSlice")
type PrefixParserSlice = PrefixParserSlice.PrefixParserSlice
export type PrefixParser = {
asSlice: (self: PrefixParser) -> PrefixParserSlice,
}
type Private = {
_path: string,
_prefix: string,
_length: number,
}
type Pr... | 313 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPath/sys/path/PrefixParserSlice.luau | luau | .luau | --!nolint LocalShadow
--!optimize 2
export type PrefixParserSlice = {
stripPrefix: (self: PrefixParserSlice, prefix: string) -> PrefixParserSlice?,
prefixBytes: (self: PrefixParserSlice) -> string,
finish: (self: PrefixParserSlice) -> string,
}
type Private = {
_path: string,
_prefix: string,
_index: number,
}
... | 417 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPath/sys/path/init.luau | luau | .luau | --!nolint LocalShadow
--!optimize 2
local Prefix = require("../../Prefix")
local parsePrefixWindows = require("./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" and (require ... | 323 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/AssertionError/init.luau | luau | .luau | --!native
--!optimize 2
--!strict
local AssertionErrorModule = require("./AssertionErrorGlobal")
export type AssertionError = AssertionErrorModule.AssertionError
return AssertionErrorModule.AssertionError
| 41 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Boolean/init.luau | luau | .luau | --!native
--!optimize 2
--!strict
return {
toJSBoolean = require("./toJSBoolean");
}
| 27 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Boolean/toJSBoolean.luau | luau | .luau | --!native
--!optimize 2
--!strict
local Number = require("../Number")
-- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean
return function(val: any): boolean
return not not val and val ~= 0 and val ~= "" and not Number.isNaN(val)
end
| 72 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Collections/Array/concat.luau | luau | .luau | --!native
--!optimize 2
--!strict
local isArray = require("./isArray")
local types = require("../../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 e... | 447 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Collections/Array/every.luau | luau | .luau | --!native
--!optimize 2
--!strict
local types = require("../../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: Arra... | 362 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Collections/Array/filter.luau | luau | .luau | --!native
--!optimize 2
--!strict
local types = require("../../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: Ar... | 410 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Collections/Array/find.luau | luau | .luau | --!native
--!optimize 2
--!strict
local types = require("../../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]
--... | 154 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Collections/Array/findIndex.luau | luau | .luau | --!native
--!optimize 2
--!strict
local types = require("../../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(ele... | 149 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Collections/Array/flat.luau | luau | .luau | --!native
--!optimize 2
local isArray = require("./isArray")
local types = require("../../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 called ... | 246 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Collections/Array/flatMap.luau | luau | .luau | --!native
--!optimize 2
local flat = require("./flat")
local map = require("./map")
local types = require("../../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, element: T,... | 232 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Collections/Array/forEach.luau | luau | .luau | --!native
--!optimize 2
--!strict
local types = require("../../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... | 356 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Collections/Array/from/fromArray.luau | luau | .luau | --!native
--!optimize 2
--!strict
local types = require("../../../ES7Types")
type Object = types.Object
type Array<T> = types.Array<T>
type mapFn<T, U> = (element: T, index: number) -> U
type mapFnWithThisArg<T, U> = (thisArg: any, element: T, index: number) -> U
return function<T, U>(
value: Array<T>,
mapFn: (mapFn... | 307 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Collections/Array/from/fromMap.luau | luau | .luau | --!native
--!optimize 2
--!strict
local types = require("../../../ES7Types")
type Object = types.Object
type Array<T> = types.Array<T>
type Map<K, V> = types.Map<K, V>
type mapFn<T, U> = (element: T, index: number) -> U
type mapFnWithThisArg<T, U> = (thisArg: any, element: T, index: number) -> U
return function<T, U>(... | 315 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Collections/Array/from/fromSet.luau | luau | .luau | --!native
--!optimize 2
--!strict
local types = require("../../../ES7Types")
type Object = types.Object
type Array<T> = types.Array<T>
type Set<T> = types.Set<T>
type mapFn<T, U> = (element: T, index: number) -> U
type mapFnWithThisArg<T, U> = (thisArg: any, element: T, index: number) -> U
return function<T, U>(
valu... | 290 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Collections/Array/from/fromString.luau | luau | .luau | --!native
--!optimize 2
--!strict
local types = require("../../../ES7Types")
type Object = types.Object
type Array<T> = types.Array<T>
type mapFn<T, U> = (element: T, index: number) -> U
type mapFnWithThisArg<T, U> = (thisArg: any, element: T, index: number) -> U
return function<T, U>(
value: string,
mapFn: (mapFn<... | 329 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Collections/Array/from/init.luau | luau | .luau | --!native
--!optimize 2
--!strict
local Map = require("../../Map/Map")
local Set = require("../../Set")
local fromArray = require("./fromArray")
local fromMap = require("./fromMap")
local fromSet = require("./fromSet")
local fromString = require("./fromString")
local instanceof = require("../../../InstanceOf")
local i... | 415 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Collections/Array/includes.luau | luau | .luau | --!native
--!optimize 2
--!strict
local indexOf = require("./indexOf")
local types = require("../../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
| 76 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Collections/Array/indexOf.luau | luau | .luau | --!native
--!optimize 2
--!strict
local types = require("../../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/Ar... | 255 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Collections/Array/init.luau | luau | .luau | --!native
--!optimize 2
--!strict
local ES7Types = require("../../ES7Types")
export type Array<T> = ES7Types.Array<T>
return table.freeze({
concat = require("./concat");
every = require("./every");
filter = require("./filter");
find = require("./find");
findIndex = require("./findIndex");
flat = require("./flat... | 194 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Collections/Array/isArray.luau | luau | .luau | --!native
--!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 ... | 173 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Collections/Array/join.luau | luau | .luau | --!native
--!optimize 2
--!strict
local map = require("./map")
local types = require("../../ES7Types")
type Array<T> = types.Array<T>
return function<T>(arr: Array<T>, separator: string?): string
if #arr == 0 then
return ""
end
-- JS does tostring conversion implicitely but in Lua we need to do that explicitely... | 100 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Collections/Array/map.luau | luau | .luau | --!native
--!optimize 2
--!strict
local types = require("../../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: Ar... | 377 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Collections/Array/reduce.luau | luau | .luau | --!native
--!optimize 2
--!strict
local types = require("../../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://devel... | 327 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Collections/Array/reverse.luau | luau | .luau | --!native
--!optimize 2
--!strict
-- https://programming-idioms.org/idiom/19/reverse-a-list/1314/lua
local types = require("../../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
en... | 118 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Collections/Array/shift.luau | luau | .luau | --!native
--!optimize 2
--!strict
local isArray = require("./isArray")
local types = require("../../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(val... | 110 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Collections/Array/slice.luau | luau | .luau | --!native
--!optimize 2
--!strict
local types = require("../../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... | 310 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Collections/Array/some.luau | luau | .luau | --!native
--!optimize 2
--!strict
local types = require("../../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>) -> boo... | 337 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Collections/Array/sort.luau | luau | .luau | --!native
--!optimize 2
--!strict
local None = require("../Object/None")
local types = require("../../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>(arr... | 291 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Collections/Array/splice.luau | luau | .luau | --!native
--!optimize 2
--!strict
local types = require("../../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/... | 449 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Collections/Array/unshift.luau | luau | .luau | --!native
--!optimize 2
--!strict
local isArray = require("./isArray")
local types = require("../../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 ... | 155 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Collections/Map/Map.luau | luau | .luau | --!native
--!optimize 2
--!strict
local arrayForEach = require("../Array/forEach")
local arrayMap = require("../Array/map")
local instanceof = require("../../InstanceOf")
local isArray = require("../Array/isArray")
local types = require("../../ES7Types")
local __DEV__ = _G.__DEV__
type Object = types.Object
type Arra... | 1,411 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Collections/Map/coerceToMap.luau | luau | .luau | --!native
--!optimize 2
local Map = require("./Map")
local Object = require("../Object")
local instanceOf = require("../../InstanceOf")
local types = require("../../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, any>): Ma... | 145 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Collections/Map/coerceToTable.luau | luau | .luau | --!native
--!optimize 2
local Map = require("./Map")
local arrayReduce = require("../Array/reduce")
local instanceOf = require("../../InstanceOf")
local types = require("../../ES7Types")
type Map<K, V> = types.Map<K, V>
type Table<K, V> = types.Table<K, V>
local function coerceToTable(mapLike: Map<any, any> | Table<a... | 164 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Collections/Map/init.luau | luau | .luau | --!native
--!optimize 2
local ES7Types = require("../../ES7Types")
local Map = require("./Map")
local coerceToMap = require("./coerceToMap")
local coerceToTable = require("./coerceToTable")
export type Map<K, V> = ES7Types.Map<K, V>
return table.freeze({
Map = Map;
coerceToMap = coerceToMap;
coerceToTable = coerce... | 97 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Collections/Object/None.luau | luau | .luau | --!native
--!optimize 2
--!nonstrict
-- Marker used to specify that the value is nothing, because nil cannot be
-- stored in tables.
local None = newproxy(true)
local mt = getmetatable(None)
mt.__tostring = function()
return "Object.None"
end
return None
| 67 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Collections/Object/assign.luau | luau | .luau | --!native
--!optimize 2
--!strict
local None = require("./None")
local types = require("../../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 ... | 523 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Collections/Object/freeze.luau | luau | .luau | --!native
--!optimize 2
--!strict
local types = require("../../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) ... | 92 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Collections/Object/init.luau | luau | .luau | --!native
--!optimize 2
--!strict
return table.freeze({
assign = require("./assign");
entries = require("./entries");
freeze = require("./freeze");
is = require("./is");
isFrozen = require("./isFrozen");
keys = require("./keys");
preventExtensions = require("./preventExtensions");
seal = require("./seal");
va... | 119 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Collections/Object/is.luau | luau | .luau | --!native
--!optimize 2
-- 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 ~= value1 ... | 97 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Collections/Object/isFrozen.luau | luau | .luau | --!native
--!optimize 2
--!strict
local __DEV__ = _G.__DEV__
local types = require("../../ES7Types")
type Array<T> = types.Array<T>
type Object = types.Object
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... | 101 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Collections/Object/keys.luau | luau | .luau | --!native
--!optimize 2
local Set = require("../Set")
local instanceOf = require("../../InstanceOf")
local types = require("../../ES7Types")
type Array<T> = types.Array<T>
type Set<T> = types.Set<T>
type Table = {[any]: any}
return function(value: Set<any> | Table | string): Array<string>
if value == nil then
error... | 205 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Collections/Object/preventExtensions.luau | luau | .luau | --!native
--!optimize 2
--!strict
local types = require("../../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 preventExtens... | 171 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Collections/Object/values.luau | luau | .luau | --!native
--!optimize 2
--!strict
local types = require("../../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 valu... | 231 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Collections/Set.luau | luau | .luau | --!native
--!optimize 2
--!nonstrict
local arrayForEach = require("./Array/forEach")
local arrayFromString = require("./Array/from/fromString")
local inspect = require("./inspect")
local isArray = require("./Array/isArray")
local types = require("../ES7Types")
local __DEV__ = _G.__DEV__
type Array<T> = types.Array<T... | 1,054 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Collections/WeakMap.luau | luau | .luau | --!native
--!optimize 2
--!strict
local ES7Types = require("../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: Wea... | 298 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Collections/init.luau | luau | .luau | --!native
--!optimize 2
--!strict
local Array = require("./Array")
local Map = require("./Map")
local Object = require("./Object")
local Set = require("./Set")
local WeakMap = require("./WeakMap")
local inspect = require("./inspect")
local types = require("../ES7Types")
export type Array<T> = types.Array<T>
export ty... | 181 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Console/init.luau | luau | .luau | --!native
--!optimize 2
--!strict
local makeConsoleImpl = require("./makeConsoleImpl")
return makeConsoleImpl()
| 30 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Console/makeConsoleImpl.luau | luau | .luau | --!native
--!optimize 2
--!strict
local Chalk = require("@packages/Chalk")
local Collections = require("../Collections")
local Map = Collections.Map
local inspect = Collections.inspect
local INDENT = " "
local YELLOW = Chalk.Rgb(243, 174, 53)
local function Concat(...)
local length = select("#", ...)
if length ... | 865 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/ES7Types.luau | luau | .luau | --!native
--!optimize 2
--!strict
export type Object = {[string]: any}
export type Array<T> = {[number]: T}
export type Function = (...any) -> ...any
export type Table<T, V> = {[T]: V}
export type Tuple<T, V> = Array<T | V>
export type mapCallbackFn<K, V> = (element: V, key: K, map: Map<K, V>) -> ()
export type mapCal... | 836 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Error.luau | luau | .luau | --!optimize 2
--!strict
local types = require("./ES7Types")
type Function = types.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(self)
-- Lua... | 742 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/InstanceOf.luau | luau | .luau | --!native
--!optimize 2
--!strict
-- polyfill for https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/instanceof
local __DEV__ = _G.__DEV__
-- FIXME Luau: typing class as Object gives: Type '{ @metatable {| __call: <a>(a, ...any) -> Error, __tostring: <b, c>({+ message: b, name: c +}) -> string... | 364 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Math.luau | luau | .luau | --!native
--!optimize 2
--!strict
return {
clz32 = bit32.countlz;
}
| 26 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Number/MAX_SAFE_INTEGER.luau | luau | .luau | --!native
--!optimize 2
--!strict
-- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER
return 9007199254740991
| 48 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Number/MIN_SAFE_INTEGER.luau | luau | .luau | --!native
--!optimize 2
--!strict
-- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MIN_SAFE_INTEGER
return -9007199254740991
| 48 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Number/init.luau | luau | .luau | --!native
--!optimize 2
--!strict
return {
isFinite = require("./isFinite");
isInteger = require("./isInteger");
isNaN = require("./isNaN");
isSafeInteger = require("./isSafeInteger");
MAX_SAFE_INTEGER = require("./MAX_SAFE_INTEGER");
MIN_SAFE_INTEGER = require("./MIN_SAFE_INTEGER");
NaN = 0 / 0;
toExponential ... | 91 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Number/isFinite.luau | luau | .luau | --!native
--!optimize 2
--!strict
return function(value)
return type(value) == "number" and value == value and value ~= math.huge and value ~= -math.huge
end
| 46 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Number/isInteger.luau | luau | .luau | --!native
--!optimize 2
--!strict
-- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger
return function(value)
return type(value) == "number" and value ~= math.huge and value == math.floor(value)
end
| 64 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Number/isNaN.luau | luau | .luau | --!native
--!optimize 2
--!strict
-- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isNaN
return function(value)
return type(value) == "number" and value ~= value
end
| 56 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Number/isSafeInteger.luau | luau | .luau | --!native
--!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)
return isInteger(value) and math.abs(value) <= MAX_SAFE_INTE... | 79 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Number/toExponential.luau | luau | .luau | --!native
--!optimize 2
--!strict
-- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toExponential
return function(value: string | number, fractionDigits: number?): string?
local num = value
if type(value) == "string" then
-- ROBLOX FIXME: add parseInt to encapsulate this log... | 294 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Promise.luau | luau | .luau | --!native
--!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>... | 116 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/String/charCodeAt.luau | luau | .luau | --!native
--!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(str: string, index: number): number... | 263 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/String/endsWith.luau | luau | .luau | --!native
--!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
le... | 129 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/String/findOr.luau | luau | .luau | --!native
--!optimize 2
--!strict
type Match = {
index: number,
match: string,
}
-- excluding the `+` and `*` character, since findOr tests and graphql use them explicitly
local luaPatternCharacters = "([" .. string.gsub("$%^()-[].?", "(.)", "%%%1") .. "])"
local function findOr(str: string, patternTable: {string},... | 425 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/String/includes.luau | luau | .luau | --!native
--!optimize 2
--!strict
-- excluding the `+` and `*` character, since findOr tests and graphql use them explicitly
local luaPatternCharacters = "([" .. string.gsub("$%^()-[].?", "(.)", "%%%1") .. "])"
local function includes(str: string, substring: string, position: (string | number)?): boolean
local strLe... | 252 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/String/indexOf.luau | luau | .luau | --!native
--!optimize 2
--!strict
-- excluding the `+` and `*` character, since findOr tests and graphql use them explicitly
local luaPatternCharacters = "([" .. string.gsub("$%^()-[].?", "(.)", "%%%1") .. "])"
-- Implements equivalent functionality to JavaScript's `String.indexOf`,
-- implementing the interface and ... | 274 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/String/init.luau | luau | .luau | --!native
--!optimize 2
--!strict
return {
charCodeAt = require("./charCodeAt");
endsWith = require("./endsWith");
findOr = require("./findOr");
includes = require("./includes");
indexOf = require("./indexOf");
lastIndexOf = require("./lastIndexOf");
slice = require("./slice");
split = require("./split");
star... | 143 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/String/lastIndexOf.luau | luau | .luau | --!native
--!optimize 2
--!strict
local function lastIndexOf(str: string, searchValue: string, fromIndex: number?): number
local strLength = #str
local calculatedFromIndex
if fromIndex then
calculatedFromIndex = fromIndex
else
calculatedFromIndex = strLength
end
if fromIndex and fromIndex < 1 then
calculat... | 326 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/String/slice.luau | luau | .luau | --!native
--!optimize 2
--!strict
local function slice(str: string, startIndexStr: string | number, lastIndexStr: (string | number)?): string
local strLen, invalidBytePosition = utf8.len(str)
assert(strLen ~= nil, string.format("string `%*` has an invalid byte at position %*", str, `{invalidBytePosition}`))
local s... | 339 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/String/split.luau | luau | .luau | --!native
--!optimize 2
--!strict
local Number = require("../Number")
local findOr = require("./findOr")
local slice = require("./slice")
local types = require("../ES7Types")
local MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER
type Array<T> = types.Array<T>
type Pattern = string | Array<string>
local function split(str... | 502 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/String/startsWith.luau | luau | .luau | --!native
--!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... | 140 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/String/substr.luau | luau | .luau | --!native
--!optimize 2
--!strict
return function(s: string, startIndex: number, numberOfCharacters: number?): string
if numberOfCharacters and numberOfCharacters <= 0 then
return ""
end
return string.sub(s, startIndex, numberOfCharacters and startIndex + numberOfCharacters - 1 or nil)
end
| 69 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/String/trim.luau | luau | .luau | --!native
--!optimize 2
--!strict
local trimEnd = require("./trimEnd")
local trimStart = require("./trimStart")
return function(source: string): string
return trimStart(trimEnd(source))
end
| 49 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/String/trimEnd.luau | luau | .luau | --!native
--!optimize 2
--!strict
return function(source: string): string
return (string.gsub(source, "[%s]+$", ""))
end
| 35 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/String/trimStart.luau | luau | .luau | --!native
--!optimize 2
--!strict
return function(source: string): string
return (string.gsub(source, "^[%s]+", ""))
end
| 36 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Symbol/RegistryGlobal.luau | luau | .luau | --!native
--!optimize 2
local Symbol = require("./Symbol")
local GlobalRegistry: {[string]: Symbol.Symbol} = {}
return {
getOrInit = function(name: string): Symbol.Symbol
if GlobalRegistry[name] == nil then
GlobalRegistry[name] = Symbol.new(name)
end
return GlobalRegistry[name]
end;
-- Used for testing
... | 94 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Symbol/Symbol.luau | luau | .luau | --!native
--!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 abil... | 178 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Symbol/init.luau | luau | .luau | --!native
--!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("./RegistryGlobal")
local Symbol = require("./Symbol")
export type Symbol = Symb... | 161 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Timers/init.luau | luau | .luau | --!native
--!optimize 2
--!strict
local task = require("@lune/task")
local Object = require("../Collections").Object
local makeIntervalImpl = require("./makeIntervalImpl")
local makeTimerImpl = require("./makeTimerImpl")
export type Timeout = makeTimerImpl.Timeout
export type Interval = makeIntervalImpl.Interval
re... | 88 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Timers/makeIntervalImpl.luau | luau | .luau | --!native
--!optimize 2
local Status = newproxy(false)
type TaskStatus = number
export type Interval = {[typeof(Status)]: TaskStatus}
local SCHEDULED = 1
local CANCELLED = 3
return function(delayImpl)
local function setInterval(callback, intervalTime: number, ...): Interval
local args = {...}
local task = {
... | 279 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/Timers/makeTimerImpl.luau | luau | .luau | --!native
--!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(delayImpl)
local function setTimeout(callback, delayTime: number?, ...): Timeout
local args = {...}
local ta... | 273 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/encodeURIComponent.luau | luau | .luau | --!native
--!optimize 2
-- 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 encodeURIComp... | 380 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/extends.luau | luau | .luau | --!native
--!optimize 2
--!nonstrict
--[[
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
s... | 299 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LuauPolyfill/init.luau | luau | .luau | --!native
--!optimize 2
--!strict
local AssertionError = require("./AssertionError")
local Boolean = require("./Boolean")
local Collections = require("./Collections")
local Console = require("./Console")
local Error = require("./Error")
local Math = require("./Math")
local Number = require("./Number")
local PromiseMod... | 386 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LunePolyfill/Utf8.luau | luau | .luau | --!native
--!optimize 2
--!strict
local Utf8 = {}
function Utf8.Graphemes(value: string, start: number?, finish: number?): () -> (number, number)
local trueStart = start or 1
local trueFinish = finish or #value
local codePoints = {}
local length = 0
for point in utf8.codes(value) do
if point >= trueStart and ... | 204 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/LunePolyfill/init.luau | luau | .luau | --!native
--!optimize 2
--!strict
local Utf8 = require("./Utf8")
local LunePolyfill = table.freeze({
Utf8 = Utf8;
})
return LunePolyfill
| 46 |
Bura-Games/data-structures | Bura-Games-data-structures-00bb85a/.lune/Packages/PathFileSystem.luau | luau | .luau | --!optimize 2
--!strict
local LuauPath = require("@packages/LuauPath")
local LuauPolyfill = require("@packages/LuauPolyfill")
local fs = require("@lune/fs")
local process = require("@lune/process")
local PathFileSystem = {}
local Path = LuauPath.Path
local console = LuauPolyfill.console
export type Path = LuauPath... | 1,050 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.