Codync
무료 오픈소스 1:1 대안, Grok Bot과 Muse 대신
아직 감지된 업데이트가 없습니다. GitHub 릴리스가 나오면 여기에 보입니다.
개인 계정의 공개 저장소 소유자는 GitHub로 로그인해 운영자를 확인하고 소개를 직접 관리할 수 있습니다. 관리자 승인은 필요하지 않습니다.
로그인한 뒤 확인 파일을 만들어 이 저장소의 기본 브랜치에 30분 안에 커밋해 주세요. 다른 브랜치나 포크의 파일은 인정하지 않습니다. 파일을 올린 뒤 아래에서 확인하면 관리자 승인 없이 관리할 수 있습니다. 자격을 유지하려면 파일을 남겨 두세요.
로그인이 필요하면 로그인 화면으로 이동합니다. 로그인 후 이곳으로 돌아와 원하는 확인 버튼을 다시 눌러 주세요.
프로젝트 폴더에서 /nomorevibe verify를 실행하면 소유권을 확인하고 소개를 직접 관리할 수 있습니다.
1분 만에 확인하기메이커가 쓴 소개는 위의 한 줄이 전부입니다. 더 자세한 내용은 저장소 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.