Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Finite state machine that emits events and is compatible to EventEmitter.
Finito is a finite automata implementation that emits events and is compatible to the EventEmitter interface.
npm install finito
The addTransition
method takes a single transition and adds it to the
automata.
addTransition from, via, to
Finito = require 'finito'
fin = new Finito
fin.addTransition 'state1', 'foo', 'state2'
The Finito
class optionally takes transitions as argument.
For example
Finito = require 'finito'
fin = new Finito
state1:
foo: 'state2'
state2:
bar: 'state1'
means that if the automata is in state1
and reads foo
it will go into
state2
and if the automata is in state2
and reads bar
it will go
into state1
.
The read
method reads a single character, that means it executes a single
transition.
The readWord
method reads a word, splits it up in characters and feeds it to
the automata. It takes a string or an array.
The change event is emitted, when the automata changes its state. The event handler gets the previous state, the character that was read and the new state.
Finito = require 'finito'
fin = new Finito
state1:
'foo': 'state2'
state2:
'bar': 'state1'
fin.setStart 'state1'
fin.on 'change', (from, via, to) ->
console.log "Changed state from #{from} to #{to} by reading '#{via}'"
fin.read 'foo'
fin.read 'bar'
Changed state from state1 to state2 by reading 'foo'
Changed state from state2 to state1 by reading 'bar'
The finish event is emitted, when the automata reaches a final state. Final
states are added by calling addFinal 'state'
.
Finito = require 'finito'
fin = new Finito
default:
'foo': 'bar'
fin.addFinal 'bar'
fin.on 'finish', ->
console.log 'FINISHED!'
fin.read 'bar'
fin.read 'foo'
A simple example for a finite automata is detection of parity.
Finito = require 'finito'
fin = new Finito
even:
'0': 'even'
'1': 'odd'
odd:
'0': 'odd'
'1': 'even'
fin.on 'change', (from, via, to) ->
console.log from+'\t--['+via+']-->\t'+to
fin.state.current = 'even'
fin.readWord '1101'
even --[1]--> odd
odd --[1]--> even
even --[0]--> even
even --[1]--> odd
FAQs
Finite state machine that emits events and is compatible to EventEmitter.
The npm package finito receives a total of 0 weekly downloads. As such, finito popularity was classified as not popular.
We found that finito demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.