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
| import { randomBytes } from "node:crypto"; | |
| import { request as httpRequest } from "node:http"; | |
| import { request as httpsRequest } from "node:https"; | |
| const DEFAULT_PORT = 443; | |
| const SEC_WEBSOCKET_VERSION = 13; | |
| class WebSocket extends EventTarget { | |
| constructor(url, protocols) { | |
| super(); |
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 interface Field { | |
| contentType?: string; | |
| filename?: string; | |
| name: string; | |
| value: string | Uint8Array; | |
| } | |
| export const boundary = Math.random().toString(16).substring(2); | |
| export async function* fileIterator(fields: Field[]) { |
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 damage = 100; | |
| const hp = 15_000; | |
| const damage_reduction = .25; | |
| const damage_reduction_limit = hp * .3; | |
| const damage_reduced = Math.min(damage * damage_reduction, damage_reduction_limit); | |
| const incoming_damage = Math.max(1, damage - damage_reduced); |
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
| function actions_per_turn(speeds, turns) { | |
| const arr = []; | |
| const slowest_speed = Math.min(...speeds); | |
| for (const speed of speeds) { | |
| const speed_arr = []; | |
| let remainder = 0; | |
| for (let i = 0; i < turns; i++) { | |
| const value = speed / slowest_speed + remainder; | |
| const floored = Math.floor(value); | |
| speed_arr.push(floored); |
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
| function hi() { | |
| console.log("hi") | |
| } |
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
| function encode(str) { | |
| return ( | |
| encodeURIComponent(str) | |
| .replace( | |
| /[\-\_\.\!\~\*\'\(\)]/g, | |
| (c) => `%${c.charCodeAt(0).toString(16).toUpperCase()}`, | |
| ) | |
| ); | |
| } |
OlderNewer