npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

bamboo_smf

v1.0.9

Published

有限状态机-用于编排复杂的流程业务,如订单流转,审批流程

Readme

有限状态机

用于编排复杂的流程业务,如订单流转,审批流程

安装

npm install bamboo_smf -S

使用

const Smf = require('bamboo_smf');
const circuit1 = new Smf()
//订单正常流程
circuit1.init('order', 'new')
.push('new', 'order.pay')
.push('pay', 'order.confirm', 'refund.start')
.push('confirm', 'order.end')
.push('end')



const circuit2 = new Smf()
//订单退款流程
circuit2.init('refund', 'start')
.push('start', 'refund.reimburse')
.push('reimburse', 'refund.end')
.push('end')

const processFlow = new Smf()
//把编排好的流程数据导入
processFlow.setSmfDataList([
circuit1.getSmfData(),
circuit2.getSmfData(),
])

//监听流程变更
processFlow.on((e, paras) => {
    console.log(e,paras);
})

//跳转下个流程
processFlow.setStatus('order.new').nextTo()
// or 
processFlow.nextTo('order.new')

Smf.init

定义初始值状态

const circuit = new Smf()
circuit.init('状态链名称', '初始状态')

Smf.push

添加转变内容

circuit.push('状态名称', '下一个流程地址(区块名称.状态名称)','异常时的流程地址(区块名称.状态名称)')

Smf.getSmfData

获取全部定义的json数据

circuit.getSmfData()

Smf.setSmfDataList

设置所有区块数据

circuit.setSmfDataList([区块数据])

Smf.setStatus

设置当前状态

circuit.setStatus('当前状态(区块名称.状态名称)')

Smf.get

获取当前状态的数据

circuit.get()

Smf.getStatusName

获取当前状态的名称

circuit.getStatusName()

Smf.getCurrentState

获取当前区域和状态

circuit.getCurrentState()

Smf.getTo

获取当前状态的to区域和状态

circuit.getTo()

Smf.getErr

获取当前状态的err区域和状态

circuit.getErr()

Smf.start

触发开始状态

circuit.start('区块名称','事件入参')

Smf.end

触发结束状态(最后一个状态)

circuit.end('区块名称','事件入参')

Smf.next

按当前状态跳转下一个

circuit.next('事件:to,err','跳转时可以重新定义当前状态','事件入参')

Smf.nextTo

按当前状态跳转到to

circuit.next('跳转时可以重新定义当前状态','事件入参')

Smf.nextErr

按当前状态跳转到err

circuit.next('跳转时可以重新定义当前状态','事件入参')

Smf.on

触发跳转时的事件

circuit.on((e, paras) => {
    console.log(e,paras);
   /**
    e:当前状态数据: {
      status_name: 'ling',
      to: 'test.end',
      err: '',
      currentState: 'test.ling'
    }
   **/
})