Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling .apply on a State Machine Factory is Throwing an Error #174

Open
andyautida14 opened this issue Apr 2, 2019 · 0 comments
Open

Comments

@andyautida14
Copy link

Using:

Using the following code:

const StateMachine = require('javascript-state-machine')

const Matter = StateMachine.factory({
  transitions: [
    { name: 'melt',     from: 'solid',  to: 'liquid' },
    { name: 'freeze',   from: 'liquid', to: 'solid'  },
    { name: 'vaporize', from: 'liquid', to: 'gas'    },
    { name: 'condense', from: 'gas',    to: 'liquid' }
  ]
})

const thing = Matter.apply({ type: 'water' }, { init: 'solid' })

thing.melt()

Running the code above throws TypeError: Cannot read property 'apply' of undefined

$ node replicate.js
node_modules/javascript-state-machine/lib/state-machine.js:597
    cstor   = function() { this._fsm.apply(this, arguments) };
                                     ^

TypeError: Cannot read property 'apply' of undefined
    at Object.cstor (node_modules/javascript-state-machine/lib/state-machine.js:597:38)
    at Object.<anonymous> (replicate.js:12:22)
    at Module._compile (internal/modules/cjs/loader.js:707:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:718:10)
    at Module.load (internal/modules/cjs/loader.js:605:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:544:12)
    at Function.Module._load (internal/modules/cjs/loader.js:536:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:760:12)
    at startup (internal/bootstrap/node.js:308:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:878:3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant