repo
stringclasses
302 values
file_path
stringlengths
18
241
language
stringclasses
2 values
file_type
stringclasses
4 values
code
stringlengths
76
697k
tokens
int64
10
271k
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/bin/spec.lua
luau
.lua
local ProcessService = game:GetService("ProcessService") local Root = script.Parent.LuauPolyfillTestModel local Packages = Root.Packages -- Load JestRoblox source into Packages folder so it's next to Roact as expected local TestEZ = require(Packages._Workspace:FindFirstChild("TestEZ", true)) -- Run all tests, collect...
141
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/boolean/src/toJSBoolean.lua
luau
.lua
--!strict local Packages = script.Parent.Parent local Number = require(Packages.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
70
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/collections/src/Array/concat.lua
luau
.lua
--!strict local __DEV__ = _G.__DEV__ local Array = script.Parent local Packages = Array.Parent.Parent local isArray = require(Array.isArray) local types = require(Packages.ES7Types) type Array<T> = types.Array<T> local RECEIVED_OBJECT_ERROR = "Array.concat(...) only works with array-like tables but " .. "it received ...
457
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/collections/src/Array/every.lua
luau
.lua
--!strict local __DEV__ = _G.__DEV__ local Array = script.Parent local Packages = Array.Parent.Parent local types = require(Packages.ES7Types) 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: ...
367
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/collections/src/Array/filter.lua
luau
.lua
--!strict local __DEV__ = _G.__DEV__ local Array = script.Parent local Packages = Array.Parent.Parent local types = require(Packages.ES7Types) 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> = (thisAr...
415
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/collections/src/Array/find.lua
luau
.lua
--!strict local Array = script.Parent local Packages = Array.Parent.Parent 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 | nil for i = 1, ...
121
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/collections/src/Array/findIndex.lua
luau
.lua
--!strict local Array = script.Parent local Packages = Array.Parent.Parent 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 elem...
114
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/collections/src/Array/flat.lua
luau
.lua
local __DEV__ = _G.__DEV__ local Array = script.Parent local Packages = Array.Parent.Parent local isArray = require(Array.isArray) local types = require(Packages.ES7Types) type Array<T> = types.Array<T> local function flat<T>(array: Array<T>, depth_: number?): Array<T> if __DEV__ then if typeof(array) ~= "table" the...
251
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/collections/src/Array/flatMap.lua
luau
.lua
local __DEV__ = _G.__DEV__ local Array = script.Parent local Packages = Array.Parent.Parent local flat = require(Array.flat) local map = require(Array.map) local types = require(Packages.ES7Types) type Array<T> = types.Array<T> type callbackFn<T, U> = (element: T, index: number, array: Array<T>) -> U type callbackFnWit...
237
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/collections/src/Array/forEach.lua
luau
.lua
--!strict local __DEV__ = _G.__DEV__ local Array = script.Parent local Packages = Array.Parent.Parent local types = require(Packages.ES7Types) 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,...
361
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/collections/src/Array/from/fromArray.lua
luau
.lua
--!strict local Array = script.Parent.Parent local Packages = Array.Parent.Parent local types = require(Packages.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 f...
312
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/collections/src/Array/from/fromMap.lua
luau
.lua
--!strict local Array = script.Parent.Parent local Packages = Array.Parent.Parent local types = require(Packages.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: ...
320
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/collections/src/Array/from/fromSet.lua
luau
.lua
--!strict local Array = script.Parent.Parent local Packages = Array.Parent.Parent local types = require(Packages.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, ind...
295
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/collections/src/Array/from/fromString.lua
luau
.lua
--!strict local Array = script.Parent.Parent local Packages = Array.Parent.Parent local types = require(Packages.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 f...
334
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/collections/src/Array/from/init.lua
luau
.lua
--!strict local Array = script.Parent local Collections = Array.Parent local Packages = Collections.Parent local Set = require(Collections.Set) local Map = require(Collections.Map.Map) local isArray = require(Array.isArray) local instanceof = require(Packages.InstanceOf) local types = require(Packages.ES7Types) local ...
423
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/collections/src/Array/includes.lua
luau
.lua
--!strict local Array = script.Parent local Packages = Array.Parent.Parent local types = require(Packages.ES7Types) type Array<T> = types.Array<T> local indexOf = require(script.Parent.indexOf) return function<T>(array: Array<T>, searchElement: T, fromIndex: number?): boolean return indexOf(array, searchElement, from...
82
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/collections/src/Array/indexOf.lua
luau
.lua
--!strict local Array = script.Parent local Packages = Array.Parent.Parent 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/...
260
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/collections/src/Array/init.lua
luau
.lua
--!strict local Packages = script.Parent.Parent local ES7Types = require(Packages.ES7Types) export type Array<T> = ES7Types.Array<T> return { concat = require(script.concat), every = require(script.every), filter = require(script.filter), find = require(script.find), findIndex = require(script.findIndex), flat ...
189
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/collections/src/Array/isArray.lua
luau
.lua
--!strict return function(value: any): boolean if typeof(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 pairs(value) do if ty...
164
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/collections/src/Array/join.lua
luau
.lua
--!strict local Array = script.Parent local Packages = Array.Parent.Parent local types = require(Packages.ES7Types) type Array<T> = types.Array<T> local map = require(Array.map) return function<T>(arr: Array<T>, separator: string?): string if #arr == 0 then return "" end -- JS does tostring conversion implicitely...
122
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/collections/src/Array/map.lua
luau
.lua
--!strict local __DEV__ = _G.__DEV__ local Array = script.Parent local Packages = Array.Parent.Parent local types = require(Packages.ES7Types) 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> = (thisAr...
382
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/collections/src/Array/reduce.lua
luau
.lua
--!strict local __DEV__ = _G.__DEV__ local Array = script.Parent local Packages = Array.Parent.Parent local types = require(Packages.ES7Types) 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...
332
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/collections/src/Array/reverse.lua
luau
.lua
--!strict -- https://programming-idioms.org/idiom/19/reverse-a-list/1314/lua local Array = script.Parent local Packages = Array.Parent.Parent 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],...
127
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/collections/src/Array/shift.lua
luau
.lua
--!strict local __DEV__ = _G.__DEV__ local Array = script.Parent local Packages = Array.Parent.Parent local isArray = require(Array.isArray) local types = require(Packages.ES7Types) type Array<T> = types.Array<T> return function<T>(value: Array<T>): T? if __DEV__ then if not isArray(value) then error(string.form...
128
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/collections/src/Array/slice.lua
luau
.lua
--!strict local Array = script.Parent local Packages = Array.Parent.Parent 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...
315
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/collections/src/Array/some.lua
luau
.lua
--!strict local Array = script.Parent local Packages = Array.Parent.Parent 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:...
342
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/collections/src/Array/sort.lua
luau
.lua
--!strict local Array = script.Parent local Collections = Array.Parent local Packages = Collections.Parent local None = require(Collections.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 re...
302
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/collections/src/Array/splice.lua
luau
.lua
--!strict local Array = script.Parent local Packages = Array.Parent.Parent 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/...
454
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/collections/src/Array/unshift.lua
luau
.lua
--!strict local __DEV__ = _G.__DEV__ local Array = script.Parent local Packages = Array.Parent.Parent local isArray = require(Array.isArray) local types = require(Packages.ES7Types) type Array<T> = types.Array<T> return function<T>(array: Array<T>, ...: T): number if __DEV__ then if not isArray(array) then error...
166
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/collections/src/Map/Map.lua
luau
.lua
--!strict local __DEV__ = _G.__DEV__ local Collections = script.Parent.Parent local Packages = Collections.Parent local arrayForEach = require(Collections.Array.forEach) local arrayMap = require(Collections.Array.map) local isArray = require(Collections.Array.isArray) local instanceof = require(Packages.InstanceOf) lo...
1,438
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/collections/src/Map/coerceToMap.lua
luau
.lua
local MapModule = script.Parent local Collections = MapModule.Parent local Packages = Collections.Parent local Map = require(MapModule.Map) local Object = require(Collections.Object) local instanceOf = require(Packages.InstanceOf) local types = require(Packages.ES7Types) type Map<K, V> = types.Map<K, V> type Table<K,...
160
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/collections/src/Map/coerceToTable.lua
luau
.lua
local MapModule = script.Parent local Collections = MapModule.Parent local Packages = Collections.Parent local Map = require(MapModule.Map) local instanceOf = require(Packages.InstanceOf) local arrayReduce = require(Collections.Array.reduce) local types = require(Packages.ES7Types) type Map<K, V> = types.Map<K, V> ty...
178
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/collections/src/Map/init.lua
luau
.lua
local Packages = script.Parent.Parent local ES7Types = require(Packages.ES7Types) local Map = require(script.Map) local coerceToMap = require(script.coerceToMap) local coerceToTable = require(script.coerceToTable) export type Map<K, V> = ES7Types.Map<K, V> return { Map = Map, coerceToMap = coerceToMap, coerceToT...
94
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/collections/src/Object/assign.lua
luau
.lua
--!strict local Object = script.Parent local Packages = Object.Parent.Parent local None = require(Object.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. ...
528
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/collections/src/Object/freeze.lua
luau
.lua
--!strict local Object = script.Parent local Packages = Object.Parent.Parent 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 e...
97
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/collections/src/Object/init.lua
luau
.lua
--!strict return { assign = require(script.assign), entries = require(script.entries), freeze = require(script.freeze), is = require(script.is), isFrozen = require(script.isFrozen), keys = require(script.keys), preventExtensions = require(script.preventExtensions), seal = require(script.seal), values = requir...
107
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/collections/src/Object/isFrozen.lua
luau
.lua
--!strict local __DEV__ = _G.__DEV__ local Object = script.Parent local Packages = Object.Parent.Parent local types = require(Packages.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 cal...
106
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/collections/src/Object/keys.lua
luau
.lua
local Object = script.Parent local Collections = Object.Parent local Packages = Object.Parent.Parent local Set = require(Collections.Set) local types = require(Packages.ES7Types) local instanceOf = require(Packages.InstanceOf) type Array<T> = types.Array<T> type Set<T> = types.Set<T> type Table = { [any]: any } retur...
221
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/collections/src/Object/preventExtensions.lua
luau
.lua
--!strict local Object = script.Parent local Packages = Object.Parent.Parent 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 -- sup...
187
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/collections/src/Object/values.lua
luau
.lua
--!strict local Object = script.Parent local Packages = Object.Parent.Parent 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...
240
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/collections/src/Set/init.lua
luau
.lua
--!nonstrict local __DEV__ = _G.__DEV__ local Collections = script.Parent local Packages = Collections.Parent local inspect = require(Collections.inspect) local isArray = require(Collections.Array.isArray) local arrayForEach = require(Collections.Array.forEach) local arrayFromString = require(Collections.Array.from.fr...
1,067
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/collections/src/WeakMap.lua
luau
.lua
--!strict local Collections = script.Parent local Packages = Collections.Parent 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...
305
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/collections/src/init.lua
luau
.lua
--!strict local Packages = script.Parent local Array = require(script.Array) local Map = require(script.Map) local Object = require(script.Object) local Set = require(script.Set) local WeakMap = require(script.WeakMap) local inspect = require(script.inspect) local types = require(Packages.ES7Types) export type Array...
180
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/console/src/init.lua
luau
.lua
--!strict local makeConsoleImpl = require(script.makeConsoleImpl) return makeConsoleImpl()
20
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/console/src/makeConsoleImpl.lua
luau
.lua
--!strict local root = script.Parent local Packages = root.Parent local inspect = require(Packages.Collections).inspect local INDENT = " " return function() local console = {} local indentDepth = 0 local function indent() return string.rep(INDENT, indentDepth) end function console.log(content, ...) local ...
525
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/es7-types/src/init.lua
luau
.lua
--!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 mapCallbackFnWithThisArg<...
831
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/instance-of/src/instanceof.lua
luau
.lua
--!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 |}, Error }' could not ...
326
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/luau-polyfill/src/AssertionError/init.lua
luau
.lua
local AssertionErrorModule = require(script["AssertionError.global"]) export type AssertionError = AssertionErrorModule.AssertionError return AssertionErrorModule.AssertionError
28
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/luau-polyfill/src/Error/init.lua
luau
.lua
local Error = require(script["Error.global"]) export type Error = Error.Error return Error
19
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/luau-polyfill/src/Promise.lua
luau
.lua
-- this maps onto community promise libraries which won't support Luau, so we inline export type PromiseLike<T> = { andThen: ( self: PromiseLike<T>, resolve: ((T) -> ...(nil | T | PromiseLike<T>))?, reject: ((any) -> ...(nil | T | PromiseLike<T>))? ) -> PromiseLike<T>, } type PromiseStatus = "Started" | "Resol...
313
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/luau-polyfill/src/encodeURIComponent.lua
luau
.lua
-- reference documentation: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent local HttpService = game:GetService("HttpService") local root = script.Parent local Packages = root.Parent local String = require(Packages.String) local charCodeAt = String.charCodeAt local ...
352
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/luau-polyfill/src/init.lua
luau
.lua
--!strict local Packages = script.Parent local Boolean = require(Packages.Boolean) local Collections = require(Packages.Collections) local Console = require(Packages.Console) local Math = require(Packages.Math) local Number = require(Packages.Number) local String = require(Packages.String) local Symbol = require(Packa...
394
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/number/src/MAX_SAFE_INTEGER.lua
luau
.lua
--!strict -- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER return 9007199254740991
38
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/number/src/MIN_SAFE_INTEGER.lua
luau
.lua
--!strict -- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MIN_SAFE_INTEGER return -9007199254740991
38
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/number/src/init.lua
luau
.lua
--!strict return { isFinite = require(script.isFinite), isInteger = require(script.isInteger), isNaN = require(script.isNaN), isSafeInteger = require(script.isSafeInteger), MAX_SAFE_INTEGER = require(script.MAX_SAFE_INTEGER), MIN_SAFE_INTEGER = require(script.MIN_SAFE_INTEGER), NaN = 0 / 0, toExponential = requ...
82
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/number/src/isFinite.lua
luau
.lua
--!strict return function(value) return typeof(value) == "number" and value == value and value ~= math.huge and value ~= -math.huge end
36
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/number/src/isInteger.lua
luau
.lua
--!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
54
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/number/src/isNaN.lua
luau
.lua
--!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
46
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/number/src/isSafeInteger.lua
luau
.lua
--!strict -- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger local isInteger = require(script.Parent.isInteger) local MAX_SAFE_INTEGER = require(script.Parent.MAX_SAFE_INTEGER) return function(value) return isInteger(value) and math.abs(value) <= MAX_SAFE_INTEGER ...
71
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/number/src/toExponential.lua
luau
.lua
--!strict -- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toExponential return function(value: string | number, fractionDigits: number?): string | nil local num = value if typeof(value) == "string" then -- ROBLOX FIXME: add parseInt to encapsulate this logic and use it her...
298
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/string/src/charCodeAt.lua
luau
.lua
--!strict local String = script.Parent local Packages = String.Parent local Number = require(Packages.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 func...
267
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/string/src/endsWith.lua
luau
.lua
--!strict local function endsWith(value: string, substring: string, optionalLength: number?): boolean local substringLength = substring:len() if substringLength == 0 then return true end local valueLength = value:len() local length = optionalLength or valueLength if length > valueLength then length = valueLen...
119
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/string/src/findOr.lua
luau
.lua
--!strict type Match = { index: number, match: string, } -- excluding the `+` and `*` character, since findOr tests and graphql use them explicitly local luaPatternCharacters = "([" .. ("$%^()-[].?"):gsub("(.)", "%%%1") .. "])" local function findOr(str: string, patternTable: { string }, initIndex: number?): Match ...
423
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/string/src/includes.lua
luau
.lua
--!strict -- excluding the `+` and `*` character, since findOr tests and graphql use them explicitly local luaPatternCharacters = "([" .. ("$%^()-[].?"):gsub("(.)", "%%%1") .. "])" local function includes(str: string, substring: string, position: (string | number)?): boolean local strLen, invalidBytePosition = utf8....
249
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/string/src/indexOf.lua
luau
.lua
--!strict -- excluding the `+` and `*` character, since findOr tests and graphql use them explicitly local luaPatternCharacters = "([" .. ("$%^()-[].?"):gsub("(.)", "%%%1") .. "])" -- Implements equivalent functionality to JavaScript's `String.indexOf`, -- implementing the interface and behaviors defined at: -- https...
258
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/string/src/init.lua
luau
.lua
return { charCodeAt = require(script.charCodeAt), endsWith = require(script.endsWith), findOr = require(script.findOr), includes = require(script.includes), indexOf = require(script.indexOf), lastIndexOf = require(script.lastIndexOf), slice = require(script.slice), split = require(script.split), startsWith = r...
127
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/string/src/lastIndexOf.lua
luau
.lua
--!strict local function lastIndexOf(str: string, searchValue: string, fromIndex: number?): number local strLength = string.len(str) local calculatedFromIndex if fromIndex then calculatedFromIndex = fromIndex else calculatedFromIndex = strLength end if fromIndex and fromIndex < 1 then calculatedFromIndex = ...
317
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/string/src/slice.lua
luau
.lua
--!strict local function slice(str: string, startIndexStr: string | number, lastIndexStr: (string | number)?): string local strLen, invalidBytePosition = utf8.len(str) assert(strLen ~= nil, ("string `%s` has an invalid byte at position %s"):format(str, tostring(invalidBytePosition))) local startIndex = tonumber(star...
322
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/string/src/split.lua
luau
.lua
--!strict local String = script.Parent local findOr = require(String.findOr) local slice = require(String.slice) local Packages = String.Parent local types = require(Packages.ES7Types) type Array<T> = types.Array<T> local MAX_SAFE_INTEGER = require(Packages.Number).MAX_SAFE_INTEGER type Pattern = string | Array<strin...
527
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/string/src/startsWith.lua
luau
.lua
--!strict local function startsWith(value: string, substring: string, position: number?): boolean if string.len(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 position ...
135
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/string/src/substr.lua
luau
.lua
--!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
59
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/string/src/trim.lua
luau
.lua
--!strict local trimStart = require(script.Parent.trimStart) local trimEnd = require(script.Parent.trimEnd) return function(source: string): string return trimStart(trimEnd(source)) end
41
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/string/src/trimEnd.lua
luau
.lua
--!strict return function(source: string): string return (source:gsub("[%s]+$", "")) end
24
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/string/src/trimStart.lua
luau
.lua
--!strict return function(source: string): string return (source:gsub("^[%s]+", "")) end
25
Roblox/luau-polyfill
Roblox-luau-polyfill-a1a0bd7/modules/timers/src/init.lua
luau
.lua
--!strict local Packages = script.Parent local Object = require(Packages.Collections).Object local makeTimerImpl = require(script.makeTimerImpl) local makeIntervalImpl = require(script.makeIntervalImpl) export type Timeout = makeTimerImpl.Timeout export type Interval = makeIntervalImpl.Interval return Object.assign...
76
hardlyardi/b226
hardlyardi-b226-c90fd91/lune/tests.luau
luau
.luau
local SPEC_DIRECTORY = "./tests/_specs" local MATCH_SPEC_FILE = "%.spec%.luau$" local RESULTS_DIRECTORY = "./_SUITE" local filesystem = require("@lune/fs") local filesystem_hierarchy = require("@runtest/utils/filesystem_hierarchy") local process = require("@lune/process") local runtest = require("@runtest/") local ser...
825
hardlyardi/b226
hardlyardi-b226-c90fd91/src/init.luau
luau
.luau
--!optimize 2 --!native --[[ - U53: Represents a positive integer with a number (a.k.a., double, or F64) value. 2^53 is the maximum unsigned integer a number in luau can accurately represent. Used primarily for entity Ids. - U32: Represents a positive integer, and implies it can or should be used with bit32 or other ...
34,793
hardlyardi/b226
hardlyardi-b226-c90fd91/tests/runtest/utils/luausignal.luau
luau
.luau
--[[ Copyright 2025 ffrostfall Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublic...
1,539
hardlyardi/b226
hardlyardi-b226-c90fd91/tests/utils/ecs_visualizer.luau
luau
.luau
local b2 = require("@b2/") local ecs = require("./ecs") local runtest = require("@runtest/") type Ent = b2.Ent local style = runtest.util.style local color = style.color local b2i = b2.internal local ecsi = ecs.internal local pretty_print = style.from_epsilon local indent_newlines = style.indent_newlines -- local bri...
1,617
hardlyardi/b226
hardlyardi-b226-c90fd91/tests/utils/spec.luau
luau
.luau
--[[ simple util for creating specs ]] local runtest = require("@runtest/") type SpecRunner = runtest.SpecRunner type SpecInterface = runtest.SpecInterface type TestInterface = runtest.TestInterface type LoadedSpec = runtest.LoadedSpec local function serve(PASSED: SpecRunner) local spec = runtest.test.spec.init(PASS...
199
Crazyblox/pajamas
Crazyblox-pajamas-1a297b2/Roblox/plugin/event.luau
luau
.luau
--!strict --!native --[[ Pajamas plugin - event: A simple event module that provides an agnostic interface for a pajamas project to hook up to a serial or parallel loop event determined by the host runtime. ]] export type Hook = { Connect: (Hook, boolean?) -> (), Disconnect: (Hook) -> () } local RunService =...
239
Crazyblox/pajamas
Crazyblox-pajamas-1a297b2/Roblox/plugin/input.luau
luau
.luau
--!strict --!native --[[ Pajamas plugin - input: A simple keyboard input module providing an agnostic interface for a pajamas project to react to keyboard user intent. Note: No method for disconnection keyboard input yet. It is currently assumed that a pajamas project runs for as long as the host runtime is...
218
Crazyblox/pajamas
Crazyblox-pajamas-1a297b2/Roblox/plugin/task.luau
luau
.luau
--!strict --!native --[[ Pajamas plugin - task: Takes advantage of the Luau runtime's own task library. This plugin also considers if sync/desync support is present. ]] assert( task, "This Luau runtime does not provide 'task'" ) local synchronize = task.synchronize or function() print("Warning: Missing sync/desy...
216
Crazyblox/pajamas
Crazyblox-pajamas-1a297b2/Roblox/wrapper/client.client.luau
luau
.luau
--!strict --!native -- Disable local iswrapper = script.Parent:FindFirstChild("iswrapper") if iswrapper then if require(iswrapper).Disable == true then script.Disabled = true return end end -- Wrapper local Attributes: {[string]: any} = script:GetAttributes() local Params: {[number]: any} = {} local i: number = 1...
137
Crazyblox/pajamas
Crazyblox-pajamas-1a297b2/Roblox/wrapper/iswrapper.luau
luau
.luau
-- Crude validation for existing in the wrapper directory in -- the face of datamodel properties not syncing outside of Roblox. return table.freeze( { Disable = true } )
36
itsfrank/frktest
itsfrank-frktest-aa72048/examples/arrays.luau
luau
.luau
local frktest = require("@frktest/frktest") local test = frktest.test local check = frktest.assert.check return function() test.suite("Arrays", function() test.case("contains", function() local a = { "one", "two", "three", "four", "five" } check.array.contains(a, "eleven") -- check ...
435
itsfrank/frktest
itsfrank-frktest-aa72048/examples/basic_assertions.luau
luau
.luau
local frktest = require("@frktest/frktest") local test = frktest.test local check = frktest.assert.check local req = frktest.assert.require return function() test.suite("Passing", function() test.case("The only passing test", function() check.is_true(true) end) end) test.suite(...
470
itsfrank/frktest
itsfrank-frktest-aa72048/examples/errors.luau
luau
.luau
local frktest = require("@frktest/frktest") local test = frktest.test local check = frktest.assert.check return function() test.suite("Errors", function() test.case("throwing", function() error("some error") -- errors end a test end) test.case("should error", function() ...
127
itsfrank/frktest
itsfrank-frktest-aa72048/examples/focus.luau
luau
.luau
local frktest = require("@frktest/frktest") local test = frktest.test local check = frktest.assert.check -- use test.focus variants of the case/suire functions to temporarily skip all but one test/suite return function() -- can be used on suites to run only one suite test.focus.suite("Only run me [suite]", fun...
192
itsfrank/frktest
itsfrank-frktest-aa72048/examples/messages.luau
luau
.luau
local frktest = require("@frktest/frktest") local test = frktest.test local check = frktest.assert.check local req = frktest.assert.require local msg = frktest.assert.msg return function() test.suite("Messages", function() test.case("Print message if assertion fails", function() check.equal(10,...
313
itsfrank/frktest
itsfrank-frktest-aa72048/examples/parametrized.luau
luau
.luau
-- parametrized testing, also known as 'data driven tests' or 'table driven tests' -- quite popular in the golang community, is a style of testing where the data -- and logic are separated so that you can run the same test logic on multiple -- input/output pairs local frktest = require("@frktest/frktest") local test =...
288
itsfrank/frktest
itsfrank-frktest-aa72048/examples/readme_demo/_run.luau
luau
.luau
function load_tests() require("./the_test")() end function run_tests() local frktest = require("@frktest/frktest") local console_reporter = require("@frktest/reporters/console_reporter") console_reporter.init() frktest.run() end load_tests() run_tests()
69
itsfrank/frktest
itsfrank-frktest-aa72048/examples/readme_demo/the_test.luau
luau
.luau
local frktest = require("@frktest/frktest") local test = frktest.test local check = frktest.assert.check local req = frktest.assert.require local msg = frktest.assert.msg return function() test.suite("A collection of tests", function() test.case("A test that passes", function() local exp = 4 ...
354
itsfrank/frktest
itsfrank-frktest-aa72048/examples/run/default.luau
luau
.luau
function load_tests() -- tests execute in the order they are loaded require("../suites_cases")() require("../basic_assertions")() require("../messages")() require("../errors")() require("../parametrized")() require("../arrays")() require("../tables")() require("../skip")() -- req...
245
itsfrank/frktest
itsfrank-frktest-aa72048/examples/run/pesde_entrypoint.luau
luau
.luau
function load_tests() require("../basic_assertions")() end function run_tests() -- same as run, but uses the entrypoint.luau entrypoint script, like a pesde project would local frktest = require("../../src/entrypoint") local console_reporter = frktest.reporters.console_reporter console_reporter.in...
97
itsfrank/frktest
itsfrank-frktest-aa72048/examples/skip.luau
luau
.luau
local frktest = require("@frktest/frktest") local test = frktest.test local check = frktest.assert.check -- use test.skip to not run suites/cases return function() -- can be used on suites to skip the entire suite test.skip.suite("This suite will not run", function() test.case("test 1", function() ...
159
itsfrank/frktest
itsfrank-frktest-aa72048/examples/suites_cases.luau
luau
.luau
local frktest = require("@frktest/frktest") local test = frktest.test local check = frktest.assert.check return function() -- use suites to group test cases together test.suite("A collection of test cases", function() test.case("case 1", function() check.is_true(false) end) ...
148
itsfrank/frktest
itsfrank-frktest-aa72048/examples/tables.luau
luau
.luau
local frktest = require("@frktest/frktest") local test = frktest.test local check = frktest.assert.check return function() test.suite("Tables", function() test.case("value equal", function() local a = { foo = 1 } local b = { foo = 1 } local c = a check.equal(...
574
itsfrank/frktest
itsfrank-frktest-aa72048/src/assert.luau
luau
.luau
local types = require("./types") type Failure = types.Failure local _state = {} _state.listeners = {} _state.listeners.check_failed = {} :: { (Failure) -> nil } _state.listeners.require_failed = {} :: { (Failure) -> nil } _state.current_user_msg = nil :: string? local test = require("./test") function exec_listener...
990
itsfrank/frktest
itsfrank-frktest-aa72048/src/assert_impl.luau
luau
.luau
local types = require("./types") local utils = require("./utils") type Failure = types.Failure type DiffEntry<T> = types.DiffEntry<T> type TableDiff = types.TableDiff local assert_impl = {} function make_failure(message: string): Failure local file, line = debug.info(5, "sl") return { location = { ...
1,810