effection
Advanced tools
Comparing version 0.3.3-c1a4d52 to 0.3.3-c7a78a7
@@ -307,3 +307,2 @@ 'use strict'; | ||
fork(operation, sync = false) { | ||
// console.log(`parent.fork(${operation}, ${sync})`); | ||
let child = new Fork(operation, this, sync); | ||
@@ -362,5 +361,16 @@ this.children.add(child); | ||
thunk(fn) { | ||
let next; | ||
let previouslyExecuting = Fork.currentlyExecuting; | ||
try { | ||
let next = this.enter(fn); | ||
Fork.currentlyExecuting = this; | ||
this.exitPrevious(); | ||
try { | ||
next = fn(this.iterator); | ||
} catch (error) { | ||
this.finalize('errored', error); | ||
return; | ||
} | ||
if (next.done) { | ||
@@ -378,14 +388,2 @@ if (this.hasBlockingChildren) { | ||
} | ||
} catch (error) { | ||
this.finalize('errored', error); | ||
} | ||
} | ||
enter(fn) { | ||
let previouslyExecuting = Fork.currentlyExecuting; | ||
try { | ||
Fork.currentlyExecuting = this; | ||
this.exitPrevious(); | ||
return fn(this.iterator); | ||
} finally { | ||
@@ -411,2 +409,10 @@ Fork.currentlyExecuting = previouslyExecuting; | ||
get root() { | ||
if (this.parent) { | ||
return this.parent.root; | ||
} else { | ||
return this; | ||
} | ||
} | ||
} | ||
@@ -413,0 +419,0 @@ |
@@ -131,3 +131,2 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
fork(operation, sync = false) { | ||
// console.log(`parent.fork(${operation}, ${sync})`); | ||
let child = new Fork(operation, this, sync); | ||
@@ -186,5 +185,16 @@ this.children.add(child); | ||
thunk(fn) { | ||
let next; | ||
let previouslyExecuting = Fork.currentlyExecuting; | ||
try { | ||
let next = this.enter(fn); | ||
Fork.currentlyExecuting = this; | ||
this.exitPrevious(); | ||
try { | ||
next = fn(this.iterator); | ||
} catch (error) { | ||
this.finalize('errored', error); | ||
return; | ||
} | ||
if (next.done) { | ||
@@ -202,14 +212,2 @@ if (this.hasBlockingChildren) { | ||
} | ||
} catch (error) { | ||
this.finalize('errored', error); | ||
} | ||
} | ||
enter(fn) { | ||
let previouslyExecuting = Fork.currentlyExecuting; | ||
try { | ||
Fork.currentlyExecuting = this; | ||
this.exitPrevious(); | ||
return fn(this.iterator); | ||
} finally { | ||
@@ -235,2 +233,10 @@ Fork.currentlyExecuting = previouslyExecuting; | ||
get root() { | ||
if (this.parent) { | ||
return this.parent.root; | ||
} else { | ||
return this; | ||
} | ||
} | ||
} | ||
@@ -237,0 +243,0 @@ |
@@ -274,3 +274,2 @@ /** | ||
let sync = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; | ||
// console.log(`parent.fork(${operation}, ${sync})`); | ||
let child = new Fork(operation, this, sync); | ||
@@ -315,5 +314,16 @@ this.children.add(child); | ||
thunk(fn) { | ||
let next; | ||
let previouslyExecuting = Fork.currentlyExecuting; | ||
try { | ||
let next = this.enter(fn); | ||
Fork.currentlyExecuting = this; | ||
this.exitPrevious(); | ||
try { | ||
next = fn(this.iterator); | ||
} catch (error) { | ||
this.finalize('errored', error); | ||
return; | ||
} | ||
if (next.done) { | ||
@@ -331,14 +341,2 @@ if (this.hasBlockingChildren) { | ||
} | ||
} catch (error) { | ||
this.finalize('errored', error); | ||
} | ||
} | ||
enter(fn) { | ||
let previouslyExecuting = Fork.currentlyExecuting; | ||
try { | ||
Fork.currentlyExecuting = this; | ||
this.exitPrevious(); | ||
return fn(this.iterator); | ||
} finally { | ||
@@ -364,2 +362,10 @@ Fork.currentlyExecuting = previouslyExecuting; | ||
get root() { | ||
if (this.parent) { | ||
return this.parent.root; | ||
} else { | ||
return this; | ||
} | ||
} | ||
} | ||
@@ -366,0 +372,0 @@ |
{ | ||
"name": "effection", | ||
"description": "Effortlessly composable structured concurrency primitive for JavaScript", | ||
"version": "0.3.3-c1a4d52", | ||
"version": "0.3.3-c7a78a7", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "files": [ |
40065
1056