Skip to content

Commit a3d4133

Browse files
committed
Release 11.0.0
- Disposal Futures provided to `hook` are no longer allowed to reject. When they do, an Error is raised, and the process should be treated as corrupt. - Add TypeScript definitions for `debugMode` and `Future.alt`.
1 parent 694a73c commit a3d4133

File tree

3 files changed

+61
-57
lines changed

3 files changed

+61
-57
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ getPackageName('package.json')
9494
### Global Bundle (CDN)
9595

9696
Fluture is hosted in full with all of its dependencies at
97-
https://cdn.jsdelivr.net/gh/fluture-js/Fluture@10.3.1/dist/bundle.js
97+
https://cdn.jsdelivr.net/gh/fluture-js/Fluture@11.0.0/dist/bundle.js
9898

9999
This script will add `Fluture` to the global scope.
100100

dist/bundle.js

+59-55
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Fluture bundled; version 10.3.1
2+
* Fluture bundled; version 11.0.0
33
*/
44

55
var Fluture = (function () {
@@ -1177,9 +1177,9 @@ var Fluture = (function () {
11771177
Sequence$cancel();
11781178
settled = true;
11791179
cold = hot = nil;
1180-
var error$$1 = makeError(e, future, context);
1180+
var error = makeError(e, future, context);
11811181
future = never;
1182-
rec(error$$1);
1182+
rec(error);
11831183
}
11841184

11851185
//This function serves to kickstart concurrent computations.
@@ -1366,27 +1366,27 @@ var Fluture = (function () {
13661366
cancel: noop
13671367
};
13681368

1369-
function captureActionContext(name$$1, fn){
1370-
return captureContext(nil, 'a Future transformed with ' + name$$1, fn);
1369+
function captureActionContext(name, fn){
1370+
return captureContext(nil, 'a Future transformed with ' + name, fn);
13711371
}
13721372

13731373
function nullaryActionToString(){
13741374
return this.name + '()';
13751375
}
13761376

1377-
function defineNullaryAction(name$$1, prototype){
1378-
var _name = '_' + name$$1;
1377+
function defineNullaryAction(name, prototype){
1378+
var _name = '_' + name;
13791379
function NullaryAction(context){ this.context = context; }
13801380
NullaryAction.prototype = Object.assign(Object.create(Action), prototype);
1381-
NullaryAction.prototype.name = name$$1;
1381+
NullaryAction.prototype.name = name;
13821382
NullaryAction.prototype.toString = nullaryActionToString;
1383-
Future.prototype[name$$1] = function checkedNullaryTransformation(){
1384-
if(!isFuture(this)) throwInvalidContext('Future#' + name$$1, this);
1383+
Future.prototype[name] = function checkedNullaryTransformation(){
1384+
if(!isFuture(this)) throwInvalidContext('Future#' + name, this);
13851385
return this[_name]();
13861386
};
13871387
Future.prototype[_name] = function uncheckedNullaryTransformation(){
13881388
return this._transform(new NullaryAction(
1389-
captureActionContext(name$$1, uncheckedNullaryTransformation)
1389+
captureActionContext(name, uncheckedNullaryTransformation)
13901390
));
13911391
};
13921392
return NullaryAction;
@@ -1396,21 +1396,21 @@ var Fluture = (function () {
13961396
return this.name + '(' + showf(this.mapper) + ')';
13971397
}
13981398

1399-
function defineMapperAction(name$$1, prototype){
1400-
var _name = '_' + name$$1;
1399+
function defineMapperAction(name, prototype){
1400+
var _name = '_' + name;
14011401
function MapperAction(mapper, context){ this.mapper = mapper; this.context = context; }
14021402
MapperAction.prototype = Object.assign(Object.create(Action), prototype);
1403-
MapperAction.prototype.name = name$$1;
1403+
MapperAction.prototype.name = name;
14041404
MapperAction.prototype.toString = mapperActionToString;
1405-
Future.prototype[name$$1] = function checkedMapperTransformation(mapper){
1406-
if(!isFuture(this)) throwInvalidContext('Future#' + name$$1, this);
1407-
if(!isFunction(mapper)) throwInvalidArgument('Future#' + name$$1, 0, 'be a Function', mapper);
1405+
Future.prototype[name] = function checkedMapperTransformation(mapper){
1406+
if(!isFuture(this)) throwInvalidContext('Future#' + name, this);
1407+
if(!isFunction(mapper)) throwInvalidArgument('Future#' + name, 0, 'be a Function', mapper);
14081408
return this[_name](mapper);
14091409
};
14101410
Future.prototype[_name] = function uncheckedMapperTransformation(mapper){
14111411
return this._transform(new MapperAction(
14121412
mapper,
1413-
captureActionContext(name$$1, uncheckedMapperTransformation)
1413+
captureActionContext(name, uncheckedMapperTransformation)
14141414
));
14151415
};
14161416
return MapperAction;
@@ -1420,27 +1420,27 @@ var Fluture = (function () {
14201420
return this.name + '(' + showf(this.lmapper) + ', ' + showf(this.rmapper) + ')';
14211421
}
14221422

1423-
function defineBimapperAction(name$$1, prototype){
1424-
var _name = '_' + name$$1;
1423+
function defineBimapperAction(name, prototype){
1424+
var _name = '_' + name;
14251425
function BimapperAction(lmapper, rmapper, context){
14261426
this.lmapper = lmapper;
14271427
this.rmapper = rmapper;
14281428
this.context = context;
14291429
}
14301430
BimapperAction.prototype = Object.assign(Object.create(Action), prototype);
1431-
BimapperAction.prototype.name = name$$1;
1431+
BimapperAction.prototype.name = name;
14321432
BimapperAction.prototype.toString = bimapperActionToString;
1433-
Future.prototype[name$$1] = function checkedBimapperTransformation(lm, rm){
1434-
if(!isFuture(this)) throwInvalidContext('Future#' + name$$1, this);
1435-
if(!isFunction(lm)) throwInvalidArgument('Future#' + name$$1, 0, 'be a Function', lm);
1436-
if(!isFunction(rm)) throwInvalidArgument('Future#' + name$$1, 1, 'be a Function', rm);
1433+
Future.prototype[name] = function checkedBimapperTransformation(lm, rm){
1434+
if(!isFuture(this)) throwInvalidContext('Future#' + name, this);
1435+
if(!isFunction(lm)) throwInvalidArgument('Future#' + name, 0, 'be a Function', lm);
1436+
if(!isFunction(rm)) throwInvalidArgument('Future#' + name, 1, 'be a Function', rm);
14371437
return this[_name](lm, rm);
14381438
};
14391439
Future.prototype[_name] = function uncheckedBimapperTransformation(lmapper, rmapper){
14401440
return this._transform(new BimapperAction(
14411441
lmapper,
14421442
rmapper,
1443-
captureActionContext(name$$1, uncheckedBimapperTransformation)
1443+
captureActionContext(name, uncheckedBimapperTransformation)
14441444
));
14451445
};
14461446
return BimapperAction;
@@ -1450,35 +1450,35 @@ var Fluture = (function () {
14501450
return this.name + '(' + this.other.toString() + ')';
14511451
}
14521452

1453-
function defineOtherAction(name$$1, prototype){
1454-
var _name = '_' + name$$1;
1453+
function defineOtherAction(name, prototype){
1454+
var _name = '_' + name;
14551455
function OtherAction(other, context){ this.other = other; this.context = context; }
14561456
OtherAction.prototype = Object.assign(Object.create(Action), prototype);
1457-
OtherAction.prototype.name = name$$1;
1457+
OtherAction.prototype.name = name;
14581458
OtherAction.prototype.toString = otherActionToString;
1459-
Future.prototype[name$$1] = function checkedOtherTransformation(other){
1460-
if(!isFuture(this)) throwInvalidContext('Future#' + name$$1, this);
1461-
if(!isFuture(other)) throwInvalidFuture('Future#' + name$$1, 0, other);
1459+
Future.prototype[name] = function checkedOtherTransformation(other){
1460+
if(!isFuture(this)) throwInvalidContext('Future#' + name, this);
1461+
if(!isFuture(other)) throwInvalidFuture('Future#' + name, 0, other);
14621462
return this[_name](other);
14631463
};
14641464
Future.prototype[_name] = function uncheckedOtherTransformation(other){
14651465
return this._transform(new OtherAction(
14661466
other,
1467-
captureActionContext(name$$1, uncheckedOtherTransformation)
1467+
captureActionContext(name, uncheckedOtherTransformation)
14681468
));
14691469
};
14701470
return OtherAction;
14711471
}
14721472

1473-
function defineParallelAction(name$$1, rec, rej, res, prototype){
1474-
var ParallelAction = defineOtherAction(name$$1, prototype);
1473+
function defineParallelAction(name, rec, rej, res, prototype){
1474+
var ParallelAction = defineOtherAction(name, prototype);
14751475
ParallelAction.prototype.run = function ParallelAction$run(early){
14761476
var eager = new Eager(this.other);
14771477
var action = new ParallelAction(eager);
14781478
function ParallelAction$early(m){ early(m, action); }
14791479
action.context = captureContext(
14801480
this.context,
1481-
name$$1 + ' triggering a parallel Future',
1481+
name + ' triggering a parallel Future',
14821482
ParallelAction$run
14831483
);
14841484
action.cancel = eager._interpret(
@@ -2620,21 +2620,7 @@ var Fluture = (function () {
26202620
cont(value);
26212621
}
26222622

2623-
function Hook$reject(x){
2624-
rej(x);
2625-
}
2626-
2627-
function Hook$consumptionException(report){
2628-
var rec_ = rec;
2629-
cont = noop;
2630-
rej = noop;
2631-
rec = noop;
2632-
Hook$dispose();
2633-
rec_(report);
2634-
}
2635-
26362623
function Hook$dispose(){
2637-
context = captureContext(context, 'hook consuming a resource', Hook$dispose);
26382624
var disposal;
26392625
try{
26402626
disposal = _dispose(resource);
@@ -2644,7 +2630,7 @@ var Fluture = (function () {
26442630
if(!isFuture(disposal)){
26452631
return rec(makeError(invalidDisposal(disposal, _dispose, resource), _this, context));
26462632
}
2647-
disposal._interpret(rec, Hook$reject, Hook$done);
2633+
disposal._interpret(Hook$disposalCrashed, Hook$disposalRejected, Hook$done);
26482634
cancel = Hook$cancelDisposal;
26492635
}
26502636

@@ -2656,17 +2642,32 @@ var Fluture = (function () {
26562642

26572643
function Hook$cancelDisposal(){
26582644
cont = noop;
2659-
rec = noop;
2660-
rej = noop;
2645+
}
2646+
2647+
function Hook$disposalCrashed(x){
2648+
rec(makeError(x, _this, context));
2649+
}
2650+
2651+
function Hook$disposalRejected(x){
2652+
rec(makeError(new Error('The disposal Future rejected with ' + sanctuaryShow(x)), _this, context));
2653+
}
2654+
2655+
function Hook$consumptionException(x){
2656+
context = captureContext(context, 'resource consumption crashing', Hook$dispose);
2657+
cont = rec;
2658+
value = x;
2659+
Hook$dispose();
26612660
}
26622661

26632662
function Hook$consumptionRejected(x){
2663+
context = captureContext(context, 'resource consumption failing', Hook$consumptionRejected);
26642664
cont = rej;
26652665
value = x;
26662666
Hook$dispose();
26672667
}
26682668

26692669
function Hook$consumptionResolved(x){
2670+
context = captureContext(context, 'resource consumption', Hook$consumptionResolved);
26702671
cont = res;
26712672
value = x;
26722673
Hook$dispose();
@@ -2696,10 +2697,13 @@ var Fluture = (function () {
26962697
);
26972698
}
26982699

2699-
var cancelAcquire = _acquire._interpret(rec, Hook$reject, Hook$consume);
2700+
var cancelAcquire = _acquire._interpret(rec, rej, Hook$consume);
27002701
cancel = cancel || cancelAcquire;
27012702

2702-
return function Hook$fork$cancel(){ cancel(); };
2703+
return function Hook$fork$cancel(){
2704+
rec = raise;
2705+
cancel();
2706+
};
27032707

27042708
};
27052709

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "fluture",
3-
"version": "10.3.1",
3+
"version": "11.0.0",
44
"description": "FantasyLand compliant (monadic) alternative to Promises",
55
"main": "index",
66
"types": "index.d.ts",

0 commit comments

Comments
 (0)