valuescript
v0.0.4
Published
A dialect of TypeScript with value semantics
Downloads
11
Readme
ValueScript
About the language
This module
This is a module for running ValueScript in JavaScript.
ValueScript is in early development and this module is especially unlikely to be useful externally right now. Please drop me a line if you want to see this improved :).
It's possible you will find the lower level WorkerPool
and WorkerSlot
utilities useful:
import { WorkerPool } from 'valuescript';
function task() {
console.log('Hi from pool');
}
const script = [
'self.postMessage("ready");',
task.toString(),
'task();',
].join('\n\n');
const scriptUrl = URL.createObjectURL(
new Blob([script], { type: 'application/javascript' }),
);
const pool = new WorkerPool(scriptUrl);
pool.use(async (worker, terminate) => {
// Exclusive access to worker
// terminate() terminates the worker and leads to the creation of a new one
// for use by other consumers
});