Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
step-flow is a lightweight(without any libraries and less than 200 lines) business processes control library that allows to easily manage business logic by step. step-flow using the syntax of middleware which is similar to express. It provides process control, step jumps, and unified error handling.
npm install --save step-flow
var Flow = require('step-flow');
var flow = new Flow();
one step with multiple functions:
flow.use(
'step1',
function fn1 (ctx, next) {
ctx.fn1 = true;
next();
},
function fn11 (ctx, next) {
ctx.fn11 = true;
next();
}
);
one step with one function:
flow
.use('step2', function fn2 (ctx, next) {
ctx.fn2 = true;
// next();
})
.use(function fn3 (ctx, next) {
ctx.fn3 = true;
});
flow.catch(function (err) {
console.log('flow error:', err);
});
var context = {};
flow.run(context)
StepFlow
Add the steps and the corresponding function. If the specified steps already exist, these functions will be appended to this step. If it does not exist, create a new one.
Each function added here will receive the parameters (context, next, nextTo, data)
:
context
: context object.next(err[,data])
: Execute the next function in step, and if it is not called, the next function will not be executed.nextTo(step[,data])
: Call this method and pass the step name, you can jump to the corresponding steps.data
: the data that the next(null, data)
pass.Only call next()
will continue to execute the next function in the step. If a non-empty parameter err is passed, and the subsequent functions will not be executed. The error handling function set with catch(fn)
will be executed. If you call next()
/nextTo()
, and passing the parameter data
, the next function will receive this data. However, the functions that after the 'next function' will not receive this data, unless the 'next function' call next()
/nextTo()
and pass the data.
Param | Type | Default | Description |
---|---|---|---|
[stepName] | String | 'default' | The step name, if you omit this parameter, the default use is default |
StepFlow
Add error handling functions that will be executed when next (err)
is called and a non-null err
arguments are passed.
In addition, if an error occurs while running the method specified by the use()
method, fn
will also be executed and the error object will be passed to fn
.
The fn
will accept the parameter(err)
,err
for the error message.
Param | Type | Description |
---|---|---|
fn | function | Error handling function |
StepFlow
Start to run the step functions. If the step name is specified, it will be executed from the corresponding step. If it is not specified, it will be executed from the first step.
Param | Type | Description |
---|---|---|
context | Any | Context object, the function of each step will accept this parameter |
stepName | String | Start step name, starting from the first step by default |
npm test
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
See also the list of contributors who participated in this project.
This project is licensed under the MIT License - see the LICENSE file for details
FAQs
step flow
We found that step-flow 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
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.