Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

breeze

Package Overview
Dependencies
Maintainers
2
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

breeze - npm Package Compare versions

Comparing version 1.1.2 to 1.1.3

examples/basic.js

95

breeze.js

@@ -25,3 +25,3 @@ var isPromise = require('is-promise')

*/
Breeze.prototype.createDoneCallback = function _breezeCreateDoneCallback (next) {
Breeze.prototype.createDoneCallback = function _breezeCreateDoneCallback () {
var system = this

@@ -34,3 +34,3 @@

if (err) {
if (!this.onError) {
if (!system.onError) {
system.err = err

@@ -45,24 +45,2 @@ } else {

var args = Array.prototype.slice.call(arguments, 1)
if (next) {
if (typeof next === 'function') {
args.unshift(system.createDoneCallback(system.steps.shift()))
next.apply(context, args)
return system.check(true)
}
if (next[1].apply(context, args)) {
if (next[0] === 'when') {
system.hasWhenHappened = true
} else if (next[0] === 'some') {
system.hasSomeHappened = true
}
next = next[2]
args.unshift(system.createDoneCallback(system.steps.shift()))
next.apply(context, args)
return system.check(true)
}
}
system.args = args

@@ -102,15 +80,32 @@ system.context = context

if (typeof func === 'function') {
args.unshift(this.createDoneCallback(this.steps.shift()))
args.unshift(this.createDoneCallback())
return func.apply(context, args)
}
if (func[1].apply(this.context, args)) {
if (func[0] === 'none') {
if (!this.hasSomeHappened) {
this.hasNoneHappened = true
func = func[1]
args.unshift(this.createDoneCallback())
return func.apply(context, args)
}
return this.check(true)
}
if (func[0] === 'some' && this.hasSomeHappened) {
return this.check(true)
}
if ((typeof func[1] === 'function' && func[1].apply(this.context, args)) || func[1]) {
switch (func[0]) {
case 'when': this.hasWhenHappened = true; break
case 'some': this.hasSomeHappened = true; break
case 'when': this.hasWhenHappened = true; break;
case 'some': this.hasSomeHappened = true; break;
}
func = func[2]
args.unshift(this.createDoneCallback(this.steps.shift()))
args.unshift(this.createDoneCallback())
func.apply(context, args)
} else {
return this.check(true)
}

@@ -127,2 +122,4 @@ }

Breeze.prototype.check = function _breezeCheck (pop) {
this.steps = this.steps || []
if (pop && this.steps.length) {

@@ -152,14 +149,4 @@ return this.run()

if (typeof arg === 'function') {
this.steps.push(['when', arg, next])
this.check()
return this
}
if (arg) {
this.hasMaybeHappened = true
this.steps.push(next)
this.check()
}
this.steps.push(['when', arg, next])
this.check()
return this

@@ -180,14 +167,4 @@ }

this.hasSome = true
if (typeof arg === 'function' && arg.apply(this.context, this.args || [])) {
this.steps.push(['some', arg, next])
this.check()
return this
}
if (arg) {
this.hasSomeHappened = true
this.steps.push(next)
this.check()
}
this.steps.push(['some', arg, next])
this.check()
return this

@@ -203,14 +180,14 @@ }

Breeze.prototype.none = function _breezeNone (next) {
if (this.err || this.hasSomeHappened) return this
if (this.err) return this
if (!this.hasSome) {
throw new Error("Cannot add .none check before adding .some checks")
}
if (this.hasSome) {
this.hasNoneHappened = true
this.steps.push(next)
this.steps.push(['none', next])
this.check()
}
if (!this.hasSome) {
throw new Error("Cannot add .none check before adding .some checks")
}
return this

@@ -217,0 +194,0 @@ }

{
"name": "breeze",
"version": "1.1.2",
"version": "1.1.3",
"description": "Functional async flow control library",

@@ -5,0 +5,0 @@ "main": "breeze.js",

@@ -34,37 +34,5 @@ # Breeze

## Example
## Examples
```js
// initialize our step system
// the method passed here is passed to .then, its optional, you can omit it.
breeze(function (done) {
done()
})
// truthy check
.maybe(1 === 1, function (done) {
console.log(1)
done(null, 'hey,', 'you can pass values!')
})
// checks can also be functions and are passed previous values.
.some(function (part1, part2) {
return 1 === 0
}, function (done, msg) {
console.log(2, msg)
done()
})
// invoked only when no .some checks pass.
.none(function (done, part1, part2) {
console.log(2, ',since no some happened,', part1, part2)
done()
})
// always invoked as long as the chain continues.
.then(function (done) {
console.log(3)
done('It finally happened.')
})
// invoked on error
.catch(function (err) {
console.error('An error occurred!', err)
})
```
Check out the [examples](examples/) directory for in-depth examples of how to use breeze.

@@ -71,0 +39,0 @@ ## License

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc