🏃Quick Start
Install the library
npm install csp-coffee
Example program
Let's just write a quick example of simple hello world program using the library
import { makeChannel } from 'csp-coffee/channel';
import { go } from 'csp-coffee/go';
import { take, putAsync } from 'csp-coffee/operators';
const ch = makeChannel();
function* helloWorldRoutine () {
const greeting: string = yield take(ch);
console.log(greeting);
}
const { cancellablePromise } = go(helloWorldRoutine)
cancellablePromise.then(() => {
console.log('DONE!');
})
putAsync(ch, 'Hello World!');
You can also check out a more sophisticated example in a github repo which features an abstract and simple fast food restaurant modelled using this library.
Last updated