This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- The equality operator `==` is really strict with unions and intersections, | |
-- where the order of their components needs to be the same. | |
type function sort_type(input: type) | |
local input_tag = input.tag | |
if input_tag == "union" or input_tag == "intersection" then | |
local components = input:components() | |
table.sort(components, function(a: type, b: type): boolean | |
local a_tag, b_tag = a.tag, b.tag |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--!strict | |
type function default_nanoid() | |
return nanoid() | |
end | |
export type function nominal(input: type) | |
local phantom_table = types.newtable() | |
phantom_table:setwriteproperty(types.singleton("_phantom_nominal_id"), types.singleton(default_nanoid()())) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--!strict | |
--!nolint LocalShadow | |
--> Table Helpers ---------------------------------------------------------------------- | |
--[=[ | |
Performs a swap remove on a table type. | |
@category Table | |
@param input { [any]: any } -- The table value to perform a swap remove on. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A helper which outputs a reader to an `onChunk` callback. | |
// Please note that the data sent to `onChunk` is the total data thus far. | |
interface StreamBodyCallbackOptions { | |
chunkSize?: number, | |
delayMs?: number, | |
abortSignal?: AbortSignal | |
} | |
export const streamBodyCallback = async ( |
OlderNewer