@statebox/stbx-js
v0.0.31
Published
[](https://travis-ci.com/statebox/stbxjs)
Readme
@statebox/stbx-js
All that this does is bundle stbx-core-js for node and the browser.
The build is published by Travis-CI to @statebox/stbx-js
Usage
Node
npm install --save @statebox/stbx-jslet Stbx = require("@statebox/stbx-js")
// create protocol instance
let mynet = {name:"a", partition: [0,1,0,1,0,0], names:["x","y"]}
let mydiagram = {name:"z", width:1,pixels:[1,2],names:["s","t"]}
let s = new Stbx({
nets: [mynet],
diagrams: [mydiagram],
labels: [0, 0] // both nodes in the diagram point to net "a"
});
// count the number of transitions and places
console.log(s.transitionCount(), s.placeCount())Browser
<script src="//unpkg.com/@statebox/stbx-js"></script>
<script>
// create protocol instance
let mynet = {name:"a", partition: [0,1,0,1,0,0], names:["x","y"]}
let mydiagram = {name:"z", width:1,pixels:[1,2],names:["s","t"]}
let s = new Stbx({
nets: [mynet],
diagrams: [mydiagram],
labels: [0, 0] // both nodes in the diagram point to net "a"
});
// count the number of transitions and places
console.log(s.transitionCount(), s.placeCount())
</script>decoding a transaction
<script src="//unpkg.com/@statebox/stbx-js"></script>
<script>
let whex =
`0a3f0a04696e697410001001100210001001100010001002100010001a0573746172741a0d737461727450726f64756365721a0d7374617274436f6e73756d65720a460a0870726f64756365721000100110001001100010021003100010021000100110001003100010001a0d737461727450726f64756365721a01611a01621a0770726f636573730a460a08636f6e73756d65721000100110001001100310001002100010021000100110001000100310001a0d7374617274436f6e73756d65721a01611a01621a0770726f6365737312140a04726f6f741003180118011802180218031803180018011802`
let w = Stbx.decode_wiring(whex)
console.log(JSON.stringify(w))
console.log(Stbx.encode_wiring(w))
</script>Examples (same for browser/node)
See @wires/stbx-core-js
Development
Running npm run bundle:production produces dist/stbx.min.js which can be used in the browser.
Run npm publish to publish the bundled package.
the unpkg field in package.json specifies which file is served when you surf to
must set NPM_AUTH_TOKEN on travis ci
