yes command implemented in WebAssembly and WASI
This command is distributed from WAPM.
$ wapm install Syuparn/yes
$ wapm run yes | head -n 3
y
y
y
You can also compile wasm manually from wat
file.
$ wasm2wat yes.wat
$ wasmer yes.wasm
y
y
y
...
Same as the GNU yes
command.
# write `y` infinitely
$ wapm run yes
y
y
y
y
y
...
# write argument instead
$ wapm run yes no!
no!
no!
no!
no!
no!
...
In order to reduce binary size, yes.wat
is written by hand.
You can test generated wasm by bats.
# install wat2wasm and bats
$ npm install
# build wasm
$ npx wat2wasm yes.wat
# run test (requires wasmer)
$ npx bats test/yes.bats
✓ yes without argument writes 'y'
✓ yes always writes 'y'
2 tests, 0 failures