repo stringclasses 341
values | file_path stringlengths 29 173 | language stringclasses 2
values | file_type stringclasses 4
values | code stringlengths 2 1.66M | tokens int64 2 598k |
|---|---|---|---|---|---|
Kampfkarren/protoc-gen-luau | Kampfkarren-protoc-gen-luau-398d559/conformance/generated/google/protobuf/duration.luau | luau | .luau | --!strict
--!nolint LocalUnused
--!nolint ImportUnused
--# selene: allow(empty_if, if_same_then_else, manual_table_clone, unused_variable)
-- This file was @autogenerated by protoc-gen-luau
local proto = require("../../proto")
local typeRegistry = require("../../proto/typeRegistry")
type _Messages = {
Duration: _Dura... | 1,719 |
Kampfkarren/protoc-gen-luau | Kampfkarren-protoc-gen-luau-398d559/conformance/generated/google/protobuf/field_mask.luau | luau | .luau | --!strict
--!nolint LocalUnused
--!nolint ImportUnused
--# selene: allow(empty_if, if_same_then_else, manual_table_clone, unused_variable)
-- This file was @autogenerated by protoc-gen-luau
local proto = require("../../proto")
local typeRegistry = require("../../proto/typeRegistry")
type _Messages = {
FieldMask: _Fie... | 906 |
Kampfkarren/protoc-gen-luau | Kampfkarren-protoc-gen-luau-398d559/conformance/generated/google/protobuf/struct.luau | luau | .luau | --!strict
--!nolint LocalUnused
--!nolint ImportUnused
--# selene: allow(empty_if, if_same_then_else, manual_table_clone, unused_variable)
-- This file was @autogenerated by protoc-gen-luau
local proto = require("../../proto")
local typeRegistry = require("../../proto/typeRegistry")
type _Messages = {
Struct: _Struct... | 4,990 |
Kampfkarren/protoc-gen-luau | Kampfkarren-protoc-gen-luau-398d559/conformance/generated/google/protobuf/timestamp.luau | luau | .luau | --!strict
--!nolint LocalUnused
--!nolint ImportUnused
--# selene: allow(empty_if, if_same_then_else, manual_table_clone, unused_variable)
-- This file was @autogenerated by protoc-gen-luau
local proto = require("../../proto")
local typeRegistry = require("../../proto/typeRegistry")
type _Messages = {
Timestamp: _Tim... | 1,613 |
Kampfkarren/protoc-gen-luau | Kampfkarren-protoc-gen-luau-398d559/conformance/generated/google/protobuf/wrappers.luau | luau | .luau | --!strict
--!nolint LocalUnused
--!nolint ImportUnused
--# selene: allow(empty_if, if_same_then_else, manual_table_clone, unused_variable)
-- This file was @autogenerated by protoc-gen-luau
local proto = require("../../proto")
local typeRegistry = require("../../proto/typeRegistry")
type _Messages = {
DoubleValue: _D... | 7,084 |
Kampfkarren/protoc-gen-luau | Kampfkarren-protoc-gen-luau-398d559/conformance/jsonEncode.luau | luau | .luau | --!strict
local serde = require("@lune/serde")
local function isArray(input: { [any]: any })
local count = 0
for _ in input do
count += 1
end
return count == #input
end
-- Re-implementation of jsonEncode that guarantees JSON etc are round tripped
local function jsonEncode(input: any): string
if typeof(input) ... | 274 |
Kampfkarren/protoc-gen-luau | Kampfkarren-protoc-gen-luau-398d559/src/luau/proto/init.test.luau | luau | .luau | --!strict
-- TODO: This file is NOT RAN! Needs to be fixed in a properly run test file.
local proto = require("@self")
local function assertEquals<T>(x: T, y: T)
if x ~= y then
error(`{x} ~= {y}`, 2)
end
end
local function formatHex(input: string): string
local bytes = {}
for index = 1, #input do
table.inser... | 1,451 |
Kampfkarren/protoc-gen-luau | Kampfkarren-protoc-gen-luau-398d559/src/luau/wkt_mixins/Any.luau | luau | .luau | function _AnyImpl.jsonEncode(input: Any): { [string]: any }
local unpacked = input:unpack(typeRegistry.default)
assert(unpacked ~= nil, "Cannot JSON-encode empty Any")
local json = unpacked:jsonEncode()
if typeof(json) == "string" then
return { ["@type"] = input.type_url, ["value"] = json }
end
json["@type"]... | 331 |
Kampfkarren/protoc-gen-luau | Kampfkarren-protoc-gen-luau-398d559/src/luau/wkt_mixins/Any_methods.luau | luau | .luau | function _AnyImpl.pack(payload: proto.Message<any, any>, typeUrlPrefix: string): Any
return _AnyImpl.new({
type_url = typeUrlPrefix .. "/" .. payload.descriptor.fullName,
value = payload:encode(),
})
end
-- Luau: It refuses to believe these are the same unpack, for some reason
local anyUnpack: typeof(({} :: _Any... | 325 |
Kampfkarren/protoc-gen-luau | Kampfkarren-protoc-gen-luau-398d559/src/luau/wkt_mixins/BytesValue.luau | luau | .luau | function _BytesValueImpl.jsonEncode(self: BytesValue): string
return buffer.tostring(self.value)
end
function _BytesValueImpl.jsonDecode(anyValue: any): BytesValue
local value: string = anyValue
return _BytesValueImpl.new({
value = buffer.fromstring(value),
})
end
| 65 |
Kampfkarren/protoc-gen-luau | Kampfkarren-protoc-gen-luau-398d559/src/luau/wkt_mixins/Duration.luau | luau | .luau | -- Converts a number of nanos to a string representation.
-- Sign and trailing zeroes are dropped.
-- 500000000 -> ".5s"
-- 500000001 -> ".500000001s"
-- 0 -> ".0s"
-- 1 -> ".000000001s"
-- -1 -> "-.000000001s"
local function serializeFractionalNanos(nanos: number): string
nanos = nanos * math.sign(nanos)
local nano... | 793 |
Kampfkarren/protoc-gen-luau | Kampfkarren-protoc-gen-luau-398d559/src/luau/wkt_mixins/FieldMask.luau | luau | .luau | function _FieldMaskImpl.jsonEncode(fieldMask: FieldMask): string
return table.concat(fieldMask.paths, ",")
end
function _FieldMaskImpl.jsonDecode(anyInput: any): FieldMask
local input: string = anyInput
local paths = {}
for path in string.gmatch(input, "[^,]+") do
table.insert(paths, path)
end
return _FieldM... | 94 |
Kampfkarren/protoc-gen-luau | Kampfkarren-protoc-gen-luau-398d559/src/luau/wkt_mixins/ListValue.luau | luau | .luau | function _ListValueImpl.jsonEncode(list: ListValue): { any }
local serialized = {}
for _, value in list.values do
table.insert(serialized, messages.Value.jsonEncode(value))
end
return serialized
end
function _ListValueImpl.jsonDecode(anyValue: any): ListValue
local input: { any } = anyValue
local values = {... | 111 |
Kampfkarren/protoc-gen-luau | Kampfkarren-protoc-gen-luau-398d559/src/luau/wkt_mixins/Struct.luau | luau | .luau | function _StructImpl.jsonEncode(struct: Struct): { [string]: any }
local serialized = {}
for key, value in struct.fields do
assert(value ~= nil, "Luau")
serialized[key] = messages.Value.jsonEncode(value)
end
return serialized
end
function _StructImpl.jsonDecode(input: { [string]: any }): Struct
local fields... | 117 |
Kampfkarren/protoc-gen-luau | Kampfkarren-protoc-gen-luau-398d559/src/luau/wkt_mixins/Timestamp.luau | luau | .luau | local function serializeFractionalNanos(nanos: number): string
if nanos % 1e6 == 0 then
return string.format(".%03d", nanos)
elseif nanos % 1e3 == 0 then
return string.format(".%06d", nanos)
else
return string.format(".%09d", nanos)
end
end
local function deserializeFractionalNanos(nanosText: string): number... | 685 |
Kampfkarren/protoc-gen-luau | Kampfkarren-protoc-gen-luau-398d559/src/luau/wkt_mixins/Value.luau | luau | .luau | function _ValueImpl.jsonEncode(input: Value): any
local kind = input.kind
if kind == nil or kind.type == "null_value" then
return nil
elseif kind.type == "number_value" or kind.type == "string_value" or kind.type == "bool_value" then
return kind.value
elseif kind.type == "list_value" then
return messages.Lis... | 412 |
Kampfkarren/protoc-gen-luau | Kampfkarren-protoc-gen-luau-398d559/src/tests/basic.luau | luau | .luau | --!strict
local tests = require("./tests")
local deeper_include_me2 = require("./samples/deeper/include_me2")
local forwards_compatibility = require("./samples/forwards_compatibility")
local include_me = require("./samples/include_me")
local kitchen_sink = require("./samples/kitchen_sink")
local recursive = require(".... | 1,429 |
Kampfkarren/protoc-gen-luau | Kampfkarren-protoc-gen-luau-398d559/src/tests/descriptors_require.luau | luau | .luau | require("./samples/descriptors")
| 7 |
Kampfkarren/protoc-gen-luau | Kampfkarren-protoc-gen-luau-398d559/src/tests/field_case.luau | luau | .luau | --!strict
-- Validates that generated protos preserve field names as-is when no field_name_case option is passed.
local tests = require("./tests")
local field_case_test = require("./samples/field_case_test")
local assertEquals = tests.assertEquals
local describe = tests.describe
local it = tests.it
describe("field_nam... | 276 |
Kampfkarren/protoc-gen-luau | Kampfkarren-protoc-gen-luau-398d559/src/tests/field_case_camel.luau | luau | .luau | --!strict
-- Validates that generated protos use camelCase field names (field_name_case=camel).
local tests = require("./tests")
local field_case_test = require("./samples/field_case_test_camel/field_case_test")
local assertEquals = tests.assertEquals
local describe = tests.describe
local it = tests.it
describe("field... | 266 |
Kampfkarren/protoc-gen-luau | Kampfkarren-protoc-gen-luau-398d559/src/tests/field_case_snake.luau | luau | .luau | --!strict
-- Validates that generated protos use normalized snake_case (field_name_case=snake).
local tests = require("./tests")
local field_case_test = require("./samples/field_case_test_snake/field_case_test")
local assertEquals = tests.assertEquals
local describe = tests.describe
local it = tests.it
describe("field... | 272 |
Kampfkarren/protoc-gen-luau | Kampfkarren-protoc-gen-luau-398d559/src/tests/invalid_utf8.luau | luau | .luau | --!strict
--# selene: allow(bad_string_escape)
local tests = require("./tests")
local kitchen_sink = require("./samples/kitchen_sink")
local assertEquals = tests.assertEquals
local describe = tests.describe
local it = tests.it
local UNICODE_REPLACEMENT_CHARACTER = "\xEF\xBF\xBD"
-- Helper to build a raw protobuf bin... | 2,287 |
Kampfkarren/protoc-gen-luau | Kampfkarren-protoc-gen-luau-398d559/src/tests/many_messages.luau | luau | .luau | require("./samples/many_messages")
| 7 |
Kampfkarren/protoc-gen-luau | Kampfkarren-protoc-gen-luau-398d559/src/tests/tests.luau | luau | .luau | -- Jest does not yet work in Lune.
-- Replace this when it can.
local tests = {}
local anyFailed = false
local indentCount = 0
local function indent()
return string.rep("\t", indentCount)
end
function tests.describe(category: string, callback: () -> ())
print(`{indent()}{category}`)
indentCount += 1
callback()
... | 542 |
Kampfkarren/protoc-gen-luau | Kampfkarren-protoc-gen-luau-398d559/src/tests/wkt_json.luau | luau | .luau | local tests = require("./tests")
local proto = require("./samples/proto")
local any = require("./samples/google/protobuf/any")
local api = require("./samples/google/protobuf/api")
local duration = require("./samples/google/protobuf/duration")
local field_mask = require("./samples/google/protobuf/field_mask")
local st... | 3,349 |
hardlyardi/b226 | hardlyardi-b226-aeef4f0/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-aeef4f0/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-aeef4f0/tests/runtest/utils/colorful.luau | luau | .luau | --[[
Copyright 2024 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... | 807 |
hardlyardi/b226 | hardlyardi-b226-aeef4f0/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-aeef4f0/tests/utils/ecs.luau | luau | .luau | local b2 = require("@b2/")
return b2.ecs(true :: true, true :: true)
| 23 |
hardlyardi/b226 | hardlyardi-b226-aeef4f0/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-aeef4f0/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 |
checkraisefold/warmluau | checkraisefold-warmluau-8299341/cli/command.luau | luau | .luau | -- warmluau
-- darklua but warm and luau
-- by checkraisefold
local PROJECT_FILE_EXTENSION = "warm.luau"
local PROJECT_FILE_MATCH = "^(.*)%.warm%.luau?$"
local cli = require("@batteries/cli")
local defs = require("@warmluau/")
local filesystem = require("@lute/fs")
local fspath = require("@util/fspath")
local luau = r... | 1,261 |
checkraisefold/warmluau | checkraisefold-warmluau-8299341/cli/options.luau | luau | .luau | local cli = require("@batteries/cli")
local function add_options(parser: cli.Parser)
parser:add("help", "flag", {
help = "get help",
aliases = { "h" },
})
parser:add("version", "flag", {
help = "get the version",
aliases = { "v" },
})
parser:add("bake", "flag", {
help = "base mode (bake)",
aliases = {... | 266 |
checkraisefold/warmluau | checkraisefold-warmluau-8299341/defs/ingredients/append_comment.luau | luau | .luau | local warmluau = require("@warmluau/")
export type Mode = "early" | "late"
export type Opts = {
text: string,
mode: Mode?,
}
return {} :: warmluau.Ingredient<Opts>
| 53 |
checkraisefold/warmluau | checkraisefold-warmluau-8299341/defs/ingredients/resolve_constant.luau | luau | .luau | local analyzer = require("@util/syntax/analyzer")
local warmluau = require("@warmluau/")
export type ImportValue =
| string --
| number
| boolean
| vector
export type ImportChain = {
value: ImportValue | {
literal: analyzer.ConstantData,
}?,
index: {
[string]: ImportValue | ImportChain,
}?,
_const: analy... | 127 |
checkraisefold/warmluau | checkraisefold-warmluau-8299341/defs/ingredients/resolve_control.luau | luau | .luau | local warmluau = require("@warmluau/")
export type Opts = {
functions: boolean?,
variables: boolean?,
branches: boolean?,
loops: boolean?,
}
return {} :: warmluau.Ingredient<Opts>
| 55 |
checkraisefold/warmluau | checkraisefold-warmluau-8299341/defs/ingredients/resolve_require.luau | luau | .luau | local warmluau = require("@warmluau/")
export type IndexingStyle = "waitforchild" | "property"
export type Opts = {
sourcemap_path: string,
indexing: IndexingStyle?,
}
return {} :: warmluau.Ingredient<Opts>
| 64 |
checkraisefold/warmluau | checkraisefold-warmluau-8299341/defs/init.luau | luau | .luau | local filesystem = require("@lute/fs")
local parser = require("@util/syntax/parser")
export type Ast = parser.Ast
export type AstExpr = parser.AstExpr
export type Parsley = parser.Parsley
export type LoadedProject = (require: <Path>(target: Path, ...never) -> unknown) -> ...unknown
export type File = {
read parsed:... | 467 |
checkraisefold/warmluau | checkraisefold-warmluau-8299341/defs/syntax/analyzer.luau | luau | .luau | local analyzer = require("@util/syntax/analyzer")
export type UnaryOperator = analyzer.UnaryOperator
export type BinaryOperator = analyzer.BinaryOperator
export type UnknownConstant = analyzer.UnknownConstant
export type NilConstant = analyzer.NilConstant
export type BooleanConstant = analyzer.BooleanConstant
export t... | 151 |
checkraisefold/warmluau | checkraisefold-warmluau-8299341/defs/syntax/parser.luau | luau | .luau | local parser = require("@util/syntax/parser")
export type Ast = parser.Ast
export type AstExpr = parser.AstExpr
export type Parsley = parser.Parsley
return {} :: typeof(parser)
| 44 |
checkraisefold/warmluau | checkraisefold-warmluau-8299341/defs/syntax/printer.luau | luau | .luau | local printer = require("@util/syntax/printer")
return {} :: typeof(printer)
| 18 |
checkraisefold/warmluau | checkraisefold-warmluau-8299341/defs/syntax/visitors.luau | luau | .luau | local visitors = require("@util/syntax/visitors")
export type Base<State = unknown> = visitors.Base<State>
export type AddType = visitors.AddType
export type AddScope = visitors.AddScope
export type Create<State = unknown> = visitors.Create<State>
return {} :: typeof(visitors)
| 61 |
checkraisefold/warmluau | checkraisefold-warmluau-8299341/ext/batteries/cli.luau | luau | .luau | local cli = {}
cli.__index = cli
type ArgKind = "positional" | "flag" | "option"
type ArgOptions = {
help: string?,
aliases: { string }?,
default: string?,
required: boolean?,
}
type ArgData = {
name: string,
kind: ArgKind,
options: ArgOptions,
}
type ParseResult = {
values: { [string]: string },
flags: { [... | 1,137 |
checkraisefold/warmluau | checkraisefold-warmluau-8299341/ext/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,213 |
checkraisefold/warmluau | checkraisefold-warmluau-8299341/src/ingredients/append_comment/init.luau | luau | .luau | local append_comment = require("@warmluau/ingredients/append_comment")
local luau = require("@lute/luau")
local visitors = require("@util/syntax/visitors")
local warmluau = require("@warmluau/")
type Opts = append_comment.Opts
type Mode = append_comment.Mode
-- Luau
local function INSERT<Item>(tbl: { Item }, value: I... | 415 |
checkraisefold/warmluau | checkraisefold-warmluau-8299341/src/ingredients/resolve_constant/replacer.luau | luau | .luau | local luau = require("@lute/luau")
local visitors = require("@util/syntax/visitors")
export type Processor = (luau.AstExpr) -> luau.AstExpr?
type VisitorState = Processor
local function EXHAUSTIVE_MATCH<Msg>(value: never, msg: Msg?): never
error(msg or `Unknown value in exhaustive match: {value}`)
end
local value_v... | 1,607 |
checkraisefold/warmluau | checkraisefold-warmluau-8299341/src/ingredients/resolve_require/init.luau | luau | .luau | local REQUIRE_GLOBAL = "require"
local DEFAULT_INDEXING_STYLE: IndexingStyle = "property"
local convert_require = require("@warmluau/ingredients/resolve_require")
local defs = require("@warmluau/")
local filesystem = require("@lute/fs")
local fspath = require("@util/fspath")
local json = require("@batteries/json")
loc... | 1,276 |
checkraisefold/warmluau | checkraisefold-warmluau-8299341/src/meta.luau | luau | .luau | return {
version = "pre-v0.1.0",
default_project_name = "default.warm.luau",
}
| 25 |
checkraisefold/warmluau | checkraisefold-warmluau-8299341/src/oven/init.luau | luau | .luau | local FAILED_OUTPUT_FILE = "return error('warmluau could not generate an output for this file');"
local defs = require("@warmluau/")
local filesystem = require("@lute/fs")
local fspath = require("@util/fspath")
local luau = require("@lute/luau")
local styled = require("@util/pretty_print")
type Process = index<defs.P... | 1,584 |
checkraisefold/warmluau | checkraisefold-warmluau-8299341/src/oven/recipe.luau | luau | .luau | local defs = require("@warmluau/")
local function recipe_create(...: defs.Recipe | defs.PreparedIngredient): defs.Recipe
local steps: { defs.Recipe | defs.PreparedIngredient } = { ... }
local steps_count = #steps
local function recipe_add(adding: { defs.Recipe | defs.PreparedIngredient }): ()
local adding_count ... | 136 |
checkraisefold/warmluau | checkraisefold-warmluau-8299341/src/require_vfs.luau | luau | .luau | local IMPL: any = nil
local defs = require("@warmluau/")
local requirer = require("@util/requirer")
local dst = requirer.override
local function dir<Children>(children: Children): Children
local children = children :: { [string]: unknown }
for index, value in children do
children[index] = dst(index, value)
end
... | 231 |
checkraisefold/warmluau | checkraisefold-warmluau-8299341/src/util/fspath/init.luau | luau | .luau | local system = require("@lute/system")
local types = require("@self/types")
export type Nav = types.Nav
export type ValidPath = types.ValidPath
return (if system.os:lower():match("windows") then require("@self/windows") else require("@self/unix")) :: types.Api
| 62 |
checkraisefold/warmluau | checkraisefold-warmluau-8299341/src/util/fspath/types.luau | luau | .luau | export type Nav = { string }
export type ValidPath = Nav | string
export type Api = {
to_nav: (path: ValidPath) -> Nav,
from_str: (path: string) -> Nav,
clone_nav: (path: ValidPath) -> Nav,
to_str: (path: ValidPath) -> string,
from_nav: (path: Nav) -> string,
has_root: (path: ValidPath) -> boolean,
absolute_eh:... | 271 |
checkraisefold/warmluau | checkraisefold-warmluau-8299341/src/util/fspath/unix.luau | luau | .luau | local NAVIGATE_BACK = ".."
local NAVIGATE_HERE = "."
local SEPARATOR_MATCH = "/+"
local SEPARATOR = "/"
local types = require("./types")
type ValidPath = types.ValidPath
type Nav = types.Nav
type Api = types.Api
local function to_nav(path: ValidPath): Nav
if type(path) == "table" then
return path
end
return (st... | 1,487 |
checkraisefold/warmluau | checkraisefold-warmluau-8299341/src/util/fspath/windows.luau | luau | .luau | --!optimize 2
--!native
local NAVIGATE_BACK = ".."
local NAVIGATE_HERE = "."
local SEPARATOR_MATCH = "[/\\]+"
local SEPARATOR = "/"
local types = require("./types")
type ValidPath = types.ValidPath
type Nav = types.Nav
type Api = types.Api
local function to_nav(path: ValidPath): Nav
if type(path) == "table" then
... | 1,539 |
checkraisefold/warmluau | checkraisefold-warmluau-8299341/src/util/pretty_print/init.luau | luau | .luau | local INDENT = " "
local DEFAULT_PRETTY_PRINT_DECIMALS = 4
-- scientific notation is in base 10, this is the closest power of 10 above 2^53 which is the max integer an f64 (luau
-- number) can accurately represent.
local SCIENTIFIC_NOTATION_THRESHOLD = 10 ^ 16
local colorful = require("./colorful")
local color = co... | 1,551 |
checkraisefold/warmluau | checkraisefold-warmluau-8299341/src/util/require_resolver/get_aliases.luau | luau | .luau | local filesystem = require("@lute/fs")
local fspath = require("@util/fspath")
local json = require("@batteries/json")
local process = require("@lute/process")
local resolver_types = require("./types")
local styled = require("@util/pretty_print")
type RequireAliases = resolver_types.RequireAliases
local function ASSER... | 636 |
checkraisefold/warmluau | checkraisefold-warmluau-8299341/src/util/require_resolver/init.luau | luau | .luau | local ALIAS_PATTERN = `^@(.+)`
local filesystem = require("@lute/fs")
local fspath = require("@util/fspath")
local get_aliases = require("@self/get_aliases")
local resolver_types = require("@self/types")
type RequireAliases = resolver_types.RequireAliases
local function ASSERT<Value>(value: Value, message: string?)
... | 1,001 |
checkraisefold/warmluau | checkraisefold-warmluau-8299341/src/util/require_resolver/types.luau | luau | .luau | export type RequireAliases = { [string]: string }
return nil
| 14 |
checkraisefold/warmluau | checkraisefold-warmluau-8299341/src/util/requirer/init.luau | luau | .luau | local PREPEND = [[math.randomseed(0); local require = ...;]]
local filesystem = require("@lute/fs")
local fspath = require("@util/fspath")
local luau = require("@lute/luau")
local override = require("@self/override")
local require_resolver = require("@util/require_resolver")
local styled = require("@util/pretty_print"... | 661 |
checkraisefold/warmluau | checkraisefold-warmluau-8299341/src/util/requirer/override.luau | luau | .luau | local fspath = require("@util/fspath")
local override = {}
local metatable = { __index = override }
type InternalIdentity = setmetatable<{
children: { [string]: InternalIdentity },
path: fspath.Nav,
value: unknown?,
}, typeof(metatable)>
export type Identity<Children = { [string]: InternalIdentity }> = InternalId... | 145 |
checkraisefold/warmluau | checkraisefold-warmluau-8299341/src/util/sourcemap/init.luau | luau | .luau | local pretty_print = require("@util/pretty_print")
export type Node = {
name: string,
filePaths: { string }?,
children: { Node }?,
}
local function ASSERT<Value, Message>(value: Value, message: Message?)
if value then
return value
end
error(message, 2)
end
-- save repetitive allocations
local reused_nodes_li... | 419 |
checkraisefold/warmluau | checkraisefold-warmluau-8299341/src/util/syntax/analyzer/defs.luau | luau | .luau | local luau = require("@lute/luau")
export type UnaryOperator = "not" | "-" | "#"
export type BinaryOperator =
| "^"
| "*"
| "/"
| "//"
| "%"
| "+"
| "-"
| ".."
| "<"
| ">"
| "<="
| ">="
| "~="
| "=="
| "and"
| "or"
export type UnknownConstant = {
read kind: "unknown",
read data: nil,
}
export type ... | 480 |
checkraisefold/warmluau | checkraisefold-warmluau-8299341/src/util/syntax/analyzer/init.luau | luau | .luau | local defs = require("@self/defs")
local luau = require("@lute/luau")
local var_tracking = require("@self/var_tracking")
export type UnaryOperator = defs.UnaryOperator
export type BinaryOperator = defs.BinaryOperator
export type UnknownConstant = defs.UnknownConstant
export type NilConstant = defs.NilConstant
export t... | 4,492 |
checkraisefold/warmluau | checkraisefold-warmluau-8299341/src/util/syntax/analyzer/var_tracking.luau | luau | .luau | local defs = require("./defs")
local luau = require("@lute/luau")
local visitors = require("@util/syntax/visitors")
type Variable = defs.Variable
type Tracked = defs.Tracked
type Scope = { [string]: Variable? }
type VisitorState = {
tracked: Tracked,
scopes: { Scope },
}
-- Luau
local function INSERT<Item>(tbl: {... | 947 |
checkraisefold/warmluau | checkraisefold-warmluau-8299341/src/util/syntax/parser.luau | luau | .luau | --!strict
local luau = require("@lute/luau")
export type Ast = luau.AstStatBlock
export type AstExpr = luau.AstExpr
export type Parsley = {
root: Ast,
eof: luau.Eof,
}
local function parse(source: string): Ast
return luau.parse(source).root
end
local function parseexpr(source: string): AstExpr
return luau.parsee... | 148 |
checkraisefold/warmluau | checkraisefold-warmluau-8299341/src/util/syntax/tokentool.luau | luau | .luau | local luau = require("@lute/luau")
local visitors = require("@util/syntax/visitors")
local first_last_visitor = visitors.create() :: visitors.Create<{
first: luau.Token,
last: luau.Token,
}?>
function first_last_visitor.vtoken(node): ()
local state = first_last_visitor.state
if state then
state.last = node
els... | 585 |
checkraisefold/warmluau | checkraisefold-warmluau-8299341/src/util/syntax/triviatool.luau | luau | .luau | local luau = require("@lute/luau")
local visitors = require("@util/syntax/visitors")
type VisitorState = {
leading: { luau.Trivia },
trailing: { luau.Trivia },
}
local visitor = visitors.create() :: visitors.Create<VisitorState>
local function add_token(token: luau.Token<string>): ()
local leading = token.leadingt... | 639 |
checkraisefold/warmluau | checkraisefold-warmluau-8299341/src/util/syntax/visitors.luau | luau | .luau | local luau = require("@lute/luau")
export type Base<State = unknown> = {
state: State,
read visit_ast_block: (self: Base<State>, node: luau.AstStatBlock, state: State) -> State,
read visit_ast_statement: (self: Base<State>, node: luau.AstStat, state: State) -> State,
read visit_ast_expression: (self: Base<State>,... | 7,995 |
Roblox/luau-polyfill | Roblox-luau-polyfill-68fef52/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-68fef52/modules/boolean/src/init.lua | luau | .lua | --!strict
return {
toJSBoolean = require(script.toJSBoolean),
}
| 17 |
Roblox/luau-polyfill | Roblox-luau-polyfill-68fef52/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-68fef52/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-68fef52/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-68fef52/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-68fef52/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-68fef52/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-68fef52/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-68fef52/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-68fef52/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-68fef52/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-68fef52/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-68fef52/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-68fef52/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-68fef52/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-68fef52/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-68fef52/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-68fef52/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-68fef52/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-68fef52/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-68fef52/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-68fef52/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-68fef52/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-68fef52/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-68fef52/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-68fef52/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-68fef52/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-68fef52/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-68fef52/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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.