tart-adapter
Stability: 1 - Experimental
Adapter turning synchronous functions into asynchronous Tiny Actor Run-Time in JavaScript actors.
Contributors
Overview
Tart adapter turns synchronous functions into asynchronous Tiny Actor Run-Time in JavaScript actors.
Usage
To run the below example run:
npm run readme
"use strict"; var adapter = ;var tart = ; var syncCountVal = 0;var { return ++syncCountVal;}; var obj = value : 0;var { thisvalue = thisvalue + increment; return thisvalue;}; var asyncCountBeh = ;var asyncIncBeh = ; var sponsor = tart; var asyncCount = ;var asyncInc = ; var countOk = ; var incOk = ; var fail = ; ;;
Tests
npm test
Documentation
Public API
adapter(obj, fn)
obj
: Object (Default: {}) Object to bindthis
to when invokingfn
.fn
: Function Function to invoke onobj
.- Return: Behavior
function (message) {}
An actor behavior that will callfn
withmessage.arguments
and return result as a message tomessage.ok
. If an exception is thrown, it will be sent tomessage.fail
.
Sets up an actor behavior that wraps invocation of fn
on obj
. If obj
is not provided, it is set to {}
.
message.arguments
must be either an Array
or a pseudo-array arguments
object.