repo
stringclasses
350 values
file_path
stringlengths
29
200
language
stringclasses
2 values
file_type
stringclasses
4 values
code
stringlengths
2
1.01M
tokens
int64
2
598k
Roblox/signals
Roblox-signals-7ef2ff7/modules/signals-experimental/src/createReducer.lua
luau
.lua
local Packages = script.Parent.Parent local Signals = require(Packages.Signals) local createComputed = Signals.createComputed type getter<T> = Signals.getter<T> type scope = Signals.scope local function createReducer<T>(reducer: (scope, previous: T) -> T, initial: (() -> T) | T): getter<T> local isInitialized = fals...
153
Roblox/signals
Roblox-signals-7ef2ff7/modules/signals-experimental/src/init.lua
luau
.lua
local SignalsScheduler = require(script.Parent.SignalsScheduler) local createProxy = require(script.createProxy) export type proxy<T> = createProxy.proxy<T> return { batch = SignalsScheduler.batch, createProxy = createProxy, createReducer = require(script.createReducer), onDisposed = require(script.onDisposed), }...
63
Roblox/signals
Roblox-signals-7ef2ff7/modules/signals-experimental/src/onDisposed.lua
luau
.lua
local Packages = script.Parent.Parent local Signals = require(Packages.Signals) type scope = Signals.scope type dispose = Signals.dispose local function onDisposed(scope: scope, dispose: dispose) local function source(_, delete: true?) if delete then dispose() end return 0 end scope(source) end return o...
76
Roblox/signals
Roblox-signals-7ef2ff7/modules/signals-flags/src/init.lua
luau
.lua
local _, SignalsSchedulerResetStateAfterErrors = xpcall(function() return game:DefineFastFlag("SignalsSchedulerResetStateAfterErrors", false) end, function() return true end) return { SignalsSchedulerResetStateAfterErrors = SignalsSchedulerResetStateAfterErrors, }
57
Roblox/signals
Roblox-signals-7ef2ff7/modules/signals-implicit-scope/src/SignalsImplicitScope.lua
luau
.lua
local Signals = require(script.Parent.Parent.Signals) local createExplicitSignal = Signals.createSignal local createExplicitComputed = Signals.createComputed local createExplicitEffect = Signals.createEffect export type getter<T> = (false | nil) -> T export type setter<T> = Signals.setter<T> export type update<T> = Si...
456
Roblox/signals
Roblox-signals-7ef2ff7/modules/signals-implicit-scope/src/__tests__/SignalsImplicitScope.test.lua
luau
.lua
local Root = script:FindFirstAncestor("SignalsImplicitScope") local Packages = Root.Parent local JestGlobals = require(Packages.Dev.JestGlobals) local expect = JestGlobals.expect local it = JestGlobals.it local SignalsImplicitScope = require(script.Parent.Parent.SignalsImplicitScope) local createSignal = SignalsImpli...
507
Roblox/signals
Roblox-signals-7ef2ff7/modules/signals-implicit-scope/src/init.lua
luau
.lua
local SignalsImplicitScope = require(script.SignalsImplicitScope) export type getter<T> = SignalsImplicitScope.getter<T> export type setter<T> = SignalsImplicitScope.setter<T> export type update<T> = SignalsImplicitScope.update<T> export type equals<T> = SignalsImplicitScope.equals<T> export type dispose = SignalsImpl...
75
Roblox/signals
Roblox-signals-7ef2ff7/modules/signals-scheduler/src/SignalsScheduler.lua
luau
.lua
export type work = () -> () local Packages = script.Parent.Parent local SignalsFlags = require(Packages.SignalsFlags) local SignalsSchedulerResetStateAfterErrors = SignalsFlags.SignalsSchedulerResetStateAfterErrors local isContinuing = false local continuations: { work } = {} local function runWork(fn: work) fn() ...
357
Roblox/signals
Roblox-signals-7ef2ff7/modules/signals-scheduler/src/__tests__/SignalsScheduler.test.lua
luau
.lua
local Root = script:FindFirstAncestor("SignalsScheduler") local Packages = Root.Parent local JestGlobals = require(Packages.Dev.JestGlobals) local expect = JestGlobals.expect local it = JestGlobals.it local SignalsFlags = require(Packages.SignalsFlags) local SignalsSchedulerResetStateAfterErrors = SignalsFlags.Signal...
1,175
Roblox/signals
Roblox-signals-7ef2ff7/modules/signals-scheduler/src/init.lua
luau
.lua
local SignalsScheduler = require(script.SignalsScheduler) export type work = SignalsScheduler.work return SignalsScheduler
22
Roblox/signals
Roblox-signals-7ef2ff7/modules/signals/src/Signals.lua
luau
.lua
local Packages = script.Parent.Parent local SignalsScheduler = require(Packages.SignalsScheduler) local flush = SignalsScheduler.flush local schedule = SignalsScheduler.schedule local callUserSpace = require(script.Parent.callUserSpace) export type getter<T> = (scope | false | nil) -> T export type setter<T> = (updat...
1,789
Roblox/signals
Roblox-signals-7ef2ff7/modules/signals/src/__tests__/Signals.test.lua
luau
.lua
local Root = script:FindFirstAncestor("Signals") local Packages = Root.Parent local JestGlobals = require(Packages.Dev.JestGlobals) local expect = JestGlobals.expect local it = JestGlobals.it local SignalsScheduler = require(Packages.SignalsScheduler) local batch = SignalsScheduler.batch local Signals = require(scri...
5,246
Roblox/signals
Roblox-signals-7ef2ff7/modules/signals/src/callUserSpace.lua
luau
.lua
local validationEnabled = _G.__SIGNALS_VALIDATION_ENABLED__ or _G.__DEV__ local function handleNoYieldValidation(co: thread, ok: boolean, ...) if not ok then local err = (...) if typeof(err) == "string" then error(debug.traceback(co, err), 2) else error(tostring(err), 2) end end if coroutine.status(c...
222
Roblox/signals
Roblox-signals-7ef2ff7/modules/signals/src/init.lua
luau
.lua
local Signals = require(script.Signals) export type getter<T> = Signals.getter<T> export type setter<T> = Signals.setter<T> export type update<T> = Signals.update<T> export type equals<T> = Signals.equals<T> export type dispose = Signals.dispose export type scope = Signals.scope return Signals
66
Roblox/signals
Roblox-signals-7ef2ff7/scripts/processExecution.luau
luau
.luau
const process = require("@std/process") const tableext = require("@std/tableext") const function runStep(name: string, command: { string }, options: process.ProcessRunOptions?) print(`{name}: {table.concat(command, " ")}`) const result = process.run( command, tableext.combine({ stdio = "inherit", }, options...
108
Roblox/signals
Roblox-signals-7ef2ff7/scripts/test.lua
luau
.lua
local ReplicatedStorage = game:GetService("ReplicatedStorage") local Packages = ReplicatedStorage:FindFirstChild("Packages") or error("Packages folder not found") local JestPackages = Packages:QueryDescendants("ModuleScript#Jest") assert(#JestPackages > 0, "No Jest packages found") local Jest = require(JestPackages[1]...
217
Roblox/signals
Roblox-signals-7ef2ff7/src/init.lua
luau
.lua
--!strict local Signals = require(script.Signals) local SignalsExperimental = require(script.SignalsExperimental) export type getter<T> = Signals.getter<T> export type setter<T> = Signals.setter<T> export type update<T> = Signals.update<T> export type equals<T> = Signals.equals<T> export type dispose = Signals.dispose...
116
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
luau-lang/lute
luau-lang-lute-c57dec9/.config.luau
luau
.luau
return { luau = { languagemode = "strict", lint = { ["*"] = true }, linterrors = true, aliases = { commands = "./lute/cli/commands", lute = "./definitions", std = "./lute/std/libs", }, }, lute = { lint = { ignores = { "**/*.d.luau", "**/*.snap.luau" }, }, format = { ignores = { "**...
171
luau-lang/lute
luau-lang-lute-c57dec9/.lute/bootstrap.luau
luau
.luau
--!strict local process = require("@lute/process") -- LUAUFIX: should `...` actually have the type `string...` for command-line environments local args: { [number]: string, n: number } = table.pack(...) :: any local cmd: { string } = { "tools/bootstrap.sh", table.unpack(args, 2, args.n) } local result = process.run...
100
luau-lang/lute
luau-lang-lute-c57dec9/.lute/luthier.luau
luau
.luau
--!strict local process = require("@lute/process") -- LUAUFIX: should `...` actually have the type `string...` for command-line environments local args: { [number]: string, n: number } = table.pack(...) :: any local cmd: { string } = { process.execPath(), "tools/luthier.luau", table.unpack(args, 2, args.n) } local ...
107
luau-lang/lute
luau-lang-lute-c57dec9/batteries/base64.luau
luau
.luau
--!optimize 2 --!strict local BASE64_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" local BASE64_ENCODING_LUT = table.create(4096) :: { number } local BASE64_DECODING_LUT = buffer.create(256) do for i = 0, 4095 do local hi = bit32.rshift(i, 6) + 1 local lo = bit32.band(i, 0x3F) + 1...
1,514
luau-lang/lute
luau-lang-lute-c57dec9/batteries/cli.luau
luau
.luau
local cli = {} cli.__index = cli type ArgKind = "positional" | "flag" | "option" | "variadic" type ArgOptions = { help: string?, aliases: { string }?, default: string?, required: boolean?, hidden: boolean?, } type ArgData = { name: string, kind: ArgKind, options: ArgOptions, } type ParseResult = { values: {...
1,651
luau-lang/lute
luau-lang-lute-c57dec9/batteries/collections/deque.luau
luau
.luau
type DequeData<T> = { _head: number, _tail: number, _values: { [number]: T }, } local deque = {} export type Deque<T> = setmetatable<DequeData<T>, typeof(deque)> deque.__index = deque deque.__len = function<T>(self: Deque<T>) return self._tail - self._head + 1 end local dequeLib = {} function dequeLib.new<T>(i...
422
luau-lang/lute
luau-lang-lute-c57dec9/batteries/difftext/init.luau
luau
.luau
local myersdiff = require("@self/myersdiff") local printdiff = require("@self/printdiff") local types = require("@self/types") export type diff = types.diff export type diffoptions = types.diffoptions local function diff(a: string, b: string, options: diffoptions): diff if options and options.byChar then return my...
124
luau-lang/lute
luau-lang-lute-c57dec9/batteries/difftext/myersdiff.luau
luau
.luau
local deque = require("@batteries/collections/deque") local tableext = require("@std/tableext") local types = require("./types") type diffoperation = types.diffoperation type diff = types.diff type EditGraphNode = { x: number, y: number, prev: EditGraphNode?, } local function editGraphNode(x: number, y: number, p...
1,287
luau-lang/lute
luau-lang-lute-c57dec9/batteries/difftext/printdiff.luau
luau
.luau
local richterm = require("@batteries/richterm") local myersdiff = require("./myersdiff") local myersdiffbychar = myersdiff.myersdiffbychar local myersdiffbyline = myersdiff.myersdiffbyline local types = require("./types") local brightGreen = richterm.brightGreen local brightRed = richterm.brightRed local bgGreen = rich...
1,799
luau-lang/lute
luau-lang-lute-c57dec9/batteries/difftext/types.luau
luau
.luau
export type diffoperationkey = "EQUAL" | "ADD" | "DELETE" export type diffoperation = { key: diffoperationkey, text: string, } export type diff = { diffoperation } export type diffoptions = { byChar: boolean?, }? return table.freeze({})
61
luau-lang/lute
luau-lang-lute-c57dec9/batteries/glob.luau
luau
.luau
--[[ Glob pattern matching and filesystem discovery. `glob.match(pattern, input)` tests whether a path matches a glob pattern. `glob.discover(pattern)` walks the filesystem returning all matching `Path`s. The implementation follows the Rust glob crate. The rules are: - `?` matches any single char...
1,758
luau-lang/lute
luau-lang-lute-c57dec9/batteries/pp.luau
luau
.luau
type ExistingOptions = { rawStrings: boolean?, } local isPrimitiveType = { string = true, number = true, boolean = true } local typeSortOrder: { [string]: number } = { ["boolean"] = 1, ["number"] = 2, ["string"] = 3, ["function"] = 4, ["vector"] = 5, ["buffer"] = 6, ["thread"] = 7, ["table"] = 8, ["userdata...
1,226
luau-lang/lute
luau-lang-lute-c57dec9/batteries/result.luau
luau
.luau
type T<Value> = | { success: true, value: Value } | { success: false, traceback: string, err: string } local result = {} function result.ok<Value>(value: Value): T<Value> return { success = true, value = value, } end function result.fail<Value>(err: string): T<Value> -- Ignore the current call to debug.traceb...
192
luau-lang/lute
luau-lang-lute-c57dec9/batteries/richterm.luau
luau
.luau
--[[ richterm terminal ansi formatter ]] export type Formatter = (s: string, nocolor: boolean?) -> string -- @noinline (if it ever exists) local function format(s: string, open: string, close: string, replace: string): string local index = string.find(s, close, #open + 1, true) local middle = s if index then ...
1,177
luau-lang/lute
luau-lang-lute-c57dec9/definitions/crypto.luau
luau
.luau
-- lute-lint-global-ignore(unused_variable) local crypto = {} export type Hash<T> = { __hash: T } crypto.hash = table.freeze({ md5 = {} :: Hash<"md5">, sha1 = {} :: Hash<"sha1">, sha256 = {} :: Hash<"sha256">, sha512 = {} :: Hash<"sha512">, blake2b256 = {} :: Hash<"blake2b256">, }) --- Computes a cryptographic ...
396
luau-lang/lute
luau-lang-lute-c57dec9/definitions/fs.luau
luau
.luau
-- lute-lint-global-ignore(unused_variable) local time = require("./time") local fs = {} --- An open file handle returned by `fs.open`. export type FileHandle = { fd: number, err: number, } --- The type of a filesystem entry: --- - `"file"`: A regular file. --- - `"dir"`: A directory. --- - `"link"`: A symbolic li...
1,232
luau-lang/lute
luau-lang-lute-c57dec9/definitions/luau.luau
luau
.luau
-- lute-lint-global-ignore(unused_variable) local luau = {} --- Compiled Luau bytecode produced by `luau.compile`. export type Bytecode = { bytecode: string } --- Compiles Luau `source` to bytecode. function luau.compile(source: string): Bytecode error("not implemented") end --- Loads `bytecode` into a callable fu...
646
luau-lang/lute
luau-lang-lute-c57dec9/definitions/process.luau
luau
.luau
-- lute-lint-global-ignore(unused_variable) --- How a child process's standard streams should be handled: --- - `"default"`: Capture stdout and stderr to pipes, accessible via `ProcessResult`. --- - `"inherit"`: Pass the parent process's stdio streams through to the child. --- - `"none"`: Discard the child's stdio stre...
885
luau-lang/lute
luau-lang-lute-c57dec9/definitions/syntax/parser.luau
luau
.luau
-- lute-lint-global-ignore(unused_variable) local cst = require("./cst") local parser = {} --- Parses `source` as a Luau script and returns the resulting CST. function parser.parse(source: string): cst.CstParseResult error("not implemented") end --- Parses `source` as a single Luau expression and returns the result...
100
luau-lang/lute
luau-lang-lute-c57dec9/definitions/system.luau
luau
.luau
--- CPU information for a single logical processor, including model, speed, and time-usage breakdown. export type CpuInfo = { model: string, speed: number, times: { sys: number, idle: number, irq: number, nice: number, user: number, }, } local system = {} --- Returns the number of logical CPU threads a...
316
luau-lang/lute
luau-lang-lute-c57dec9/definitions/task.luau
luau
.luau
-- lute-lint-global-ignore(unused_variable) local time = require("./time") local task = {} --- Schedules `routine` to run immediately on the next resumption cycle, passing any additional arguments to it. Returns the thread. function task.spawn<T..., U...>(routine: ((T...) -> U...) | thread, ...: T...): thread error(...
324
luau-lang/lute
luau-lang-lute-c57dec9/definitions/time.luau
luau
.luau
-- lute-lint-global-ignore(unused_variable) local time = {} local duration_ops = {} local instant = {} --- Returns the current time as an `Instant`. function time.now(): Instant error("not implemented") end --- Returns the number of seconds elapsed since `instant`. function time.since(instant: Instant): number err...
856
luau-lang/lute
luau-lang-lute-c57dec9/definitions/vm.luau
luau
.luau
-- lute-lint-global-ignore(unused_variable) local vm = {} --- Creates a new Luau VM from the module at `path` and returns its exported table. function vm.create(path: string): { [any]: any } error("not implemented") end return vm
58
luau-lang/lute
luau-lang-lute-c57dec9/docs/docgen.luau
luau
.luau
return { ["../lute/std/libs"] = { alias = "std", destination = "std" }, ["../definitions"] = { alias = "lute", destination = "lute" }, }
44
luau-lang/lute
luau-lang-lute-c57dec9/examples/a.luau
luau
.luau
local _ = require("./b")
7
luau-lang/lute
luau-lang-lute-c57dec9/examples/b.luau
luau
.luau
print("hello there") return {}
7
luau-lang/lute
luau-lang-lute-c57dec9/examples/cliargs.luau
luau
.luau
local cli = require("@batteries/cli") local args = cli.parser() args:add("input", "positional", { help = "Input file" }) args:add("verbose", "flag", { help = "Enable verbose mode", aliases = { "v" } }) args:add("output", "option", { help = "Output file", aliases = { "o" }, default = "default.txt" }) args:parse({ ......
136
luau-lang/lute
luau-lang-lute-c57dec9/examples/colorful.luau
luau
.luau
local richterm = require("@batteries/richterm") print(richterm.red("This is red text!")) print(richterm.bgRed("This is red background!")) print(richterm.bold("This is bold text!")) print(richterm.underline("This is underlined text!")) print(richterm.dim(richterm.italic("This is dim italic text!"))) print(richterm.red...
129
luau-lang/lute
luau-lang-lute-c57dec9/examples/compile.luau
luau
.luau
local luau = require("@std/luau") local bytecode_container = luau.compile('return "Hello, world!"') print(`Bytecode is {#bytecode_container["bytecode"]} bytes long`) print(luau.load(bytecode_container)())
54
luau-lang/lute
luau-lang-lute-c57dec9/examples/create_directory.luau
luau
.luau
local fs = require("@std/fs") local path = require("@std/path") local system = require("@std/system") local tmpdir = system.tmpdir() local directory = path.join(tmpdir, "example_dir") fs.createDirectory(directory, { makeParents = true }) if fs.exists(directory) and fs.type(directory) == "dir" then print("Directory ...
118
luau-lang/lute
luau-lang-lute-c57dec9/examples/difftext.luau
luau
.luau
local difftext = require("@batteries/difftext") local richterm = require("@batteries/richterm") local src = [[ local originalVariable = 1 local same = 1 function doSomething() -- comment -- removed print(originalVariable * 2) end print() ]] local destination = [[ local newVariable = 2 local same = 1 functi...
230
luau-lang/lute
luau-lang-lute-c57dec9/examples/directories.luau
luau
.luau
local fs = require("@std/fs") for _, file in fs.listDirectory("./examples") do print(`Example {file.name} is a {file.type}`) end
35
luau-lang/lute
luau-lang-lute-c57dec9/examples/docs/test_module.luau
luau
.luau
-- lute-lint-global-ignore(unused_variable) -- This file creates a mock module called test_module with random mock functions and different types of comments to test the reference doc generator reference.luau -- See output documentation file generated in this folder `test_module.md` local test_module = {} --- Property...
299
luau-lang/lute
luau-lang-lute-c57dec9/examples/fib.luau
luau
.luau
local module = {} function module.fib(n: number) return if n <= 2 then 1 else module.fib(n - 1) + module.fib(n - 2) end function module.fibTable(t: { n: number }) return if t.n <= 2 then 1 else module.fibTable({ n = t.n - 1 }) + module.fibTable({ n = t.n - 2 }) end return module
96
luau-lang/lute
luau-lang-lute-c57dec9/examples/fs_metadata.luau
luau
.luau
local fs = require("@std/fs") local path = require("@std/path") local process = require("@std/process") local scriptPath = path.resolve(process.cwd(), process.args[1]) local metadata = fs.metadata(scriptPath) local created = metadata.created print(tostring(created))
57
luau-lang/lute
luau-lang-lute-c57dec9/examples/hash.luau
luau
.luau
local crypto = require("@lute/crypto") local base64 = require("@batteries/base64") local message = "Hello, world!" local digest = crypto.digest(crypto.hash.sha256, message) function hexify(digest) local hex = {} for i = 1, buffer.len(digest) do hex[i] = string.format("%02x", buffer.readu8(digest, i - 1)) end r...
127
luau-lang/lute
luau-lang-lute-c57dec9/examples/homedir_cwd.luau
luau
.luau
local process = require("@std/process") print(process.cwd(), process.homedir())
17
luau-lang/lute
luau-lang-lute-c57dec9/examples/json.luau
luau
.luau
local json = require("@std/json") local serialize = json.serialize({ hello = "world", }, true) print(serialize) local deserialized = json.deserialize([[{ "hello": "world" }]]) deserialized = assert(json.asObject(deserialized)) print(deserialized.hello)
60
luau-lang/lute
luau-lang-lute-c57dec9/examples/lints/almost_swapped.luau
luau
.luau
-- Check out lute/cli/commands/lint/rules for the default rules used by lute lint! local lintTypes = require("@lint") local path = require("@std/path") local query = require("@std/syntax/query") local syntax = require("@std/syntax") local utils = require("@std/syntax/utils") local name = "almost_swapped" local messag...
900
luau-lang/lute
luau-lang-lute-c57dec9/examples/lints/divide_by_zero.luau
luau
.luau
-- Check out lute/cli/commands/lint/rules for the default rules used by lute lint! local lintTypes = require("@lint") local path = require("@std/path") local query = require("@std/syntax/query") local syntax = require("@std/syntax") local utils = require("@std/syntax/utils") local name = "divide_by_zero" local messag...
324
luau-lang/lute
luau-lang-lute-c57dec9/examples/main.luau
luau
.luau
print("hello")
4
luau-lang/lute
luau-lang-lute-c57dec9/examples/module_return_type/get_module_return_type.luau
luau
.luau
local luau = require("@std/luau") local path = require("@std/path") local process = require("@std/process") local filePath = path.join(process.cwd(), "examples", "module_return_type", "mainmodule.luau") local returnType = luau.typeofModule(filePath) if not returnType then error("Failed to get module return type") en...
298
luau-lang/lute
luau-lang-lute-c57dec9/examples/module_return_type/mainmodule.luau
luau
.luau
local tableext = require("@std/tableext") local testFilter: { [string]: number } = { ["a"] = 1, } local module = {} function module.func1(a: number) return function(s: string): boolean return s == tostring(a) end end module.strings = tableext.map(testFilter, function(value) return tostring(value) end) module...
99
luau-lang/lute
luau-lang-lute-c57dec9/examples/net_example.luau
luau
.luau
local net = require("@std/net") local task = require("@std/task") local pp = require("@batteries/pp") print(net.request("https://en.wikipedia.org/").status) print(pp(net.request("https://en.wikipedia.org/").headers)) local start = os.clock() local results = {} local done = 0 task.spawn(function() results[1] = n...
213
luau-lang/lute
luau-lang-lute-c57dec9/examples/options_transformer.luau
luau
.luau
local query = require("@std/syntax/query") local syntax = require("@std/syntax") local syntax_utils = require("@std/syntax/utils") local transformTypes = require("@transform") return { options = { { kind = "string", name = "functionName", default = "math.isnan" }, }, transform = function(ctx: transformTypes.Cont...
202
luau-lang/lute
luau-lang-lute-c57dec9/examples/parallel_serve.luau
luau
.luau
local vm = require("@lute/vm") local task = require("@std/task") local threadCount = 8 for _ = 1, threadCount do task.spawn(vm.create("./parallel_serve_helper").serve) end print(`Created {threadCount} server threads`)
59
luau-lang/lute
luau-lang-lute-c57dec9/examples/parallel_serve_helper.luau
luau
.luau
local server = require("@lute/net/server") return { serve = function() server.serve({ handler = function(_) return "Hello, lute!" end, reuseport = true, }) end, }
52
luau-lang/lute
luau-lang-lute-c57dec9/examples/parallel_sort.luau
luau
.luau
local vm = require("@lute/vm") local task = require("@std/task") local function getslice(t, n: number, m: number) local size = math.ceil(#t / m) local slice = table.create(size) table.move(t, 1 + (n - 1) * size, n * size, 1, slice) return slice end local function merge<T>(t1: { T }, t2: { T }, comp: (T, T) -> l...
740
luau-lang/lute
luau-lang-lute-c57dec9/examples/parallel_sort_helper.luau
luau
.luau
return { sort = function(t) -- LUAUFIX - we cannot figure out the type of the array elements, even with an annotation on t. table.sort(t, function(a: number, b: number) return a < b end) return t end, }
62
luau-lang/lute
luau-lang-lute-c57dec9/examples/parsing.luau
luau
.luau
local syntax = require("@std/syntax") local pretty = require("@batteries/pp") local foo = syntax.parseExpr("5") print(pretty(foo))
33
luau-lang/lute
luau-lang-lute-c57dec9/examples/process.luau
luau
.luau
local process = require("@std/process") process.system("echo hello", {}) local result = process.run({ "echo", "Hello, lute!" }) print(result.exitcode) print(result.stdout) local r1 = process.run({ "echo", "-n", "One" }) local r2 = process.run({ "echo", "-n", "Two" }) local r3 = process.run({ "echo", "-n", "Three" }...
220
luau-lang/lute
luau-lang-lute-c57dec9/examples/process_env.luau
luau
.luau
local process = require("@std/process") print(process.env.HOME) print(process.env.LUTE_HOME) process.env.LUTE_HOME = "/home/lute" print(process.env.LUTE_HOME) for k, v in process.env do print(k, v) end
55
luau-lang/lute
luau-lang-lute-c57dec9/examples/profile_test.luau
luau
.luau
-- Test program for profiler with deep call stacks and recursion -- Fibonacci with recursion (creates deep stacks) local function fibonacci(n: number): number if n <= 1 then return n end return fibonacci(n - 1) + fibonacci(n - 2) end -- Array processing with nested calls local function processArray(arr: { number...
556
luau-lang/lute
luau-lang-lute-c57dec9/examples/pwhash.luau
luau
.luau
local crypto = require("@lute/crypto") local secret = "woof" local password = crypto.password.hash(secret) function hexify(digest) local hex = {} for i = 1, buffer.len(digest) do hex[i] = string.format("%02x", buffer.readu8(digest, i - 1)) end return table.concat(hex) end print(`password hash: {hexify(password...
124
luau-lang/lute
luau-lang-lute-c57dec9/examples/query.luau
luau
.luau
local syntax = require("@std/syntax") local query = require("@std/syntax/query") local utils = require("@std/syntax/utils") local cst = syntax.parseExpr("require(OldComponent)") local p = query.findAllFromRoot(cst, utils.isRequireCall):filter(function(call) local firstArg = call.arguments[1] return firstArg.tag == ...
136
luau-lang/lute
luau-lang-lute-c57dec9/examples/query_transformer.luau
luau
.luau
local query = require("@std/syntax/query") local syntax = require("@std/syntax") local syntax_utils = require("@std/syntax/utils") local transformTypes = require("@transform") local function transform(ctx: transformTypes.Context) return query .findAllFromRoot(ctx.parseresult :: syntax.CstParseResult, syntax_utils....
165
luau-lang/lute
luau-lang-lute-c57dec9/examples/secretbox.luau
luau
.luau
local crypto = require("@lute/crypto") local message = "Hello, world!" local box = crypto.secretbox.seal(message) function hexify(digest) local hex = {} for i = 1, buffer.len(digest) do hex[i] = string.format("%02x", buffer.readu8(digest, i - 1)) end return table.concat(hex) end print(hexify(box.ciphertext)) ...
124
luau-lang/lute
luau-lang-lute-c57dec9/examples/serve.luau
luau
.luau
local server = require("@lute/net/server") print("Starting server...") -- Start the server (non-blocking) local instance = server.serve(function(_) return "Hello, lute!" end) print(`Server listening on http://{instance.hostname}:{instance.port}`) print("Program ending, but server will continue running in the backg...
83
luau-lang/lute
luau-lang-lute-c57dec9/examples/spawn_example.luau
luau
.luau
local vm = require("@lute/vm") local task = require("@std/task") print("start") local vm1 = vm.create("./fib") local vm2 = vm.create("./fib") local vm3 = vm.create("./fib") print("fib(15):", vm1.fib(15)) print("fib(20):", vm2.fib(20)) print("done inline") do local start = os.clock() print("fib(10):", vm1.fib(10...
513
luau-lang/lute
luau-lang-lute-c57dec9/examples/system_environment_check.luau
luau
.luau
local system = require("@std/system") if system.win32 then print("Running on Windows") elseif system.linux then print("Running on Linux") elseif system.macos then print("Running on macOS") elseif system.unix then print("Running on Unix") else print("Unknown operating system") end
66
luau-lang/lute
luau-lang-lute-c57dec9/examples/system_lib.luau
luau
.luau
local system = require("@std/system") print( string.format( "%s (%s-%s) - %d cores, uptime for %ss | freemem: %dMB | totalmem: %dMB", system.hostName(), system.os, system.arch, system.threadCount(), tostring(system.uptime()), system.freeMemory(), system.totalMemory() ) ) for _i, _cpu in system.cpus(...
159
luau-lang/lute
luau-lang-lute-c57dec9/examples/task-delay.luau
luau
.luau
local task = require("@lute/task") task.delay(1, coroutine.create(print), vector.one) task.delay(1, print, vector.one)
31
luau-lang/lute
luau-lang-lute-c57dec9/examples/task-resume.luau
luau
.luau
local task = require("@lute/task") local c = coroutine.create(function() print("hello") -- We don't know what subsequent calls to coroutine.yield produce. print(coroutine.yield() :: any) print("wtf") end) task.resume(c) task.resume(c, "world", "meow for good measure") local _ = coroutine.running() task.spawn(pr...
88
luau-lang/lute
luau-lang-lute-c57dec9/examples/task-wait.luau
luau
.luau
local task = require("@lute/task") local time = require("@std/time") print(task.wait(1)) print(task.wait(time.duration.seconds(1))) print(task.wait()) -- while true do -- local start = time.now() -- local delta = task.wait(1) -- local stop = time.now() -- print(stop - start) -- print(delta) -- end
82
luau-lang/lute
luau-lang-lute-c57dec9/examples/testing.luau
luau
.luau
local test = require("@std/test") local runner = require("@std/test/runner") test.case("foo", function(assert) assert.eq(3, 3) assert.eq(6, 1) end) test.case("bar", function(assert) assert.eq("a", "b") end) test.case("baz", function(assert) assert.neq("a", "b") end) test.suite("MySuite", function(suite) -- bef...
446
luau-lang/lute
luau-lang-lute-c57dec9/examples/time_example.luau
luau
.luau
local time = require("@std/time") local duration = time.duration local fiveSeconds = duration.seconds(5) local tenSeconds = fiveSeconds * 2 local fifteenSeconds = fiveSeconds + tenSeconds print(fiveSeconds) print(tenSeconds) print(fifteenSeconds) print(fiveSeconds < tenSeconds) print(fifteenSeconds > tenSeconds) lo...
127
luau-lang/lute
luau-lang-lute-c57dec9/examples/time_instants.luau
luau
.luau
local time = require("@lute/time") local start = time.now() for _ = 1, 10000 do vector.dot(vector.one, vector.zero) end local stop = time.now() assert(stop > start) assert(stop ~= start) assert(start == start) print((stop - start):toMicroseconds())
67
luau-lang/lute
luau-lang-lute-c57dec9/examples/toml.luau
luau
.luau
local toml = require("@batteries/toml") local deserialized = toml.deserialize([=[ hello = "world" infinity = inf nan_value = nan escaped_string = "This is a string with a newline\ncharacter" [world] v1 = "hi" v2 = 8080 v3 = true [[users]] name = "Alice" age = 25 [[users]] name = "Bob" age = 30 [people.Tom] age = 3...
126