feat: install moo and use in toy example
I failed to find a satisfactory way to compile and import moo.js with fixed specifiers, so finally I just gave up and patched the distributed code to be an es6 module. A bit ugly but it works.
This commit is contained in:
parent
67a07e2000
commit
77bd983cbc
11 changed files with 86 additions and 25 deletions
10
etc/streamToString.js
Normal file
10
etc/streamToString.js
Normal file
|
@ -0,0 +1,10 @@
|
|||
export async function streamToString(stream) {
|
||||
// lets have a ReadableStream as a stream variable
|
||||
const chunks = [];
|
||||
|
||||
for await (const chunk of stream) {
|
||||
chunks.push(Buffer.from(chunk));
|
||||
}
|
||||
|
||||
return Buffer.concat(chunks).toString("utf-8");
|
||||
}
|
|
@ -5,8 +5,8 @@
|
|||
<title>vrml1to97 test</title>
|
||||
<script>
|
||||
(async () => {
|
||||
const vrml1to97 = await import('../dist/index.js')
|
||||
console.log(vrml1to97.convert('test'))
|
||||
const vrml1to97 = await import('../dist/vrml1to97/index.js')
|
||||
console.log(vrml1to97.convert('if (moo) cows // hurray'))
|
||||
})()
|
||||
</script>
|
||||
</head>
|
||||
|
|
|
@ -1,18 +1,8 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
import {convert} from './index.js'
|
||||
import {convert} from './vrml1to97/index.js'
|
||||
import {stdin, argv} from 'node:process'
|
||||
|
||||
async function streamToString(stream) {
|
||||
// lets have a ReadableStream as a stream variable
|
||||
const chunks = [];
|
||||
|
||||
for await (const chunk of stream) {
|
||||
chunks.push(Buffer.from(chunk));
|
||||
}
|
||||
|
||||
return Buffer.concat(chunks).toString("utf-8");
|
||||
}
|
||||
import {streamToString} from './streamToString.js'
|
||||
|
||||
if (argv.length > 2) {
|
||||
console.log('Usage: vrml1to97 < old.wrl > shinynew.wrl')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue