Instantly share code, notes, and snippets.
- Tokyo/Japan
- https://mizchi.dev
- @mizchi
mizchi /moonbit-js-size-analysis.md
Last activeNovember 29, 2025 10:45
This document analyzes the bundle size of MoonBit JavaScript output, identifying the main contributors to code size and potential optimization opportunities.
Note: The analyzed output is after terser DCE (Dead Code Elimination) with compress enabled. Unused code has already been removed.
https://github.com/mizchi/js.mbt/blob/main/src/examples/aisdk/main.mbt
mizchi /moonbit-ffi-core.md
CreatedNovember 2, 2025 16:48
mizchi /moonbit-proposal-json-enum-draft-ja.md
Last activeNovember 2, 2025 14:54
mizchi /promise.mbt
CreatedOctober 29, 2025 16:12
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
| /// original https://github.com/moonbit-community/jmop/blob/main/promise.mbt | |
| ///| | |
| extern"js"fnffi_promise_resolve(x :Value)->Value="(x) => Promise.resolve(x)" | |
| ///| | |
| extern"js"fnffi_promise_reject(e :Error)->Value="(x) => Promise.reject(x)" | |
| ///| | |
| extern"js"fnffi_promise_then( |
mizchi /async-raise-failure.mbt
Last activeOctober 28, 2025 13:10
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
| ```mbt | |
| asyncfn[T,U]map_async(arr:Array[T],f:async (T)->Uraise?)->Array[U]raise? { | |
| letres:Array[U]= [] | |
| foriteminarr { | |
| res.push(f(item)) | |
| } | |
| res | |
| } | |
| asynctest { |
mizchi /mbt-error-in-test.md
CreatedOctober 21, 2025 16:20
mizchi /rabbit-tea-svg-element.mbt
CreatedOctober 14, 2025 11:16
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
| ///| | |
| fnalias@svg.nodeassvg_node | |
| ///| | |
| fn[M]common_svg_node( | |
| tag_name :String, | |
| new_attrs :Array[@svg.Attribute[M]], | |
| style~ :Array[String]?, | |
| class~ :String?, | |
| id~ :String?, |
mizchi /openrouter-byok.ts
CreatedOctober 9, 2025 12:39
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
| constOPENAI_API_KEY_PATH="%_%=k"; | |
| constTEMP_PKCE_VERIFIER="%_%=pk"; | |
| functionbase64UrlEncode(array:Uint8Array):string{ | |
| constbase64=btoa(String.fromCharCode(...array)); | |
| returnbase64.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,""); | |
| } | |
| typeLoginState= | |
| |{ |
mizchi /discord-oidc-worker.js
CreatedOctober 9, 2025 11:49
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
| /** | |
| DiscordAuthforCloudflareAccess | |
| basedon https://github.com/Erisa/discord-oidc-worker | |
| #Creatediscordapplication | |
| -Getclientidandsecret | |
| -SetredirectURLto`https://<cloudflare-name>.cloudflareaccess.com/cdn-cgi/access/callback` |
mizchi /moonbit-string-bytes-convert.mbt
CreatedSeptember 17, 2025 14:07
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
| ///| | |
| test"String to Bytes conversion" { | |
| fnfind_index(url :Bytes)->Int? { | |
| url.find("://") | |
| } | |
| leturl="https://www.example.ocom" | |
| leturl_bytes :Bytes="https://example.com" | |
| inspect(url.find("://"),content="Some(5)") | |
| inspect(find_index("https://example.com"),content="Some(5)") |
NewerOlder