chore: Set up development environment

Add the civet and typescript compilers, implement a build step,
  provide examples of using from es6, script, and command line.
  Of course, there is no actual behavior produced; convert always produces
  'foo' at the moment.
This commit is contained in:
Glen Whitney 2023-09-01 08:20:34 -07:00
parent 26f1be2d67
commit 67a07e2000
10 changed files with 468 additions and 1 deletions

1
etc/package.json Normal file
View file

@ -0,0 +1 @@
{"type": "module"}

17
etc/testscript.html Normal file
View file

@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>vrml1to97 test</title>
<script>
(async () => {
const vrml1to97 = await import('../dist/index.js')
console.log(vrml1to97.convert('test'))
})()
</script>
</head>
<body>
<p>Nothing will show in this page, but the result of the conversion
should appear in the console.</p>
</body>
</html>

23
etc/vrml1to97.js Executable file
View file

@ -0,0 +1,23 @@
#!/usr/bin/env node
import {convert} from './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");
}
if (argv.length > 2) {
console.log('Usage: vrml1to97 < old.wrl > shinynew.wrl')
console.log(' Translates VRML 1.0 on standard input to VRML97 on standard out.')
} else {
const input = await streamToString(stdin)
console.log(convert(input))
}