mirror of
https://github.com/remko/waforth
synced 2025-01-17 18:11:39 +01:00
Make onEmit log to console by default
This commit is contained in:
parent
55647e0200
commit
a11c7a10ea
1 changed files with 12 additions and 0 deletions
|
@ -49,6 +49,18 @@ class WAForth {
|
|||
|
||||
constructor() {
|
||||
this.#fns = {};
|
||||
this.onEmit = (() => {
|
||||
// Default emit that logs to console
|
||||
let buffer: string[] = [];
|
||||
return (c: string) => {
|
||||
if (c === "\n") {
|
||||
console.log(buffer.join(""));
|
||||
buffer = [];
|
||||
} else {
|
||||
buffer.push(c);
|
||||
}
|
||||
};
|
||||
})();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue