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

async-caf

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

async-caf - npm Package Compare versions

Comparing version 1.0.3 to 1.1.0

18

dist/caf.js
/*! caf.js
v1.0.3 (c) 2018 Kyle Simpson
v1.1.0 (c) 2018 Kyle Simpson
MIT License: http://getify.mit-license.org

@@ -29,10 +29,10 @@ */

});
var { it, pr } = _runner(generatorFn,cancelToken,...args);
var { it, pr } = _runner.call(this,generatorFn,cancelToken,...args);
cancelToken.listen(function onCancel(reason){
try { var ret = it.return(); } catch (err) {}
trigger(ret.value != undefined ? ret.value : reason);
trigger(ret.value !== undefined ? ret.value : reason);
it = pr = trigger = null;
});
var race = Promise.race([ pr, canceled ]);
race.catch(_ => 1); // prevent unhandled rejection warnings
race.catch(_=>1); // silence unhandled rejection warnings
return race;

@@ -71,3 +71,3 @@ };

// initialize the generator in the current context
var it = gen.apply( this, args );
var it = gen.apply(this,args);

@@ -80,3 +80,3 @@ // return a promise for the generator completing

// run to the next yielded value
var next = it.next( value );
var next = it.next(value);

@@ -90,3 +90,3 @@ return (function handleResult(next){

else {
return Promise.resolve( next.value )
return Promise.resolve(next.value)
.then(

@@ -104,5 +104,5 @@ // resume the async loop on

return Promise.resolve(
it.throw( err )
it.throw(err)
)
.then( handleResult );
.then(handleResult);
}

@@ -109,0 +109,0 @@ );

{
"name": "async-caf",
"version": "1.0.3",
"version": "1.1.0",
"description": "Wrapper for generators as cancelable async functions",

@@ -5,0 +5,0 @@ "main": "./dist/caf.js",

@@ -24,10 +24,10 @@ (function UMD(name,context,definition){

});
var { it, pr } = _runner(generatorFn,cancelToken,...args);
var { it, pr } = _runner.call(this,generatorFn,cancelToken,...args);
cancelToken.listen(function onCancel(reason){
try { var ret = it.return(); } catch (err) {}
trigger(ret.value != undefined ? ret.value : reason);
trigger(ret.value !== undefined ? ret.value : reason);
it = pr = trigger = null;
});
var race = Promise.race([ pr, canceled ]);
race.catch(_ => 1); // prevent unhandled rejection warnings
race.catch(_=>1); // silence unhandled rejection warnings
return race;

@@ -66,3 +66,3 @@ };

// initialize the generator in the current context
var it = gen.apply( this, args );
var it = gen.apply(this,args);

@@ -75,3 +75,3 @@ // return a promise for the generator completing

// run to the next yielded value
var next = it.next( value );
var next = it.next(value);

@@ -85,3 +85,3 @@ return (function handleResult(next){

else {
return Promise.resolve( next.value )
return Promise.resolve(next.value)
.then(

@@ -99,5 +99,5 @@ // resume the async loop on

return Promise.resolve(
it.throw( err )
it.throw(err)
)
.then( handleResult );
.then(handleResult);
}

@@ -104,0 +104,0 @@ );

@@ -39,4 +39,5 @@ "use strict";

QUnit.test( "CAF() + parameters + return", async function test(assert){
QUnit.test( "CAF() + this + parameters + return", async function test(assert){
function *checkParameters(cancelToken,a,b,...args) {
assert.step(this.x);
assert.step(String(cancelToken === token));

@@ -50,4 +51,6 @@ assert.step(a);

var token = new CAF.cancelToken();
var obj = { x: "obj.x" };
var rExpected = [
"obj.x",
"true",

@@ -64,7 +67,7 @@ "3",

// rActual;
var pActual = asyncFn(token,"3","12");
var pActual = asyncFn.call(obj,token,"3","12");
var qActual = await pActual;
pActual = pActual.toString();
assert.expect( 8 ); // note: 3 assertions + 4 `step(..)` calls
assert.expect( 9 ); // note: 4 assertions + 5 `step(..)` calls
assert.ok( _isFunction( asyncFn ), "asyncFn()" );

@@ -71,0 +74,0 @@ assert.verifySteps( rExpected, "check arguments to generator" );

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