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 3.0.0 to 3.0.1

4

dist/caf.js
/*! caf.js
v3.0.0 (c) 2018 Kyle Simpson
v3.0.1 (c) 2018 Kyle Simpson
MIT License: http://getify.mit-license.org

@@ -108,3 +108,2 @@ */

return function instance(signal,...args){
var { it, success } = _runner.call(this,generatorFn,signal,...args);
var cancelation = signal.pr.catch(function onCancel(reason){

@@ -117,2 +116,3 @@ try {

});
var { it, success } = _runner.call(this,generatorFn,signal,...args);
var completion = Promise.race([ success, cancelation ]);

@@ -119,0 +119,0 @@ completion.catch(_=>1); // silence unhandled rejection warnings

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

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

@@ -35,3 +35,2 @@ (function UMD(name,context,definition){

return function instance(signal,...args){
var { it, success } = _runner.call(this,generatorFn,signal,...args);
var cancelation = signal.pr.catch(function onCancel(reason){

@@ -44,2 +43,3 @@ try {

});
var { it, success } = _runner.call(this,generatorFn,signal,...args);
var completion = Promise.race([ success, cancelation ]);

@@ -46,0 +46,0 @@ completion.catch(_=>1); // silence unhandled rejection warnings

@@ -209,11 +209,62 @@ "use strict";

assert.expect( 9 ); // note: 2 assertions + 7 `step(..)` calls
assert.verifySteps( rExpected, "canceled after during second 'secondary()' call" );
assert.verifySteps( rExpected, "canceled during second 'secondary()' call" );
assert.strictEqual( pActual, pExpected, "Quit!" );
} );
QUnit.test( "cancelation rejection ordering", async function test(assert){
function *main(signal,ms) {
signal.pr.catch(()=>assert.step("main:signal.pr.catch"));
assert.step("main: 1");
var pr = secondary(signal,ms);
pr.catch(()=>assert.step("main:pr.catch"));
yield pr;
assert.step("main: shouldn't happen");
}
function *secondary(signal,ms) {
signal.pr.catch(()=>assert.step("secondary:signal.pr.catch"));
assert.step(`secondary: 1`);
yield _delay(ms);
assert.step("secondary: shouldn't happen");
}
var token = new CAF.cancelToken();
var rExpected = [
"main: 1",
"secondary: 1",
"main:signal.pr.catch",
"secondary:signal.pr.catch",
"outer:pr.catch",
"main:pr.catch",
];
var pExpected = "Quit!";
main = CAF(main);
secondary = CAF(secondary);
setTimeout(function(){
token.abort("Quit!");
},30);
// rActual;
try {
var pr = main(token.signal,50);
pr.catch(()=>assert.step("outer:pr.catch"));
await pr;
}
catch (err) {
var pActual = err;
}
assert.expect( 8 ); // note: 2 assertions + 6 `step(..)` calls
assert.verifySteps( rExpected, "rejects in expected order" );
assert.strictEqual( pActual, pExpected, "Quit!" );
} );
function _delay(ms) {

@@ -220,0 +271,0 @@ return new Promise(res => setTimeout(res,ms));

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