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

caco

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

caco - npm Package Compare versions

Comparing version 2.0.2 to 2.0.3

20

index.js

@@ -25,3 +25,3 @@ var isGeneratorFunction = require('is-generator-function')

var done = false
var nextQ = []
var ticking = false
var callback

@@ -62,11 +62,15 @@

// callback stepper with nextTick delay
// nextQ to guarantee ordering
function next () {
var args = Array.prototype.slice.call(arguments)
nextQ.push(args)
process.nextTick(function () {
while (nextQ.length) {
step.apply(self, nextQ.shift())
}
})
if (!ticking) {
ticking = true
process.nextTick(function () {
ticking = false
step.apply(self, args)
})
} else {
// if another next() called during pausing,
// break iter and callback
iter = null
}
}

@@ -73,0 +77,0 @@

2

package.json
{
"name": "caco",
"version": "2.0.2",
"version": "2.0.3",
"description": "Generator based control flow that supports both callbacks and promises",

@@ -5,0 +5,0 @@ "scripts": {

@@ -41,3 +41,3 @@ # caco

return data
...
}).catch(function (err) {

@@ -44,0 +44,0 @@ // handle uncaught error

@@ -80,3 +80,3 @@ var test = require('tape')

test('yieldable', function (t) {
t.plan(4)
t.plan(6)

@@ -100,5 +100,12 @@ function * resolveGen (n) {

})
caco(function * (next) {
yield setTimeout(next, 0)
var o = yield Observable
var tryCatchNext = caco.wrap(function * (next) {
try {
return yield next(689)
} catch (err) {
t.equal(err, 689, 'try/catch next err')
return yield next(null, 167)
}
})
var observ = function () {
return Observable
.fromArray([1, 2])

@@ -108,5 +115,9 @@ .merge(Observable.fromPromise(Promise.resolve(3)))

.toArray()
t.deepEqual(o, [1, 2, 3], 'yield observable')
}
caco(function * (next) {
yield setTimeout(next, 0)
t.deepEqual(yield observ(), [1, 2, 3], 'yield observable')
t.equal(yield instantCb(next), 1044, 'yield callback')
t.equal(yield tryCatch(), 167, 'yield gnerator-promise')
t.equal(yield tryCatchNext(), 167, 'yield next val')
}).catch(t.error)

@@ -113,0 +124,0 @@ })

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