Comments (6)
Actually, for some reason, I cannot get either of
import { Machine, make } from jssm;
or
var jssm = require('jssm');
to work. Machine
, make
, and jssm
respectively are undefined.
from jssm.
Even with:
import * as jssm from 'jssm';
console.log(jssm); // { default: {} }
from jssm.
I've used the interactive demo at jssm/src/demo/index.html and manipulated a SM through the console. Yet, I still don't see how to use this library in NodeJS.
from jssm.
I've looked at the tests in src/js/tests
and the import in those files is:
const jssm = require('../../../build/jssm.es5.js'),
sm = jssm.sm;
and obviously works, but this file is not available in the NPM package, and I've used:
const jssm = require('./node_modules/jssm/dist/jssm.es5.cjs.js'),
sm = jssm.sm;
as a substitute, but no cookie.The complaint being that sm
is not a function, which it is not, it's a property.
from jssm.
Tried this again this weekend, and managed to get it working in NodeJS. Seems a bit hacky, but I can now turn a DSL into a fsm.
Install for the project:
npm -i jssm --save
Go to the jssm
directory in node_modules
:
cd node_modules/jssm
Install dependencies of jssm
:
npm install
Then run the make script:
npm run-script make
Now we have a build
directory with the file jssm.es5.js
and we can import the appropriate functions (or at least I can because I'm using babel to translate imports, otherwise you'd use a require
):
import { sm, Machine, make } from './node_modules/jssm/build/jssm.es5';
We can then do something like this:
import fs from 'fs';
fs.readFile('./my.fsl', 'utf8', function(err, planString) {
let myExampleFSM = new Machine( make( planString ) );
console.log(myExampleFSM.state()); // check initial state
myExampleFSM.action('proceed'); // assuming your fsl has a 'proceed' transition
console.log(myExampleFSM.state()); // check the result of the action
}
Note that the shorter way:
let myExampleFSM = sm( planString );
doesn't work for me because there's an error TypeError: template_strings.reduce is not a function
in return new Machine(make(template_strings.reduce(...
from jssm.
The reason why sm( planString )
isn't working for me is because I was trying to pass in a String when it's expecting an array of Strings. Whatever, sm
is aiming to achieve with arguments
(currently a commented out arg into the sm
function), I don't need it. new Machine( make( myDSL_string ) )
works fine.
from jssm.
Related Issues (20)
- editor dies when high unicode like ✅ is used HOT 1
- Does this need a video series? HOT 3
- get a mention HOT 1
- Publish the next NPM version HOT 3
- NodeJS approach to producing SVGs HOT 7
- fsl to svg cli HOT 4
- Link SVG stuff from site; make youtube HOT 1
- Github action for graphing HOT 1
- reassert videos on site HOT 1
- Gh actions viz build HOT 1
- Events HOT 6
- Todo list (v3) HOT 1
- TypeScript type declarations file HOT 11
- Huge package HOT 24
- Parse the JSSM format HOT 4
- Do a full rescan of repo HOT 1
- Saving/restoring machine state between runs HOT 7
- Problem defining more than one action with the same transition path HOT 6
- this._data is never set when without hooks path is taken in `transition_impl` HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jssm.