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
export type OnPayloadQueueFlush<T> = (items: T[]) => void | Promise<void>; | |
export interface PayloadQueueOptions<T> { | |
/** | |
* The interval at which the queue should be flushed | |
*/ | |
flushTimeout?: number; | |
/** | |
* The callback function to call when items are flished |
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
type SortFunction<T> = (a: T, b: T) => number; | |
interface SortRule<T> { | |
sort: SortFunction<T>; | |
asc?: boolean; | |
} | |
const multisort = <T>(items: T[], sorts: SortFunction<T>[], asc?: boolean) => { | |
const copy = [...items]; | |
copy.sort((a, b) => { |
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
local args = { ... } | |
if #args ~= 2 then | |
print("usage: furnace <input inventory id> <output inventory id>") | |
return | |
end | |
MAX_SMELTING_STACK_SIZE = 16 | |
local depots = { peripheral.find("create:depot") } | |
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
type TryFunction<T> = () => Promise<T>; | |
type TryResultSuccess<T> = { | |
ok: true; | |
result: T; | |
error: null; | |
} | |
type TryResultFailure = { | |
ok: false; |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<?import javafx.geometry.Insets?> | |
<?import javafx.scene.control.Accordion?> | |
<?import javafx.scene.control.Button?> | |
<?import javafx.scene.control.Label?> | |
<?import javafx.scene.control.Menu?> | |
<?import javafx.scene.control.MenuBar?> | |
<?import javafx.scene.control.MenuItem?> | |
<?import javafx.scene.control.TitledPane?> |
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
const timings = {}; | |
chrome.webRequest.onSendHeaders.addListener( | |
function (details) { | |
timings[details.url] = Date.now(); | |
}, | |
{ urls: ["<all_urls>"], types: ["xmlhttprequest"] } | |
); | |
chrome.webRequest.onHeadersReceived.addListener( |
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
export const partitionSettledPromises = <ResolvedType, OriginalType>(original: OriginalType[], settled: PromiseSettledResult<ResolvedType>[]): [ResolvedType[], OriginalType[]] => { | |
const resolved: ResolvedType[] = []; | |
const rejected: OriginalType[] = []; | |
for (let i = 0; i < settled.length; i++) { | |
const job = settled[i]; | |
if (job.status === "fulfilled") { | |
resolved.push(job.value); | |
} else { | |
rejected.push(original[i]); | |
} |
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
export type Category = { | |
value: string; | |
count: number; | |
} | |
export const categorize = <T extends string>(items: T[]) => { | |
const results: Category[] = []; | |
items.forEach(item => { | |
const index = results.findIndex(r => r.value === item); | |
index === -1 |
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
const chunk = <T>(items: T[], size: number) => { | |
return items.reduce<T[][]>((chunks, curr, i) => { | |
(chunks[Math.floor(i / size)] ??= []).push(curr); | |
return chunks; | |
}, []); | |
} | |
NewerOlder