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 🙏

© 2024 – Pkg Stats / Ryan Hefner

js-workflow-promise

v0.0.8

Published

用类似promise链式调用的方式来做js工作流管理,有利于梳理和简化复杂的业务流程

Downloads

70

Readme

js-workflow-promise

GitHub license NPM Version NODE Version CircleCI

用类似promise链式调用的方式来做js工作流管理,有利于梳理和简化复杂的业务流程。

中文版文档

Installation

npm install js-workflow-promise -g

Examples

import { workflow } from '../src/index'

workflow
  .init({
    name: 'workflow-demo',
    context: null
  })
  .add({
    name: 'task1',
    target(curTask) {
      console.log(`Workflow-excuting: ${curTask.name}-excuted`)
    }
  })
  .run()

这个例子新建了一个名为workflow-demo的工作流,并往这个工作流中添加了一个任务task1,然后启动工作流。需要注意的是,工作流的返回值都会是一个promise

API Reference

Init

传入自定义配置来初始化一个工作流,配置可选

| 属性 | 含义 | | :------ | :--------------------: | | name | 工作流名称 | | context | 作为贯穿工作流的上下文 | | debug | 是否开启调试模式 |

Add

往工作流中添加一个任务task或者一个任务组taskGroup,要注意必须先进行初始化init。 每个工作流都是由无数的合流,分流任务组成的,每个task需要满足以下特征

| 属性 | 类型 | 含义 | | :---------- | :------------------------------------: | -------------------------------------------------: | | name | string | 任务名称 | | target | (task:Task,workflowInst:Workflow)=>any | 任务目标函数 | | scope | any | 任务函数执行作用域,不传则作用域默认为当前工作流。 | | description | string | 任务描述 | | filter | (task:Task)=>boolean | 是否应该执行该次任务 |

Run

执行工作流中的任务,最终返回一个promise。 要注意的是,只要工作流中的一个任务中断(出错或者显性地调用this.cancel()),则会抛出异常,且不会执行后续任务。

Cancel

中断工作流,中断正在执行的任务,且不会执行后续任务。

Property Reference

Name

工作流的名称

Context

贯穿工作流的上下文,可以类似使用koa.ctx的思想和习惯来使用该属性。

Debug

开启调试模式。开启后会将task运行的细节记录起来,可以通过record获取到每个task运行的结果,错误信息,耗时信息

TODO LIST

  • 收集workflow运行结果并可视化展示

Licence

MIT