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 |
|---|---|---|---|---|---|
YetAnotherClown/planck | YetAnotherClown-planck-2dc9aba/src/run-tests.server.luau | luau | .luau | _G.NOCOLOR = _G.NOCOLOR
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Packages = ReplicatedStorage.Packages
local DevPackages = ReplicatedStorage.DevPackages
local Jest = require(DevPackages.Jest)
local runCLIOptions = {
verbose = false,
ci = false,
}
local projects = {
Packages,
}
Jest.r... | 92 |
typeforge-luau/typeforge | typeforge-luau-typeforge-05d2b6e/src/init.luau | luau | .luau | --!strict
--!nolint LocalShadow
--> Helpers ----------------------------------------------------------------------------
type function handle_negation<T>(input: type, callback: (input: type, input_tag: string) -> T)
local input_tag = input.tag
if input_tag == "negation" then
local input_inner = input:... | 18,020 |
typeforge-luau/typeforge | typeforge-luau-typeforge-05d2b6e/src/init.test.luau | luau | .luau | --!strict
local t = require("@self")
type function set_indexer(input: typeof(types.newtable()), index: type, result: type)
input:setindexer(index, result)
return input
end
--> Core ----------------------------------------------------------------------------------------------
-- Omit -------------------------... | 13,915 |
kosuke14/vLuau | kosuke14-vLuau-e395e63/Fiu.luau | luau | .luau | --!optimize 2
--!native
-- // Environment changes in the VM are not supposed to alter the behaviour of the VM so we localise globals beforehand
local type = type
local pcall = pcall
local error = error
local tonumber = tonumber
local assert = assert
local setmetatable = setmetatable
local string_format = string.format... | 12,901 |
axiom-co/framework | axiom-co-framework-fe85912/src/logs.luau | luau | .luau | return {
FatalInit = "Init errored: %s",
FatalAddModule = "Added module errored: %s",
ProviderDuplicate = "Provider '%s' already exists",
AlreadyStarted = "Framework has already started",
ReservedName = "'%s' is a reserved %s name",
InvalidType = "Expected type %s; got '%s'",
}
| 80 |
axiom-co/framework | axiom-co-framework-fe85912/src/spawn.luau | luau | .luau | local FreeThreads: { thread } = {}
local function RunCallback(callback: (...any) -> ...any, thread: thread, ...)
callback(...)
table.insert(FreeThreads, thread)
end
local function Yielder()
while true do
RunCallback(coroutine.yield())
end
end
return function<T...>(callback: (T...) -> (), ...: T...)
local Thre... | 139 |
axiom-co/framework | axiom-co-framework-fe85912/src/types.luau | luau | .luau | export type Provider<T> = {
Name: string?,
Uses: { any }?,
Order: number?,
Init: (() -> ())?,
Start: (() -> ())?,
} & T
export type Hook<T...> = {
Name: string,
Fire: (self: Hook<T...>, T...) -> (),
Listeners: { (...any) -> () },
}
return {}
| 78 |
axiom-co/framework | axiom-co-framework-fe85912/tests/hooks/callback/consumer.luau | luau | .luau | local function HookCallback(args)
print(args)
end
return {
HookCallback = HookCallback,
}
| 23 |
axiom-co/framework | axiom-co-framework-fe85912/tests/hooks/callback/hook.luau | luau | .luau | local Packages = script.Parent.Parent.Parent.Parent
local Framework = require(Packages.framework.src)
local TEST_NAME = "HOOK-TEST"
local RunService = game:GetService("RunService")
local Hook = Framework.Hook("HookCallback", function(self, ...)
for _, listener in self.Listeners do
print(`{TEST_NAME}: Hook custom li... | 100 |
axiom-co/framework | axiom-co-framework-fe85912/tests/hooks/consumer.luau | luau | .luau | local function HookTest(arg)
print(`{arg}: Default listener`)
end
return {
HookTest = HookTest,
}
| 27 |
axiom-co/framework | axiom-co-framework-fe85912/tests/hooks/hook.luau | luau | .luau | local Packages = script.Parent.Parent.Parent
local Framework = require(Packages.framework.src)
local TEST_NAME = "HOOK-TEST"
local RunService = game:GetService("RunService")
local Hook = Framework.Hook("HookTest")
RunService.Heartbeat:Connect(function()
Hook:Fire(TEST_NAME)
end)
return {}
| 67 |
axiom-co/framework | axiom-co-framework-fe85912/tests/providers/dependencies/dep1.luau | luau | .luau | local TEST_NAME = "DEPENDENCIES-TEST"
local Dep2 = require(script.Parent.dep2)
local function Init()
print(`{TEST_NAME}: Dependency 1, using Dependency 2 (second)`)
end
return {
Init = Init,
Uses = { Dep2 }
}
| 60 |
axiom-co/framework | axiom-co-framework-fe85912/tests/providers/dependencies/dep2.luau | luau | .luau | local TEST_NAME = "DEPENDENCIES-TEST"
local function Init()
print(`{TEST_NAME}: Dependency 2 (first)`)
end
return {
Init = Init,
}
| 38 |
axiom-co/framework | axiom-co-framework-fe85912/tests/providers/dependencies/module.luau | luau | .luau | local TEST_NAME = "DEPENDENCIES-TEST"
local Dep1 = require(script.Parent.dep1)
local function Init()
print(`{TEST_NAME}: Module (third)`)
end
return {
Init = Init,
Uses = { Dep1 }
}
| 53 |
axiom-co/framework | axiom-co-framework-fe85912/tests/providers/order/mod1.luau | luau | .luau | local TEST_NAME = "ORDER-TEST"
local function Init()
print(`{TEST_NAME}: First`)
end
return {
Init = Init,
Order = -3,
}
| 38 |
axiom-co/framework | axiom-co-framework-fe85912/tests/providers/order/mod2.luau | luau | .luau | local TEST_NAME = "ORDER-TEST"
local function Init()
print(`{TEST_NAME}: Second`)
end
return {
Init = Init,
Order = -2,
}
| 38 |
axiom-co/framework | axiom-co-framework-fe85912/tests/providers/order/mod3.luau | luau | .luau | local TEST_NAME = "ORDER-TEST"
local function Init()
print(`{TEST_NAME}: Third`)
end
return {
Init = Init,
Order = -1,
}
| 38 |
axiom-co/framework | axiom-co-framework-fe85912/tests/providers/provider.luau | luau | .luau | local TEST_NAME = "PROVIDER-TEST"
local function Init()
print(`{TEST_NAME}: Init (first)`)
end
local function Start()
print(`{TEST_NAME}: Start (second)`)
end
return {
Init = Init,
Start = Start,
Name = "provider-custom",
}
| 67 |
axiom-co/framework | axiom-co-framework-fe85912/tests/start.server.luau | luau | .luau | local Packages = script.Parent.Parent
local Tests = script.Parent
local Framework = require(Packages.framework.src)
local TESTING = {
-- lifecycles
Tests.hooks,
Tests.hooks.callback,
-- providers
Tests.providers,
Tests.providers.dependencies,
Tests.providers.order,
}
Framework.Add(TESTING)... | 76 |
Corecii/GreenTea | Corecii-GreenTea-9901687/.pesde/roblox_sync_config_generator.luau | luau | .luau | local process = require("@lune/process")
local home_dir = if process.os == "windows" then process.env.userprofile else process.env.HOME
require(home_dir .. "/.pesde/scripts/lune/rojo/roblox_sync_config_generator.luau")
| 54 |
Corecii/GreenTea | Corecii-GreenTea-9901687/.pesde/sourcemap_generator.luau | luau | .luau | local process = require("@lune/process")
local home_dir = if process.os == "windows" then process.env.userprofile else process.env.HOME
require(home_dir .. "/.pesde/scripts/lune/rojo/sourcemap_generator.luau") | 54 |
Corecii/GreenTea | Corecii-GreenTea-9901687/lune/build-lune-zip.luau | luau | .luau | local process = require("@lune/process")
local fs = require("@lune/fs")
local function exec(cmdline: string | { string }, options: process.SpawnOptions?)
local pieces = {}
if typeof(cmdline) == "string" then
for piece in string.gmatch(" " .. cmdline, "%s+([^%s]+)") do
table.insert(pieces, piece)
end
else
p... | 391 |
Corecii/GreenTea | Corecii-GreenTea-9901687/lune/enable-loadmodule.luau | luau | .luau |
local fs = require("@lune/fs")
local process = require("@lune/process")
local serde = require("@lune/serde")
if process.env.windir ~= nil then
-- Windows
local appDataPath = process.env.LOCALAPPDATA
local robloxVersionsPath = `{appDataPath}\\Roblox\\Versions`
if not fs.isDir(robloxVersionsPath) then
error(`Ro... | 517 |
Corecii/GreenTea | Corecii-GreenTea-9901687/lune/moonwave.luau | luau | .luau | local fs = require("@lune/fs")
local task = require("@lune/task")
local process = require("@lune/process")
export type Path = string
local function getModifiedAt(path: Path): number
local meta = fs.metadata(path)
return assert(meta.modifiedAt).unixTimestampMillis
end
local function rebuild_item(options: {
base: P... | 1,110 |
Corecii/GreenTea | Corecii-GreenTea-9901687/lune/prepare-lune-version.luau | luau | .luau | --[[
This is a simplified Roblox -> Lune converter specifically for GreenTea.
I have chosen this approach over DarkLua and other because...
1. String requires are coming to Roblox soon, which makes this less necessary.
2. DarkLua and similar add a lot of complexity for something that is really
simple in this ca... | 363 |
Corecii/GreenTea | Corecii-GreenTea-9901687/lune/set-version.luau | luau | .luau | local fs = require("@lune/fs")
local serde = require("@lune/serde")
local process = require("@lune/process")
local wally = serde.decode("toml", fs.readFile("wally.toml"))
local lastVersion = wally.package.version
local nextVersion = assert(process.args[1], "version required!\n\nusage:\n lune set-version -- <version>... | 508 |
Corecii/GreenTea | Corecii-GreenTea-9901687/lune/wally-install.luau | luau | .luau | local process = require("@lune/process")
local function exec(cmdline: string)
local pieces = {}
for piece in string.gmatch(" " .. cmdline, "%s+([^%s]+)") do
table.insert(pieces, piece)
end
local program = table.remove(pieces, 1)
assert(program ~= nil, "cmdline must include a program")
local result = process.s... | 162 |
Corecii/GreenTea | Corecii-GreenTea-9901687/src-t-standalone-pesde/t.luau | luau | .luau | local GreenTea = require(script.Parent.roblox_packages.GreenTea)
export type Cause = GreenTea.Cause
export type Type = GreenTea.Type
export type TuplePacked<T...> = GreenTea.TuplePacked<T...>
return GreenTea.t
| 60 |
Corecii/GreenTea | Corecii-GreenTea-9901687/src-t-standalone-wally/init.luau | luau | .luau | local GreenTea = require(script.Parent.GreenTea)
export type Cause = GreenTea.Cause
export type Type = GreenTea.Type
export type TuplePacked<T...> = GreenTea.TuplePacked<T...>
return GreenTea.t | 55 |
Roblox/dash | Roblox-dash-5a885be/benchmark/benchmark.lua | luau | .lua | local Packages = game:GetService("ReplicatedStorage").Packages
local JestGlobals = require(Packages.Dev.JestGlobals)
local JestBenchmark = require(Packages.Dev.JestBenchmark)
local describe = JestGlobals.describe
local benchmark = JestBenchmark.benchmark
return function<T>(name: string, times: number, benchFunction: (... | 227 |
Roblox/dash | Roblox-dash-5a885be/benchmark/join.bench.lua | luau | .lua | local Packages = game:GetService("ReplicatedStorage").Packages
local Dash = require(Packages.Dash)
local Cryo = require(Packages.Dev.Cryo)
local benchmark = require(script.Parent.benchmark)
local DICT_A = {
a = 5,
b = 10,
cherry = 800,
}
local DICT_B = {
apple = 50,
cherry = 80,
fig = 100,
}
local DICT_C = {
ba... | 399 |
Roblox/dash | Roblox-dash-5a885be/benchmark/union.bench.lua | luau | .lua | local Packages = game:GetService("ReplicatedStorage").Packages
local Dash = require(Packages.Dash)
local Cryo = require(Packages.Dev.Cryo)
local benchmark = require(script.Parent.benchmark)
local DICT_A = {
a = 5,
b = 10,
cherry = 800,
}
local DICT_B = {
apple = 50,
cherry = 80,
fig = 100,
}
local BENCHMARK_ITE... | 154 |
Roblox/dash | Roblox-dash-5a885be/src/Error.lua | luau | .lua | local Dash = script.Parent
local Types = require(Dash.Types)
local class = require(Dash.class)
local format = require(Dash.format) :: <T...>(string, T...) -> string
local join = require(Dash.join)
--[=[
Creates an error object with a specified name and message.
In native Lua, errors can only be string values. At Ro... | 421 |
Roblox/dash | Roblox-dash-5a885be/src/None.lua | luau | .lua | local Symbol = require(script.Parent.Symbol)
local None = Symbol.new("None")
--[=[
A symbol representing nothing, that can be used in place of nil as a key or value of a table,
where nil is illegal.
Utility functions can check for the None symbol and treat it like a nil value.
@usage Use cases include:
1. Creat... | 102 |
Roblox/dash | Roblox-dash-5a885be/src/Symbol.lua | luau | .lua | local Dash = script.Parent
local class = require(Dash.class)
--[=[
Creates a symbol with a specified name. Upper snake-case is recommended as the symbol is a constant, unless you are linking the symbol conceptually to a different string.
Symbols are useful when you want a value that isn't equal to any other type, f... | 266 |
Roblox/dash | Roblox-dash-5a885be/src/Types.lua | luau | .lua | -- A table with keys of type _Key_ and values of type _Value_
export type Map<Key, Value> = { [Key]: Value }
-- A table with keys of a fixed type _Key_ and a boolean value representing membership of the set (default is false)
export type Set<Key> = { [Key]: boolean }
-- A table of any type
export type Table = { [any]: ... | 141 |
Roblox/dash | Roblox-dash-5a885be/src/all.lua | luau | .lua | type AllHandler = (any, any) -> boolean
local defaultHandler: AllHandler = function(value)
return value
end
--[=[
Returns `true` if all entries in the _input_ table satisfy the predicate _handler_.
If no _handler_ is provided, the default predicate returns the truthiness of each value.
For array inputs, elements... | 186 |
Roblox/dash | Roblox-dash-5a885be/src/append.lua | luau | .lua | local Dash = script.Parent
local None = require(Dash.None)
local forEachArgs = require(Dash.forEachArgs)
local forEach = require(Dash.forEach)
local insert = table.insert
--[=[
Adds new elements to the _target_ array from subsequent array arguments in left-to-right order.
Arguments which are `nil` or `Dash.None` ar... | 186 |
Roblox/dash | Roblox-dash-5a885be/src/assertEqual.lua | luau | .lua | local Dash = script.Parent
--[=[
Performs a simple equality check and throws an error if _left_ is not equal to _right_.
The formatted error message can be customized, which by default provides a serialization of both inputs using `Dash.pretty`.
The `left` and `right` values are available to be referenced in the ... | 183 |
Roblox/dash | Roblox-dash-5a885be/src/assign.lua | luau | .lua | local Dash = script.Parent
local None = require(Dash.None)
local Types = require(Dash.Types)
local forEach = require(Dash.forEach)
local forEachArgs = require(Dash.forEachArgs)
--[=[
Adds new key/value pairs to the _target_ table from subsequent table arguments in left-to-right order.
The `None` symbol can be used ... | 470 |
Roblox/dash | Roblox-dash-5a885be/src/chain.lua | luau | .lua | -- TODO (AleksandrSl 18/08/2025): Implementation is valid, but it's impossible to cast nil into T...
--!nocheck
--[=[
Returns a stateful iterator that yields all elements from the first iterator, then the next, until exhausted.
@param ... One or more stateful iterator functions to chain.
@return A stateful iterator... | 251 |
Roblox/dash | Roblox-dash-5a885be/src/class.lua | luau | .lua | local Dash = script.Parent
local Types = require(Dash.Types)
local function throwNotImplemented(tags: Types.Table)
local Error = require(Dash.Error) :: { [string]: any } -- see type Error
local NotImplemented =
Error.new("NotImplemented", [[The method "{methodName}" is not implemented on the class "{className}"]])... | 2,163 |
Roblox/dash | Roblox-dash-5a885be/src/collect.lua | luau | .lua | local Dash = script.Parent
local Types = require(Dash.Types)
-- TODO (AleksandrSl 18/08/2025): Try to type again with a solver V2. Solver V1 infers types weirdly,
-- so the functions are barely usable without type casts
export type CollectHandler<Key, Value, NewKey, NewValue> = (key: Key, value: Value) -> (NewKey?, N... | 262 |
Roblox/dash | Roblox-dash-5a885be/src/collectArray.lua | luau | .lua | local Dash = script.Parent
local Types = require(Dash.Types)
local insert = table.insert
-- TODO (AleksandrSl 18/08/2025): Try to type again with a solver V2. Solver V1 infers types weirdly,
-- so the functions are barely usable without type casts
type CollectHandler<Key, Value, NewValue> = (key: Key, value: Value) ... | 263 |
Roblox/dash | Roblox-dash-5a885be/src/collectSet.lua | luau | .lua | local Dash = script.Parent
local Types = require(Dash.Types)
type CollectHandler<Key, Value, NewValue> = (key: Key, value: Value) -> NewValue?
--[=[
Returns a new set built from iterating over _input_ and calling _handler_ for each `(key, value)`.
If _handler_ is not provided, the values of _input_ are used direct... | 293 |
Roblox/dash | Roblox-dash-5a885be/src/copy.lua | luau | .lua | local Dash = script.Parent
local Types = require(Dash.Types)
--[=[
Returns a shallow copy of the _input_ table.
Only the top level is copied; nested tables are copied by reference.
@param input The table to copy.
@return A new table with the same keys and values as _input_.
@see `Dash.assign` to copy properties... | 115 |
Roblox/dash | Roblox-dash-5a885be/src/count.lua | luau | .lua | type CountHandler<Key, Value> = (Value, Key) -> boolean
local defaultHandler = function()
return true
end
--[=[
Returns the number of elements in _input_, optionally counting only those for which _handler_ returns true on the `(value, key)` pair.
If _handler_ is not provided, all elements are counted. Iteration o... | 411 |
Roblox/dash | Roblox-dash-5a885be/src/cycles.lua | luau | .lua | local Dash = script.Parent
local Types = require(Dash.Types)
local includes = require(Dash.includes)
local keys = require(Dash.keys)
local sort = table.sort
export type Cycles = {
-- A set of tables which were visited recursively
visited: Types.Set<Types.Table>,
-- A map from table to unique index in visit order
... | 808 |
Roblox/dash | Roblox-dash-5a885be/src/debounce.lua | luau | .lua | local Dash = script.Parent
local assign = require(Dash.assign)
type DebounceOptions = {
leading: boolean?,
trailing: boolean?,
}
type DebounceOptionsInternal = {
leading: boolean,
trailing: boolean,
}
-- `& (...any) -> ...any` in the function type is a funky way to mimick `T extends function`
type AnyVoidFunctio... | 597 |
Roblox/dash | Roblox-dash-5a885be/src/endsWith.lua | luau | .lua | --[=[
Checks whether _input_ ends with the string _suffix_.
@return `true` if _input_ ends with _suffix_; otherwise `false`.
@example
```luau
endsWith("Fun Roblox Games", "Games") --> true
```
@example
```luau
endsWith("Bad Roblox Memes", "Games") --> false
```
]=]
local function endsWith(input: string, suff... | 118 |
Roblox/dash | Roblox-dash-5a885be/src/filter.lua | luau | .lua | local Dash = script.Parent
local Types = require(Dash.Types)
export type FilterHandler<Key, Value> = (Value, Key) -> boolean
--[=[
Returns a new array containing the elements of the _input_ table for which _handler_ returns truthy.
For an array input, the order of elements is preserved in the output.
For a Map/ta... | 195 |
Roblox/dash | Roblox-dash-5a885be/src/find.lua | luau | .lua | export type FindHandler<Key, Value> = (Value, Key) -> boolean
--[=[
Returns the first element in the _input_ table that satisfies the _handler_ predicate.
For an array input, the first matching element in order 1..n is returned.
For a Map input, an arbitrary matching element is returned.
@param input The table t... | 171 |
Roblox/dash | Roblox-dash-5a885be/src/findIndex.lua | luau | .lua | export type FindHandler<Value> = (Value, number) -> boolean
--[=[
Returns the index of the first element in the _input_ array that satisfies the _handler_ predicate.
@param input The array to search.
@param handler Function called as `(value, index)` for each element; return `true` to select the index.
@return Th... | 149 |
Roblox/dash | Roblox-dash-5a885be/src/flat.lua | luau | .lua | local Dash = script.Parent
local append = require(Dash.append)
local forEach = require(Dash.forEach)
-- TODO Luau: Support function generics
--[=[
Flattens the input array by a single level.
Outputs a new array of elements merged from the _input_ array arguments in left-to-right order.
@param input The array of a... | 138 |
Roblox/dash | Roblox-dash-5a885be/src/forEach.lua | luau | .lua | export type ForEachHandler<Key, Value> = (Value, Key) -> ()
--[=[
Iterates through the elements of the _input_ table and calls _handler_ for each entry.
For an array input, the elements are visited in order 1..n.
For a Map input, the keys are visited in an arbitrary order.
@param input The table to iterate over.... | 134 |
Roblox/dash | Roblox-dash-5a885be/src/forEachArgs.lua | luau | .lua | export type ForEachArgsHandler<Value> = (Value, number) -> ()
--[=[
Iterates through the tail arguments in order, including nil values up to the argument list length.
@param handler Function called as `(value, index)` for each argument.
@param ... Variable arguments to iterate over.
]=]
local function forEachArgs<... | 111 |
Roblox/dash | Roblox-dash-5a885be/src/format.lua | luau | .lua | local Dash = script.Parent
local formatValue = require(Dash.formatValue)
local splitOn = require(Dash.splitOn)
local startsWith = require(Dash.startsWith)
local concat = table.concat
local insert = table.insert
--[=[
Returns the _format_ string with placeholders `{...}` substituted with readable representations of t... | 939 |
Roblox/dash | Roblox-dash-5a885be/src/formatValue.lua | luau | .lua | local Dash = script.Parent
--[=[
Formats a specific _value_ using the specified _displayString_.
@param value The value to format.
@param displayString Optional display string specifying the format.
@return The formatted string representation of the value.
@example
```luau
formatValue(255, "06X") --> "0000FF"... | 422 |
Roblox/dash | Roblox-dash-5a885be/src/freeze.lua | luau | .lua | local Dash = script.Parent
local Error = require(Dash.Error)
local format = require(Dash.format)
local ReadonlyKey =
Error.new("ReadonlyKey", "Attempted to write to readonly key {key:?} of frozen object {objectName:?}")
local MissingKey = Error.new("MissingKey", "Attempted to read missing key {key:?} of frozen object... | 686 |
Roblox/dash | Roblox-dash-5a885be/src/frequencies.lua | luau | .lua | local Dash = script.Parent
local Types = require(Dash.Types)
local reduce = require(Dash.reduce)
type FrequenciesHandler<Key, Value, NewKey> = (Value, Key) -> NewKey
--[=[
Returns a map counting the frequency of unique values in the _input_ table.
If no _handler_ is provided, counts occurrences of each unique valu... | 398 |
Roblox/dash | Roblox-dash-5a885be/src/get.lua | luau | .lua | --[=[
Returns the value at _path_ from _object_. If resolution yields `nil`, _defaultValue_ is returned instead.
@param object The table to query.
@param path An array of keys to traverse on _object_.
@param defaultValue The value to return when the resolved value is `nil`.
@return The resolved value at _path_, o... | 290 |
Roblox/dash | Roblox-dash-5a885be/src/getOrSet.lua | luau | .lua | export type GetValueHandler<Key, Value> = ({ [Key]: Value }, Key) -> Value
--[=[
Returns the value at _key_ from the _input_ table.
If the key is missing, calls _getValue_ to compute a value, stores it on _input_, and returns it.
@param input The table to read from (and potentially write to).
@param key The key ... | 179 |
Roblox/dash | Roblox-dash-5a885be/src/identity.lua | luau | .lua | --[=[
Returns the input parameters unchanged.
Can be used to make it clear that a handler returns its inputs unchanged.
@param ... The input parameters to return.
@return The input parameters unchanged.
]=]
local function identity<T...>(...: T...): T...
return ...
end
return identity
| 62 |
Roblox/dash | Roblox-dash-5a885be/src/includes.lua | luau | .lua | --[=[
Returns `true` if the _item_ exists as a value in the _input_ table.
A nil _item_ will always return `false`.
@param input The table to search in.
@param item The value to search for.
@return `true` if the item is found, `false` otherwise.
]=]
local function includes(input: {}, item: any?): boolean
if ite... | 124 |
Roblox/dash | Roblox-dash-5a885be/src/init.lua | luau | .lua | local Types = require(script.Types)
export type Map<Key, Value> = Types.Map<Key, Value>
export type Set<Key> = Types.Set<Key>
export type Table = Types.Table
export type Class<Object> = Types.Class<Object>
export type AnyFunction = Types.AnyFunction
local Dash = {
all = require(script.all),
append = require(script.... | 607 |
Roblox/dash | Roblox-dash-5a885be/src/isCallable.lua | luau | .lua | --[=[
Returns `true` if the value can be called i.e. you can write `value(...)`.
@param value The value to check if it's callable.
@return `true` if the value is callable, `false` otherwise.
]=]
local function isCallable<T>(value: T): boolean
return type(value) == "function"
or (type(value) == "table" and getmet... | 107 |
Roblox/dash | Roblox-dash-5a885be/src/isLowercase.lua | luau | .lua | local Dash = script.Parent
local assertEqual = require(Dash.assertEqual)
--[=[
Returns `true` if the first character of _input_ is a lower-case character.
Throws if the _input_ is not a string or it is the empty string.
Our current version of Lua unfortunately does not support upper or lower-case detection outsid... | 192 |
Roblox/dash | Roblox-dash-5a885be/src/isUppercase.lua | luau | .lua | local Dash = script.Parent
local assertEqual = require(Dash.assertEqual)
--[=[
Returns `true` if the first character of _input_ is an upper-case character.
Throws if the _input_ is not a string or it is the empty string.
Our current version of Lua unfortunately does not support upper or lower-case detection outsi... | 196 |
Roblox/dash | Roblox-dash-5a885be/src/iterable.lua | luau | .lua | local Dash = script.Parent
local Types = require(Dash.Types)
--[=[
Creates a stateful iterator for the _input_ table, first visiting ordered numeric keys 1..n and then the remaining unordered keys in any order.
@param input The table to create an iterator for.
@return A stateful iterator function that yields `(key... | 311 |
Roblox/dash | Roblox-dash-5a885be/src/iterator.lua | luau | .lua | local Dash = script.Parent
local Types = require(Dash.Types)
--[=[
Returns an iterator for _input_: `ipairs` when it's a non-empty array, otherwise `pairs` for tables; if _input_ is a function, it is returned as-is.
This function can be used to build behavior that iterates over both arrays and Maps.
@return A sta... | 203 |
Roblox/dash | Roblox-dash-5a885be/src/join.lua | luau | .lua | local Dash = script.Parent
local Types = require(Dash.Types)
local assign = require(Dash.assign)
--[=[
Returns a new Map by merging all keys from the provided Map arguments in left-to-right order.
The `None` symbol can be used to remove existing elements.
@param ... Any number of tables to merge.
@return A new M... | 99 |
Roblox/dash | Roblox-dash-5a885be/src/joinArrays.lua | luau | .lua | local Dash = script.Parent
local Types = require(Dash.Types)
--[=[
Returns a new array containing the joined elements of the arrays passed.
@param ... Any number of arrays to join.
@return A new array containing the joined elements.
]=]
local function joinArrays(...: {}?): Types.Table
local arrays = { ... }
loca... | 121 |
Roblox/dash | Roblox-dash-5a885be/src/joinDeep.lua | luau | .lua | local Dash = script.Parent
local None = require(Dash.None)
local Types = require(Dash.Types)
local forEach = require(Dash.forEach)
-- TODO Luau: Support typing varargs
-- TODO Luau: Support function generics
--[=[
Creates a shallow clone of the _source_ map, and copies the values from the _delta_ map by key, like the... | 325 |
Roblox/dash | Roblox-dash-5a885be/src/keys.lua | luau | .lua | local insert = table.insert
--[=[
Returns an array of the keys in the _input_ table.
If the input is an array, ordering is preserved.
If the input is a Map, elements are returned in an arbitrary order.
@param input The table to extract keys from.
@return An array containing all keys from the input table.
]=]
lo... | 105 |
Roblox/dash | Roblox-dash-5a885be/src/last.lua | luau | .lua | export type FindHandler<Value> = (Value, number) -> boolean
--[=[
Returns the last element in the _input_ array that satisfies the _handler_ predicate.
If no _handler_ is provided, returns the last element of the array.
If no entries satisfy the condition, returns `nil`.
@param input The array to search.
@param... | 195 |
Roblox/dash | Roblox-dash-5a885be/src/leftPad.lua | luau | .lua | --[=[
Makes a string of _length_ from _input_ by repeating characters from _prefix_ at the start of the string.
@param input The string to pad.
@param length The desired total length of the result.
@param prefix The character(s) to use for padding; defaults to a single space.
@return A new string padded to the sp... | 246 |
Roblox/dash | Roblox-dash-5a885be/src/map.lua | luau | .lua | local Dash = script.Parent
local Types = require(Dash.Types)
local assertEqual = require(Dash.assertEqual)
export type MapHandler<Key, Value, NewValue> = (Value, Key) -> NewValue
--[=[
Returns a new table by applying the _handler_ to each element of _input_.
For an array input, the elements are visited in order 1.... | 240 |
Roblox/dash | Roblox-dash-5a885be/src/mapFirst.lua | luau | .lua | export type MapHandler<Value, NewValue> = (Value, number) -> NewValue?
--[=[
Iterates through the elements of the _input_ array in order 1..n and returns the first non-nil value from the _handler_.
If all values returned by the _handler_ are `nil`, `nil` is returned.
@param input The array to iterate over.
@para... | 189 |
Roblox/dash | Roblox-dash-5a885be/src/mapLast.lua | luau | .lua | export type MapHandler<Value, NewValue> = (Value, number) -> NewValue?
--[=[
Iterates through the elements of the _input_ array in reverse order n..1 and returns the first non-nil value from the _handler_.
If all values returned by the _handler_ are `nil`, `nil` is returned.
@param input The array to iterate over... | 199 |
Roblox/dash | Roblox-dash-5a885be/src/mapNotNil.lua | luau | .lua | local Dash = script.Parent
local Types = require(Dash.Types)
export type MapHandler<Key, Value, NewValue> = (Value, Key) -> NewValue
--[=[
Returns a new table by applying the _handler_ to each element of _input_.
For a Map input, the elements are visited in an arbitrary order.
If a nil value is returned from the... | 214 |
Roblox/dash | Roblox-dash-5a885be/src/mapOne.lua | luau | .lua | export type MapHandler<Key, Value, NewValue> = (Value, Key) -> NewValue?
--[=[
Iterates through the elements of the _input_ table in no particular order and returns the first non-nil value.
If a _handler_ is provided, returns the first non-nil value returned by the handler.
If no _handler_ is provided, returns the... | 220 |
Roblox/dash | Roblox-dash-5a885be/src/max.lua | luau | .lua | local Dash = script.Parent
local reduce = require(Dash.reduce)
-- Return true if a > b
type MaxComparator = (any, any) -> boolean
type MaxHandler = (any, any) -> any
local defaultComparator = function(a: number | string, b: number | string)
return a > b
end
--[=[
Returns the maximum value in the _input_ table. By ... | 561 |
Roblox/dash | Roblox-dash-5a885be/src/memoize.lua | luau | .lua | local Dash = script.Parent
local Types = require(Dash.Types)
export type ResolverFunction = (...any) -> string
--[=[
Creates a function that memoizes the result of _func_. The memoized function will cache results based on the arguments provided. If a resolver function is provided, it will be used to generate the cac... | 331 |
Roblox/dash | Roblox-dash-5a885be/src/min.lua | luau | .lua | local Dash = script.Parent
local reduce = require(Dash.reduce)
-- Return true if a < b
type MinComparator = (any, any) -> boolean
type MinHandler = (any, any) -> any
local defaultComparator = function(a, b)
return a < b
end
-- TODO (AleksandrSl 03/06/2024): Can be further "optimized" by writing a compare function t... | 590 |
Roblox/dash | Roblox-dash-5a885be/src/noop.lua | luau | .lua | --[=[
A function which does nothing.
Can be used to make it clear that a handler has no function.
@return Always returns `nil`.
]=]
-- selene: allow(unused_variable)
local function noop(...: any) end
return noop
| 53 |
Roblox/dash | Roblox-dash-5a885be/src/omit.lua | luau | .lua | local Dash = script.Parent
local collectSet = require(Dash.collectSet)
local forEach = require(Dash.forEach)
local Types = require(Dash.Types)
--[=[
Returns a new table made from entries in the _input_ table whose key is not in the _keys_ array.
If the input is an array, ordering is preserved.
If the input is a Ma... | 181 |
Roblox/dash | Roblox-dash-5a885be/src/pick.lua | luau | .lua | local Dash = script.Parent
local Types = require(Dash.Types)
export type PickHandler<Key, Value> = (Value, Key) -> boolean
--[=[
Returns a new table containing only the entries from _input_ for which the _handler_ returns truthy.
@param input The table to filter.
@param handler Function called as `(value, key)` fo... | 157 |
Roblox/dash | Roblox-dash-5a885be/src/pipe.lua | luau | .lua | --[=[
Creates a function that returns the result of passing a value through a pipeline of functions.
Each function in the pipeline receives the result of the previous function.
Functions are executed from left to right.
@param f The first function in the pipeline.
@param ... Additional functions to pipe.
@return... | 283 |
Roblox/dash | Roblox-dash-5a885be/src/pretty.lua | luau | .lua | local Dash = script.Parent
local Types = require(Dash.Types)
local append = require(Dash.append)
local assign = require(Dash.assign)
local cycles = require(Dash.cycles)
local includes = require(Dash.includes)
local join = require(Dash.join)
local map = require(Dash.map)
local keys = require(Dash.keys)
local slice = re... | 1,560 |
Roblox/dash | Roblox-dash-5a885be/src/product.lua | luau | .lua | local Dash = script.Parent
local reduce = require(Dash.reduce)
--[=[
Multiplies all numbers in the _input_ array.
If the _input_ has no elements, returns `1`.
@param input The array of numbers to multiply.
@return The product of all numbers in the array.
@example
```luau
Dash.product({3, 3, 2}) --> 18
```
]... | 129 |
Roblox/dash | Roblox-dash-5a885be/src/reduce.lua | luau | .lua | export type ReduceHandler<Key, Value, Accumulator> = (Accumulator, Value, Key) -> Accumulator
--[=[
Iterates through the elements of the _input_ table and calls the _handler_ for each element,
passing the return of the previous call as the first argument.
The _initial_ value is passed into the first call, and the ... | 191 |
Roblox/dash | Roblox-dash-5a885be/src/reverse.lua | luau | .lua | local insert = table.insert
--[=[
Reverses the order of the elements in the _input_ array.
@param input The array to reverse.
@return A new array with elements in reverse order.
]=]
local function reverse<T>(input: { T }): { T }
local output: { T } = {}
for i = #input, 1, -1 do
insert(output, input[i])
end
r... | 96 |
Roblox/dash | Roblox-dash-5a885be/src/rightPad.lua | luau | .lua | --[=[
Makes a string of _length_ from _input_ by repeating characters from _suffix_ at the end of the string.
By default, suffix is " ".
@param input The string to pad.
@param length The desired total length of the result.
@param suffix The character(s) to use for padding; defaults to a single space.
@return A ... | 252 |
Roblox/dash | Roblox-dash-5a885be/src/shallowEqual.lua | luau | .lua | --[=[
Returns `true` if the _left_ and _right_ values are equal (by the equality operator) or the inputs are tables, and all their keys are equal.
@param left The first value to compare.
@param right The second value to compare.
@return `true` if the values are shallowly equal, `false` otherwise.
]=]
local functio... | 208 |
Roblox/dash | Roblox-dash-5a885be/src/slice.lua | luau | .lua | local insert = table.insert
--[=[
Returns a portion of the _input_ array starting with the element at the _left_ index and ending with the element at the _right_ index (i.e. an inclusive range).
If _left_ is not defined, it defaults to 1.
If _right_ is not defined, it defaults to the length of the array (i.e. the ... | 304 |
Roblox/dash | Roblox-dash-5a885be/src/some.lua | luau | .lua | export type SomeHandler<Key, Value> = (Value, Key) -> boolean
--[=[
Iterates through the elements of the _input_ table in no particular order.
Calls the _handler_ for each entry and returns `true` if the handler returns truthy for any element which it is called with.
@param input The table to iterate over.
@para... | 166 |
Roblox/dash | Roblox-dash-5a885be/src/splitOn.lua | luau | .lua | local insert = table.insert
--[=[
Splits _input_ into parts based on a _pattern_ delimiter and returns a table of the parts, followed by a table of the matched delimiters.
@param input The string to split.
@param pattern The delimiter pattern to split on.
@return A tuple containing the parts array and delimiters ... | 238 |
Roblox/dash | Roblox-dash-5a885be/src/startsWith.lua | luau | .lua | --[=[
Checks whether _input_ starts with the string _prefix_.
@param input The string to check.
@param prefix The prefix to check for.
@return `true` if _input_ starts with _prefix_; otherwise `false`.
@example
```luau
startsWith("Fun Roblox Games", "Fun") --> true
```
@example
```luau
startsWith("Chess",... | 135 |
Roblox/dash | Roblox-dash-5a885be/src/sum.lua | luau | .lua | local Dash = script.Parent
local reduce = require(Dash.reduce)
--[=[
Sums all numbers in the _input_ array.
If the input array has no elements, returns `0`.
@param input The array of numbers to sum.
@return The sum of all numbers in the array.
@example
```luau
Dash.sum({3, 2, 1}) --> 6
```
]=]
local functio... | 127 |
Roblox/dash | Roblox-dash-5a885be/src/throttle.lua | luau | .lua | local Dash = script.Parent
local assign = require(Dash.assign)
type ThrottleOptions = {
leading: boolean?,
trailing: boolean?,
}
type ThrottleOptionsInternal = {
leading: boolean,
trailing: boolean,
}
-- `& (...any) -> ...any` in the function type is a funky way to mimick `T extends function`
type AnyVoidFunctio... | 912 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.