Codync
免費、開源的 1:1 替代方案,取代 Grok Bot 與 Muse。從 iPhone、Mac 或 Linux 桌面將 Claude Code、Codex、Cursor 與 40+ 程式碼代理人作為持續機器人傳訊。群組聊天、主題串…
AI 翻譯
尚未偵測到更新。GitHub 發布版本後會顯示在這裡。
個人 GitHub 帳號下公開儲存庫的擁有者可以登入並驗證所有權,自行管理介紹,無需管理員核准。
登入並產生驗證檔案,在 30 分鐘內將其提交至此儲存庫的預設分支。其他分支或分叉儲存庫中的檔案無效。然後在下方檢查檔案,即可無需管理員核准直接管理專案。請保留檔案以維持管理權限。
如需登入,將前往登入頁面。登入後請回到此處,再次點擊所選的驗證按鈕。
在專案資料夾中執行 /nomorevibe verify,即可驗證所有權並自行管理介紹。
一分鐘完成驗證製作者的介紹僅有上面的一句話。 更多詳情請閱讀儲存庫 README。 儲存庫 README ↗
正在載入完整 README。
檢視完整 README ↗The classic low-level design interview question, solved without the State pattern: the whole machine is one pure function.
step(machine, event) → [machine, effects]
▶ Try it in the animated walkthrough: buy something, jam the motor, run out of change, then scrub back through time and branch from any moment.
stateDiagram-v2
[*] --> idle
idle --> paying: select (in stock)
paying --> paying: insert / buy before fully paid
paying --> dispensing: buy (paid ≥ price, change possible)
paying --> idle: cancel / no change possible
dispensing --> idle: dispensed (commit) / jammed (refund)
| File | Role |
|---|---|
src/machine.ts | Types and step(): every (phase, event) pair, nothing else. No I/O, no clock, no mutation |
src/coins.ts | Integer cents, coin counts, makeChange() |
tests/properties.test.ts | fast-check: thousands of random event sequences against invariants |
docs/index.html | The shell: renders the machine and replays events through the same core (docs/vending.js is built from src/) |
The textbook solution is a VendingMachine class holding selectedProduct, totalCoins and currentState, plus a State pattern with Idle, Ready, Dispense and ReturnChange classes that call machine.setState(new ...).
switch is fine when the compiler checks it. The OOP answer rejects switch on Open/Closed grounds. With discriminated unions and noImplicitReturns, dropping a case fails the build, which is stronger than OCP for a closed set of states.idle has none and paying has slot and inserted. "Idle with a product selected" cannot be written down.{ tag: 'returnCoins', coins } and not a ReturnChangeState. Tests read effects like any value, and the page animates them.dispensed. On jammed the exact inserted coins go back and nothing was ever written.totalCoins = 135 cannot tell you whether 35¢ of change is possible. The box keeps counts per denomination, and that is the only way "Exact change only" fits in the design.makeChange backtracks and is checked against brute force.step one at a time. If the machine sits behind an API, serialising events per machine is the shell's job, and the core does not change.run(start, events) on every render.Hand-written scenarios cover the obvious paths. The property tests generate random machines and up to 60 random events (coins while dispensing, sensor signals out of nowhere, slots that do not exist) and check, at every step:
box + inserted = box' + returned + escrowmakeChange finds change exactly when brute force says it existsTo check they are not decorative: drop the line that pays change out of the box and three tests fail. Drop any case and tsc refuses to compile.
Requires Node 23+.
npm install
npm test # unit + property tests
npm run typecheck
npm run build:web # rebuild docs/vending.js after changing src/
Open docs/index.html through any static server, for example npx serve docs.