Comparing version 1.2.0 to 1.2.1
@@ -155,3 +155,3 @@ // Constructor | ||
args.unshift(this.createStepCallback()) | ||
return step.apply(context, args) | ||
return step.apply(this.context, args) | ||
} | ||
@@ -186,3 +186,3 @@ | ||
args.unshift(this.createStepCallback()) | ||
return step.apply(context, args) | ||
return step.apply(this.context, args) | ||
} | ||
@@ -189,0 +189,0 @@ |
{ | ||
"name": "breeze", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "Functional async flow control library", | ||
@@ -5,0 +5,0 @@ "main": "breeze.js", |
@@ -25,27 +25,43 @@ # Breeze | ||
- `breeze(next)` - Initialize breeze flow system, supports initial `.then` method. | ||
- `breeze(step)` - Initialize breeze flow system, supports initial `.then` method. | ||
- `.pass(value)` - Introduce new value into flow system, argument is appended to system arguments passed through `next`. | ||
- `.when(check, next)` - When `check` is truthy, add `next` to the stack | ||
- `.maybe(check, next)` - When `check` is truthy, add `next` to the stack, sugar for `breeze.when` | ||
- `.some(check, next)` - When `check` is truthy and no other `some` or `none` has ran, add to the stack | ||
- `.none(next)` - Whenever no `some` have ran, add callback to the stack | ||
- `.then(next)` - Add callback to stack | ||
- `.each(iterables, iteratee, next)` - Iterate over an object / array and invoke a method for each entry. `iterables` is not a reference therefore, you must properly store `iterables` outside of the flow if you plan to update or modify the object. | ||
- `.catch(next)` - Any error caught will terminate stack and be sent here | ||
- `.when(check, step)` - When `check` is truthy, add `step` to the stack | ||
- `.maybe(check, step)` - When `check` is truthy, add `step` to the stack, sugar for `breeze.when` | ||
- `.some(check, step)` - When `check` is truthy and no other `some` or `none` has ran, add to the stack | ||
- `.none(step)` - Whenever no `some` have ran, add callback to the stack | ||
- `.then(step)` - Add callback to stack | ||
- `.each(iterables, iteratee, step)` - Iterate over an object / array and invoke a method for each entry. `iterables` is not a reference therefore, you must properly store `iterables` outside of the flow if you plan to update or modify the object. | ||
- `.catch(step)` - Any error caught will terminate stack and be sent here | ||
- `.deferred()` - Returns a deferred promise system, allowing for a passable then / catch. | ||
- `.reset()` - Reset current system | ||
### Next | ||
### Step | ||
The `next` method passed through breeze has a very small api. It accepts two variants of usage, normal node style | ||
`err, arguments...`, and `promise, arguments...`. | ||
The `step` method passed through breeze has a very small API, providing any `arguments` stored within the system passed through either the `next` or `.pass` methods, and the `next` callback method which is explained below. | ||
When a *truthy* `err` is passed the system will halt (no other actions will be taken) and `.catch` will be triggered. | ||
#### Promises | ||
``` | ||
function step (next, arguments...) | ||
``` | ||
When a `promise` is passed the system will attach to either the `then / catch` methods, or the `.then(then, catch)` | ||
method style depending on the promise type passed. Whenever the `then` is invoked, any `arguments` passed along with | ||
the passed promise are placed at the *front* of the arguments array, and the success arguments will be *last*. | ||
#### Next | ||
The `next` method is the step callback system, it provides utility for short-circuiting the step system with an error, passing additional arguments along the chain, and skipping steps completely. | ||
``` | ||
return next(err, arguments...) | ||
``` | ||
The `next` method supports additional modes explained below. | ||
##### Errors | ||
When a *truthy* `err` is passed the system will short-circuit (no other actions will be taken) and `.catch` will be triggered. | ||
##### Promises | ||
When a `promise` is passed the system will attach to either a `then / catch` or `.then(success, catch)` method style depending on the promise type passed. | ||
Whenever the promises `then / then success` method is invoked, any `arguments` passed along with the initial promise are placed at the *front* of the arguments array, and the success arguments will be *last*. | ||
This allows you to chain multiple promises while still passing values down the chain. | ||
@@ -57,3 +73,3 @@ | ||
#### Skipping Steps | ||
##### Skipping Steps | ||
@@ -73,3 +89,3 @@ When you pass the string `skip` as the first argument in the `next` method, the next step in the sequence will be skipped completely. | ||
- [each](examples/each.js) - Breeze array iteration (`then`, `pass`, `each`, `catch`) | ||
- [when](examples/maybe.js) - Conditional flows (`then`, `when`) | ||
- [when](examples/when.js) - Conditional flows (`then`, `when`) | ||
@@ -100,2 +116,2 @@ | ||
[download]: https://github.com/Nijikokun/breeze/archive/v1.2.0.zip | ||
[download]: https://github.com/Nijikokun/breeze/archive/v1.2.1.zip |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
29853
114