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/luau-polyfill
Roblox-luau-polyfill-d4798c6/modules/es7-types/src/init.lua
luau
.lua
--!strict export type Object = { [string]: any } export type Array<T> = { [number]: T } export type Function = (...any) -> ...any export type Table<T, V> = { [T]: V } export type Tuple<T, V> = Array<T | V> export type mapCallbackFn<K, V> = (element: V, key: K, map: Map<K, V>) -> () export type mapCallbackFnWithThisArg<...
831
Roblox/luau-polyfill
Roblox-luau-polyfill-d4798c6/modules/instance-of/src/init.lua
luau
.lua
local instanceof = require(script.instanceof) return instanceof
11
Roblox/luau-polyfill
Roblox-luau-polyfill-d4798c6/modules/instance-of/src/instanceof.lua
luau
.lua
--!strict -- polyfill for https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/instanceof local __DEV__ = _G.__DEV__ -- FIXME Luau: typing class as Object gives: Type '{ @metatable {| __call: <a>(a, ...any) -> Error, __tostring: <b, c>({+ message: b, name: c +}) -> string |}, Error }' could not ...
326
Roblox/luau-polyfill
Roblox-luau-polyfill-d4798c6/modules/luau-polyfill/src/AssertionError/init.lua
luau
.lua
local AssertionErrorModule = require(script["AssertionError.global"]) export type AssertionError = AssertionErrorModule.AssertionError return AssertionErrorModule.AssertionError
28
Roblox/luau-polyfill
Roblox-luau-polyfill-d4798c6/modules/luau-polyfill/src/Error/init.lua
luau
.lua
local Error = require(script["Error.global"]) export type Error = Error.Error return Error
19
Roblox/luau-polyfill
Roblox-luau-polyfill-d4798c6/modules/luau-polyfill/src/Promise.lua
luau
.lua
-- this maps onto community promise libraries which won't support Luau, so we inline export type PromiseLike<T> = { andThen: ( self: PromiseLike<T>, resolve: ((T) -> ...(nil | T | PromiseLike<T>))?, reject: ((any) -> ...(nil | T | PromiseLike<T>))? ) -> PromiseLike<T>, } type PromiseStatus = "Started" | "Resol...
313
Roblox/luau-polyfill
Roblox-luau-polyfill-d4798c6/modules/luau-polyfill/src/encodeURIComponent.lua
luau
.lua
-- reference documentation: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent local HttpService = game:GetService("HttpService") local root = script.Parent local Packages = root.Parent local String = require(Packages.String) local charCodeAt = String.charCodeAt local ...
352
Roblox/luau-polyfill
Roblox-luau-polyfill-d4798c6/modules/luau-polyfill/src/init.lua
luau
.lua
--!strict local Packages = script.Parent local Boolean = require(Packages.Boolean) local Collections = require(Packages.Collections) local Console = require(Packages.Console) local Math = require(Packages.Math) local Number = require(Packages.Number) local String = require(Packages.String) local Symbol = require(Packa...
394
Roblox/luau-polyfill
Roblox-luau-polyfill-d4798c6/modules/math/src/init.lua
luau
.lua
--!strict return { clz32 = require(script.clz32), }
17
Roblox/luau-polyfill
Roblox-luau-polyfill-d4798c6/modules/number/src/MAX_SAFE_INTEGER.lua
luau
.lua
--!strict -- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER return 9007199254740991
38
Roblox/luau-polyfill
Roblox-luau-polyfill-d4798c6/modules/number/src/MIN_SAFE_INTEGER.lua
luau
.lua
--!strict -- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MIN_SAFE_INTEGER return -9007199254740991
38
Roblox/luau-polyfill
Roblox-luau-polyfill-d4798c6/modules/number/src/init.lua
luau
.lua
--!strict return { isFinite = require(script.isFinite), isInteger = require(script.isInteger), isNaN = require(script.isNaN), isSafeInteger = require(script.isSafeInteger), MAX_SAFE_INTEGER = require(script.MAX_SAFE_INTEGER), MIN_SAFE_INTEGER = require(script.MIN_SAFE_INTEGER), NaN = 0 / 0, toExponential = requ...
82
Roblox/luau-polyfill
Roblox-luau-polyfill-d4798c6/modules/number/src/isFinite.lua
luau
.lua
--!strict return function(value) return typeof(value) == "number" and value == value and value ~= math.huge and value ~= -math.huge end
36
Roblox/luau-polyfill
Roblox-luau-polyfill-d4798c6/modules/number/src/isInteger.lua
luau
.lua
--!strict -- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger return function(value) return type(value) == "number" and value ~= math.huge and value == math.floor(value) end
54
Roblox/luau-polyfill
Roblox-luau-polyfill-d4798c6/modules/number/src/isNaN.lua
luau
.lua
--!strict -- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isNaN return function(value) return type(value) == "number" and value ~= value end
46
Roblox/luau-polyfill
Roblox-luau-polyfill-d4798c6/modules/number/src/isSafeInteger.lua
luau
.lua
--!strict -- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger local isInteger = require(script.Parent.isInteger) local MAX_SAFE_INTEGER = require(script.Parent.MAX_SAFE_INTEGER) return function(value) return isInteger(value) and math.abs(value) <= MAX_SAFE_INTEGER ...
71
Roblox/luau-polyfill
Roblox-luau-polyfill-d4798c6/modules/number/src/toExponential.lua
luau
.lua
--!strict -- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toExponential return function(value: string | number, fractionDigits: number?): string | nil local num = value if typeof(value) == "string" then -- ROBLOX FIXME: add parseInt to encapsulate this logic and use it her...
298
Roblox/luau-polyfill
Roblox-luau-polyfill-d4798c6/modules/string/src/charCodeAt.lua
luau
.lua
--!strict local String = script.Parent local Packages = String.Parent local Number = require(Packages.Number) local NaN = Number.NaN -- js https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charCodeAt -- lua http://www.lua.org/manual/5.4/manual.html#pdf-utf8.codepoint return func...
267
Roblox/luau-polyfill
Roblox-luau-polyfill-d4798c6/modules/string/src/endsWith.lua
luau
.lua
--!strict local function endsWith(value: string, substring: string, optionalLength: number?): boolean local substringLength = substring:len() if substringLength == 0 then return true end local valueLength = value:len() local length = optionalLength or valueLength if length > valueLength then length = valueLen...
119
Roblox/luau-polyfill
Roblox-luau-polyfill-d4798c6/modules/string/src/findOr.lua
luau
.lua
--!strict type Match = { index: number, match: string, } -- excluding the `+` and `*` character, since findOr tests and graphql use them explicitly local luaPatternCharacters = "([" .. ("$%^()-[].?"):gsub("(.)", "%%%1") .. "])" local function findOr(str: string, patternTable: { string }, initIndex: number?): Match ...
423
Roblox/luau-polyfill
Roblox-luau-polyfill-d4798c6/modules/string/src/includes.lua
luau
.lua
--!strict -- excluding the `+` and `*` character, since findOr tests and graphql use them explicitly local luaPatternCharacters = "([" .. ("$%^()-[].?"):gsub("(.)", "%%%1") .. "])" local function includes(str: string, substring: string, position: (string | number)?): boolean local strLen, invalidBytePosition = utf8....
249
Roblox/luau-polyfill
Roblox-luau-polyfill-d4798c6/modules/string/src/indexOf.lua
luau
.lua
--!strict -- excluding the `+` and `*` character, since findOr tests and graphql use them explicitly local luaPatternCharacters = "([" .. ("$%^()-[].?"):gsub("(.)", "%%%1") .. "])" -- Implements equivalent functionality to JavaScript's `String.indexOf`, -- implementing the interface and behaviors defined at: -- https...
258
Roblox/luau-polyfill
Roblox-luau-polyfill-d4798c6/modules/string/src/init.lua
luau
.lua
return { charCodeAt = require(script.charCodeAt), endsWith = require(script.endsWith), findOr = require(script.findOr), includes = require(script.includes), indexOf = require(script.indexOf), lastIndexOf = require(script.lastIndexOf), slice = require(script.slice), split = require(script.split), startsWith = r...
127
Roblox/luau-polyfill
Roblox-luau-polyfill-d4798c6/modules/string/src/lastIndexOf.lua
luau
.lua
--!strict local function lastIndexOf(str: string, searchValue: string, fromIndex: number?): number local strLength = string.len(str) local calculatedFromIndex if fromIndex then calculatedFromIndex = fromIndex else calculatedFromIndex = strLength end if fromIndex and fromIndex < 1 then calculatedFromIndex = ...
317
Roblox/luau-polyfill
Roblox-luau-polyfill-d4798c6/modules/string/src/slice.lua
luau
.lua
--!strict local function slice(str: string, startIndexStr: string | number, lastIndexStr: (string | number)?): string local strLen, invalidBytePosition = utf8.len(str) assert(strLen ~= nil, ("string `%s` has an invalid byte at position %s"):format(str, tostring(invalidBytePosition))) local startIndex = tonumber(star...
322
Roblox/luau-polyfill
Roblox-luau-polyfill-d4798c6/modules/string/src/split.lua
luau
.lua
--!strict local String = script.Parent local findOr = require(String.findOr) local slice = require(String.slice) local Packages = String.Parent local types = require(Packages.ES7Types) type Array<T> = types.Array<T> local MAX_SAFE_INTEGER = require(Packages.Number).MAX_SAFE_INTEGER type Pattern = string | Array<strin...
527
Roblox/luau-polyfill
Roblox-luau-polyfill-d4798c6/modules/string/src/startsWith.lua
luau
.lua
--!strict local function startsWith(value: string, substring: string, position: number?): boolean if string.len(substring) == 0 then return true end -- Luau FIXME: we have to use a tmp variable, as Luau doesn't understand the logic below narrow position to `number` local position_ if position == nil or position ...
135
Roblox/luau-polyfill
Roblox-luau-polyfill-d4798c6/modules/string/src/substr.lua
luau
.lua
--!strict return function(s: string, startIndex: number, numberOfCharacters: number?): string if numberOfCharacters and numberOfCharacters <= 0 then return "" end return string.sub(s, startIndex, numberOfCharacters and startIndex + numberOfCharacters - 1 or nil) end
59
Roblox/luau-polyfill
Roblox-luau-polyfill-d4798c6/modules/string/src/trim.lua
luau
.lua
--!strict local trimStart = require(script.Parent.trimStart) local trimEnd = require(script.Parent.trimEnd) return function(source: string): string return trimStart(trimEnd(source)) end
41
Roblox/luau-polyfill
Roblox-luau-polyfill-d4798c6/modules/string/src/trimEnd.lua
luau
.lua
--!strict return function(source: string): string return (source:gsub("[%s]+$", "")) end
24
Roblox/luau-polyfill
Roblox-luau-polyfill-d4798c6/modules/string/src/trimStart.lua
luau
.lua
--!strict return function(source: string): string return (source:gsub("^[%s]+", "")) end
25
Roblox/luau-polyfill
Roblox-luau-polyfill-d4798c6/modules/timers/src/init.lua
luau
.lua
--!strict local Packages = script.Parent local Object = require(Packages.Collections).Object local makeTimerImpl = require(script.makeTimerImpl) local makeIntervalImpl = require(script.makeIntervalImpl) export type Timeout = makeTimerImpl.Timeout export type Interval = makeIntervalImpl.Interval return Object.assign...
76
Kampfkarren/protoc-gen-luau
Kampfkarren-protoc-gen-luau-ff2d49c/conformance/generated/google/protobuf/any.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 = { Any: _AnyMessag...
1,761
Kampfkarren/protoc-gen-luau
Kampfkarren-protoc-gen-luau-ff2d49c/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-ff2d49c/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-ff2d49c/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-ff2d49c/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-ff2d49c/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-ff2d49c/conformance/generated/proto/init.luau
luau
.luau
local base64 = require("@self/base64") local message = require("@self/message") local typeRegistry = require("@self/typeRegistry") export type Descriptor = message.Descriptor export type Message<T, Fields> = message.Message<T, Fields> export type CustomJson<T, Json> = message.CustomJson<T, Json> export type TypeRegist...
3,465
Kampfkarren/protoc-gen-luau
Kampfkarren-protoc-gen-luau-ff2d49c/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-ff2d49c/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-ff2d49c/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-ff2d49c/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-ff2d49c/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-ff2d49c/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-ff2d49c/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-ff2d49c/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-ff2d49c/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-ff2d49c/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-ff2d49c/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-ff2d49c/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,487
Kampfkarren/protoc-gen-luau
Kampfkarren-protoc-gen-luau-ff2d49c/src/tests/descriptors_require.luau
luau
.luau
require("./samples/descriptors")
7
Kampfkarren/protoc-gen-luau
Kampfkarren-protoc-gen-luau-ff2d49c/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-ff2d49c/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-ff2d49c/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-ff2d49c/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,284
Kampfkarren/protoc-gen-luau
Kampfkarren-protoc-gen-luau-ff2d49c/src/tests/many_messages.luau
luau
.luau
require("./samples/many_messages")
7
Kampfkarren/protoc-gen-luau
Kampfkarren-protoc-gen-luau-ff2d49c/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-ff2d49c/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
Nicell/htmluau
Nicell-htmluau-45b25ed/examples/cards.luau
luau
.luau
local net = require("@lute/net/server") local htmluau = require("../src") local html = htmluau.html local div = htmluau.div local head = htmluau.head local title = htmluau.title local body = htmluau.body local img = htmluau.img local h2 = htmluau.h2 local p = htmluau.p local createComponent = htmluau.createComponent...
349
Nicell/htmluau
Nicell-htmluau-45b25ed/examples/flatten.luau
luau
.luau
local htmluau = require("../src") local html = htmluau.html local body = htmluau.body local article = htmluau.article local div = htmluau.div local p = htmluau.p local map = htmluau.map local cards = { article() { "First", }, article() { "Second", }, } local sites = { home = "https://luau.page", docs = "ht...
184
Nicell/htmluau
Nicell-htmluau-45b25ed/examples/html.luau
luau
.luau
local net = require("@lute/net/server") local htmluau = require("../src") local html = htmluau.html local head = htmluau.head local title = htmluau.title local body = htmluau.body local h1 = htmluau.h1 local button = htmluau.button local p = htmluau.p local website = html({ lang = "en" }) { head() { title() { ...
211
Nicell/htmluau
Nicell-htmluau-45b25ed/loom.config.luau
luau
.luau
return { package = { name = "htmluau", version = "0.1.0", }, }
27
Nicell/htmluau
Nicell-htmluau-45b25ed/src/init.luau
luau
.luau
export type Element = () -> string -- Elements are what Components return export type Node = string | Element -- Nodes are what user defined functions return export type ElementList = { Element } export type Child = string | Element | ChildElement | ElementList export type ChildElement = <T>(children: { T }?) -> Elemen...
1,663
Nicell/htmluau
Nicell-htmluau-45b25ed/tests/init.test.luau
luau
.luau
local test = require("@std/test") local htmluau = require("../src") test.suite("HTMLuau", function(suite) suite:case("renders nested elements and joins sibling children with newlines", function(assert) local document = htmluau.div({ id = "root" }) { htmluau.h1() { "Hello", }, htmluau.p() { "First ...
645
0x5eal/semver-luau
0x5eal-semver-luau-3f77d74/.lune/exec.luau
luau
.luau
--> lib: Builder pattern class to spawn child processes local stdio = require("@lune/stdio") local process = require("@lune/process") local Option = require("../luau_packages/option") type Option<T> = Option.Option<T> local CommandBuilder = {} export type CommandBuilder = typeof(setmetatable({} :: Command...
736
0x5eal/semver-luau
0x5eal-semver-luau-3f77d74/.lune/fmt.luau
luau
.luau
--> Run stylua to check for formatting errors local process = require("@lune/process") local CommandBuilder = require("./exec") process.exit(CommandBuilder.new("stylua"):withArg("."):withArgs(process.args):withStdioStrategy("forward"):exec().code)
56
0x5eal/semver-luau
0x5eal-semver-luau-3f77d74/.lune/test.luau
luau
.luau
--> Run tests using frktest runner local fs = require("@lune/fs") local process = require("@lune/process") local frktest = require("@pkg/frktest") local reporter = require("../tests/_reporter") -- HACK: Cast require to allow for dynamic paths in strict mode -- A more proper solution would be to use luau.load instead...
455
0x5eal/semver-luau
0x5eal-semver-luau-3f77d74/.lune/typecheck.luau
luau
.luau
--> Run luau-lsp analysis to check for type errors local process = require("@lune/process") local CommandBuilder = require("./exec") process.exit( CommandBuilder.new("luau-lsp") :withArg("analyze") :withArgs({ "--settings", ".vscode/settings.json" }) :withArgs({ "--ignore", "'**/.pesde/**'" }) :w...
108
0x5eal/semver-luau
0x5eal-semver-luau-3f77d74/lib/init.luau
luau
.luau
local Option = require("../luau_packages/option") type Option<T> = Option.Option<T> local Result = require("../luau_packages/result") type Result<T, E> = Result.Result<T, E> local function stringStartsWith(str: string, sub: string) return string.sub(str, 1, #sub) == sub end local function hasLeadingZeros(num: strin...
3,623
0x5eal/semver-luau
0x5eal-semver-luau-3f77d74/tests/cmp.luau
luau
.luau
local frktest = require("@pkg/frktest") local check = frktest.assert.check local Option = require("../luau_packages/option") type Option<T> = Option.Option<T> local Semver = require("../lib") return function(test: typeof(frktest.test)) test.suite("Semver comparison tests", function() test.case("Basic version comp...
1,114
0x5eal/semver-luau
0x5eal-semver-luau-3f77d74/tests/parse_invalid.luau
luau
.luau
local frktest = require("@pkg/frktest") local check = frktest.assert.check local Semver = require("../lib") return function(test: typeof(frktest.test)) test.suite("Invalid semver parsing tests", function() test.case("Rejects missing components", function() local res = Semver.parse("1.2") check.is_true(res:is...
1,007
0x5eal/semver-luau
0x5eal-semver-luau-3f77d74/tests/parse_valid.luau
luau
.luau
local frktest = require("@pkg/frktest") local check = frktest.assert.check local Option = require("../luau_packages/option") type Option<T> = Option.Option<T> local Semver = require("../lib") return function(test: typeof(frktest.test)) test.suite("Basic tests", function() test.case("Semver creates valid version o...
491
0x5eal/semver-luau
0x5eal-semver-luau-3f77d74/tests/tostring.luau
luau
.luau
local frktest = require("@pkg/frktest") local check = frktest.assert.check local Option = require("../luau_packages/option") type Option<T> = Option.Option<T> local Semver = require("../lib") return function(test: typeof(frktest.test)) test.suite("Stringification tests", function() test.case("A version constructe...
721
0x5eal/luau-unzip
0x5eal-luau-unzip-5ed3cf9/.lune/docsgen/init.luau
luau
.luau
--> Generate markdown documentation from moonwave comments local process = require("@lune/process") local serde = require("@lune/serde") local moonwave = require("@self/moonwave") local logger = require("@self/log") local writeMarkdown = require("@self/markdown") local function extract(input: string): (number, { moo...
226
0x5eal/luau-unzip
0x5eal-luau-unzip-5ed3cf9/.lune/docsgen/log.luau
luau
.luau
local stdio = require("@lune/stdio") local base = stdio.style("bold") local STYLE_INFO = base .. `{stdio.color("green")}info{stdio.color("reset")}:` local STYLE_WARN = base .. `{stdio.color("yellow")}warn{stdio.color("reset")}:` local STYLE_ERROR = base .. `{stdio.color("red")}error{stdio.color("reset")}:` export ty...
207
0x5eal/luau-unzip
0x5eal-luau-unzip-5ed3cf9/.lune/docsgen/markdown.luau
luau
.luau
local fs = require("@lune/fs") local moonwave = require("./moonwave") local logger = require("./log") local function writeSectionHeader(buf: string, title: string) buf ..= `### {title}\n` return buf end local function writeRef(buf: string, name: string, fragment: string?) buf ..= `\n[{name}]: #{fragment or name}\...
1,305
0x5eal/luau-unzip
0x5eal-luau-unzip-5ed3cf9/.lune/fmt.luau
luau
.luau
--> Run stylua to check for formatting errors local process = require("@lune/process") local CommandBuilder = require("./util/exec") process.exit(CommandBuilder.new("stylua"):withArgs(process.args):withArg("."):withStdioStrategy("forward"):exec().code)
57
0x5eal/luau-unzip
0x5eal-luau-unzip-5ed3cf9/.lune/tests/init.luau
luau
.luau
--> Run tests using frktest runner local fs = require("@lune/fs") local process = require("@lune/process") local frktest = require("../luau_packages/frktest") local reporter = require("@self/reporter") -- HACK: Cast require to allow for dynamic paths in strict mode -- A more proper solution would be to use luau.load...
626
0x5eal/luau-unzip
0x5eal-luau-unzip-5ed3cf9/.lune/typecheck.luau
luau
.luau
--> Run luau-lsp analysis to check for type errors local process = require("@lune/process") local CommandBuilder = require("./util/exec") process.exit( CommandBuilder.new("luau-lsp") :withArg("analyze") :withArgs({ "--settings", ".vscode/settings.json" }) :withArgs({ "--ignore", "'**/*_packages/**/*'" }) :w...
110
0x5eal/luau-unzip
0x5eal-luau-unzip-5ed3cf9/.lune/util/channel.luau
luau
.luau
--> util: An MPSC synchronization primitive powered by Lua upvalues which retains only --> one value at a time. --- ## Usage --- ```luau --- local send, recv = watch((nil :: any) :: string) --- task.delay(5, send, "hello, world!") --- task.spawn(function() --- local value = recv() --- print("received value:", ...
266
0x5eal/luau-unzip
0x5eal-luau-unzip-5ed3cf9/.lune/util/exec.luau
luau
.luau
--> lib: Builder pattern class to spawn child processes local process = require("@lune/process") local stdio = require("@lune/stdio") local CommandBuilder = {} export type CommandBuilder = typeof(setmetatable({} :: CommandBuilderFields, { __index = CommandBuilder })) type CommandBuilderFields = { program: string, ...
640
0x5eal/luau-unzip
0x5eal-luau-unzip-5ed3cf9/.lune/util/reader_utils.luau
luau
.luau
local process = require("@lune/process") local exports = {} export type ChildProcessReader = typeof(({} :: process.ChildProcess).stdout) local CHUNK_SIZE = 8 * 1024 -- 8 KB --- Luau implementation of `ChildReader:readToEnd`. --- --- This is a workaround for a lune bug which causes child processes to --- never exit. ...
476
0x5eal/luau-unzip
0x5eal-luau-unzip-5ed3cf9/examples/tour.luau
luau
.luau
local fs = require("@lune/fs") local zip = require("../lib") local asciitable = require("../luau_packages/asciitable") local file = fs.readFile("tests/data/files_and_dirs.zip") local reader = zip.load(buffer.fromstring(file)) --- Transforms a tree of recursive `{ [string]: EntryData }` to a recursive tree of --- `{ [...
738
0x5eal/luau-unzip
0x5eal-luau-unzip-5ed3cf9/lib/crc.luau
luau
.luau
local CRC32_TABLE: { number } = table.create(256) -- TODO: Maybe compute this AoT as an optimization -- Initialize the lookup table and lock it in place for i = 0, 255 do local crc = i for _ = 1, 8 do if bit32.band(crc, 1) == 1 then crc = bit32.bxor(bit32.rshift(crc, 1), 0xEDB88320) else crc = bit32.rshift...
738
0x5eal/luau-unzip
0x5eal-luau-unzip-5ed3cf9/lib/inflate.luau
luau
.luau
-- Tree class for storing Huffman trees used in DEFLATE decompression local Tree = {} export type Tree = typeof(setmetatable({} :: TreeInner, { __index = Tree })) type TreeInner = { table: { number }, -- Length of 16, stores code length counts trans: { number }, -- Length of 288, stores code to symbol translations ...
5,317
0x5eal/luau-unzip
0x5eal-luau-unzip-5ed3cf9/lib/utils/path.luau
luau
.luau
--- Canonicalize a path by removing redundant components local function canonicalize(path: string): string -- We convert any `\\` separators to `/` separators to ensure consistency local components = string.split(path:gsub("\\", "/"), "/") local result = {} for _, component in components do if component == "." th...
826
0x5eal/luau-unzip
0x5eal-luau-unzip-5ed3cf9/scripts/generate_inflate_testdata.luau
luau
.luau
local fs = require("@lune/fs") local zlib = require("./util/zlib") local toHex = require("./util/hex") local testCases = require("../tests/data/inflate/cases") local TEST_DATA_DIR = "tests/data/inflate" print("Generating inflate test files to", TEST_DATA_DIR) fs.writeDir(TEST_DATA_DIR) for _, case in testCases do l...
176
0x5eal/luau-unzip
0x5eal-luau-unzip-5ed3cf9/scripts/generate_invalid_version_zip.luau
luau
.luau
local fs = require("@lune/fs") local stdio = require("@lune/stdio") local process = require("@lune/process") -- stylua: ignore local function createZip(version: number): buffer version = version or math.random(63, 100) print("Using version:", version) local data = buffer.create(98) local pos = ...
1,136
0x5eal/luau-unzip
0x5eal-luau-unzip-5ed3cf9/scripts/util/adler32.luau
luau
.luau
local MOD_ADLER = 65521 local function adler32(buf: buffer): number local a = 1 local b = 0 for i = 0, buffer.len(buf) - 1 do local byte = buffer.readu8(buf, i) a = (a + byte) % MOD_ADLER b = (b + a) % MOD_ADLER end return bit32.lshift(b, 16) + a end return adler32
110
0x5eal/luau-unzip
0x5eal-luau-unzip-5ed3cf9/scripts/util/hex.luau
luau
.luau
local function toHex(data: string, maxBytes: number) local bytes = {} for i = 1, math.min(#data, maxBytes) do bytes[i] = string.format("%02X", data:byte(i)) end local hex = table.concat(bytes, " ") if #data > maxBytes then hex = hex .. string.format(" ... (%d bytes total)", #data) end return hex end retur...
97
0x5eal/luau-unzip
0x5eal-luau-unzip-5ed3cf9/scripts/util/zlib.luau
luau
.luau
local serde = require("@lune/serde") local adler32 = require("./adler32") export type Level = "Low" | "Fast" | "Default" | "Best" export type Compressed = { raw: buffer, level: Level, } local ZLIB_MAGIC_BYTE = 0x78 local COMPRESSION_LEVELS: { [number]: Level } = { [0x01] = "Low", [0x5E] = "Fast", [0x9C] = "Defau...
424
0x5eal/luau-unzip
0x5eal-luau-unzip-5ed3cf9/tests/custom_decompression.luau
luau
.luau
local fs = require("@lune/fs") local serde = require("@lune/serde") local frktest = require("../luau_packages/frktest") local check = frktest.assert.check local unzip = require("../lib") type DecompressionRoutines = { [number]: unzip.DecompressionRoutine } return function(test: typeof(frktest.test)) test.suite("Cu...
673
0x5eal/luau-unzip
0x5eal-luau-unzip-5ed3cf9/tests/data/inflate/cases.luau
luau
.luau
return { { name = "literal_single", data = "x" }, { name = "literal_multiple", data = "Hello World!" }, { name = "repeated_a", data = string.rep("a", 100) }, { name = "repeated_ab", data = string.rep("ab", 50) }, { name = "repeated_long", data = string.rep("x", 2324) }, { name = "mixed", data = "abc" .. string.re...
164
0x5eal/luau-unzip
0x5eal-luau-unzip-5ed3cf9/tests/edge_cases.luau
luau
.luau
local fs = require("@lune/fs") local process = require("@lune/process") local serde = require("@lune/serde") local frktest = require("../luau_packages/frktest") local check = frktest.assert.check local reader = require("../.lune/util/reader_utils") local ZipReader = require("../lib") return function(test: typeof(frk...
934
0x5eal/luau-unzip
0x5eal-luau-unzip-5ed3cf9/tests/extract.luau
luau
.luau
local fs = require("@lune/fs") local process = require("@lune/process") local frktest = require("../luau_packages/frktest") local check = frktest.assert.check local readToEnd = require("../.lune/util/reader_utils").readToEnd local ZipReader = require("../lib") -- Reuse the same ZIP files from metadata tests local ZI...
671
0x5eal/luau-unzip
0x5eal-luau-unzip-5ed3cf9/tests/inflate.luau
luau
.luau
local fs = require("@lune/fs") local frktest = require("../luau_packages/frktest") local check = frktest.assert.check local inflate = require("../lib/inflate") local TEST_CASES = require("./data/inflate/cases") return function(test: typeof(frktest.test)) test.suite("Inflate decompression tests", function() for _...
345
0x5eal/luau-unzip
0x5eal-luau-unzip-5ed3cf9/tests/list.luau
luau
.luau
local fs = require("@lune/fs") local process = require("@lune/process") local frktest = require("../luau_packages/frktest") local check = frktest.assert.check local ZipReader = require("../lib") return function(test: typeof(frktest.test)) test.suite("ZIP listing tests (top-level)", function() test.case("Lists all...
571
0x5eal/luau-unzip
0x5eal-luau-unzip-5ed3cf9/tests/metadata.luau
luau
.luau
local fs = require("@lune/fs") local process = require("@lune/process") local DateTime = require("@lune/datetime") local frktest = require("../luau_packages/frktest") local check = frktest.assert.check local readToEnd = require("../.lune/util/reader_utils").readToEnd local unzip = require("../lib") local ZIPS = fs.r...
1,765
0x5eal/luau-unzip
0x5eal-luau-unzip-5ed3cf9/tests/path.luau
luau
.luau
local frktest = require("../luau_packages/frktest") local check = frktest.assert.check local path = require("../lib/utils/path") return function(test: typeof(frktest.test)) test.suite("Path utilities function as expected", function() test.case("Canonicalize should handle basic paths", function() check.equal(pat...
731