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

fluture

Package Overview
Dependencies
Maintainers
1
Versions
109
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fluture - npm Package Compare versions

Comparing version 9.0.0 to 9.0.1

2

package.json
{
"name": "fluture",
"version": "9.0.0",
"version": "9.0.1",
"description": "FantasyLand compliant (monadic) alternative to Promises",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -1210,5 +1210,8 @@ # [![Fluture](logo.png)](#butterfly)

An advanced version of [fork](#fork) that allows us to recover from exceptions
that were thrown during the executation of the computation.
An advanced version of [fork](#fork) that allows us to recover in the event
that an error was `throw`n during the executation of the computation.
The recovery function will always be called with an instance of Error,
independent of what was thrown.
**Using this function is a trade-off;**

@@ -1229,3 +1232,4 @@

fut.forkCatch(console.error, console.error, console.log);
//! TypeError: Cannot read property 'foo' of null
//! Error: TypeError occurred while running a computation for a Future:
//! Cannot read property 'foo' of null
```

@@ -1761,2 +1765,3 @@

[SS]: https://github.com/sanctuary-js/sanctuary-show
[STI]: https://github.com/sanctuary-js/sanctuary-type-identifiers

@@ -1763,0 +1768,0 @@ [FST]: https://github.com/fluture-js/fluture-sanctuary-types

@@ -1,2 +0,2 @@

import {Core, isNever, never} from './core';
import {Future, never} from './core';
import {show, partial1} from './internal/fn';

@@ -7,9 +7,5 @@ import {isUnsigned} from './internal/is';

function After$race(other){
return other.isSettled()
? other
: isNever(other)
? this
: typeof other._time === 'number'
return typeof other._time === 'number'
? other._time < this._time ? other : this
: Core._race.call(this, other);
: Future.prototype._race.call(this, other);
}

@@ -22,3 +18,3 @@

After.prototype = Object.create(Core);
After.prototype = Object.create(Future.prototype);

@@ -49,3 +45,3 @@ After.prototype._race = After$race;

RejectAfter.prototype = Object.create(Core);
RejectAfter.prototype = Object.create(Future.prototype);

@@ -52,0 +48,0 @@ RejectAfter.prototype._race = After$race;

@@ -1,2 +0,2 @@

import {Core} from './core';
import {Future} from './core';
import {noop, showf} from './internal/fn';

@@ -10,3 +10,3 @@ import {isFunction} from './internal/is';

Attempt.prototype = Object.create(Core);
Attempt.prototype = Object.create(Future.prototype);

@@ -13,0 +13,0 @@ Attempt.prototype._interpret = function Attempt$interpret(rec, rej, res){

@@ -1,2 +0,2 @@

import {Core, isFuture} from './core';
import {Future, isFuture} from './core';
import {noop} from './internal/fn';

@@ -22,18 +22,10 @@ import {throwInvalidFuture} from './internal/throw';

Cached.prototype = Object.create(Core);
Cached.prototype = Object.create(Future.prototype);
Cached.prototype.isRejected = function Cached$isRejected(){
return this._state === Rejected;
};
Cached.prototype.isResolved = function Cached$isResolved(){
return this._state === Resolved;
};
Cached.prototype.extractLeft = function Cached$extractLeft(){
return this.isRejected() ? [this._value] : [];
return this._state === Rejected ? [this._value] : [];
};
Cached.prototype.extractRight = function Cached$extractRight(){
return this.isResolved() ? [this._value] : [];
return this._state === Resolved ? [this._value] : [];
};

@@ -40,0 +32,0 @@

@@ -1,2 +0,2 @@

import {Core} from './core';
import {Future} from './core';
import {Next, Done} from './internal/iteration';

@@ -11,3 +11,3 @@ import {Undetermined, Synchronous, Asynchronous} from './internal/timing';

ChainRec.prototype = Object.create(Core);
ChainRec.prototype = Object.create(Future.prototype);

@@ -14,0 +14,0 @@ ChainRec.prototype._interpret = function ChainRec$interpret(rec, rej, res){

@@ -144,3 +144,3 @@ import {show, showf, noop, moop, raise} from './internal/fn';

Future.prototype.forkCatch = function Future$fork(rec, rej, res){
Future.prototype.forkCatch = function Future$forkCatch(rec, rej, res){
if(!isFuture(this)) throwInvalidContext('Future#fork', this);

@@ -150,3 +150,3 @@ if(!isFunction(rec)) throwInvalidArgument('Future#fork', 0, 'to be a Function', rec);

if(!isFunction(res)) throwInvalidArgument('Future#fork', 2, 'to be a Function', res);
return this._interpret(rec, rej, res);
return this._interpret(function Future$forkCatch$recover(x){ rec(valueToError(x)) }, rej, res);
};

@@ -175,14 +175,2 @@

Future.prototype.isRejected = function Future$isRejected(){
return false;
};
Future.prototype.isResolved = function Future$isResolved(){
return false;
};
Future.prototype.isSettled = function Future$isSettled(){
return this.isRejected() || this.isResolved();
};
Future.prototype.extractLeft = function Future$extractLeft(){

@@ -196,58 +184,60 @@ return [];

export var Core = Object.create(Future.prototype);
Future.prototype._transform = function Future$transform(action){
return new Sequence(this, cons(action, nil));
};
Core._ap = function Core$ap(other){
return new Sequence(this)._ap(other);
Future.prototype._ap = function Future$ap(other){
return this._transform(new ApAction(other));
};
Core._parallelAp = function Core$parallelAp(other){
return new Sequence(this)._parallelAp(other);
Future.prototype._parallelAp = function Future$pap(other){
return this._transform(new ParallelApAction(other));
};
Core._map = function Core$map(mapper){
return new Sequence(this)._map(mapper);
Future.prototype._map = function Future$map(mapper){
return this._transform(new MapAction(mapper));
};
Core._bimap = function Core$bimap(lmapper, rmapper){
return new Sequence(this)._bimap(lmapper, rmapper);
Future.prototype._bimap = function Future$bimap(lmapper, rmapper){
return this._transform(new BimapAction(lmapper, rmapper));
};
Core._chain = function Core$chain(mapper){
return new Sequence(this)._chain(mapper);
Future.prototype._chain = function Future$chain(mapper){
return this._transform(new ChainAction(mapper));
};
Core._mapRej = function Core$mapRej(mapper){
return new Sequence(this)._mapRej(mapper);
Future.prototype._mapRej = function Future$mapRej(mapper){
return this._transform(new MapRejAction(mapper));
};
Core._chainRej = function Core$chainRej(mapper){
return new Sequence(this)._chainRej(mapper);
Future.prototype._chainRej = function Future$chainRej(mapper){
return this._transform(new ChainRejAction(mapper));
};
Core._race = function Core$race(other){
return new Sequence(this)._race(other);
Future.prototype._race = function Future$race(other){
return isNever(other) ? this : this._transform(new RaceAction(other));
};
Core._both = function Core$both(other){
return new Sequence(this)._both(other);
Future.prototype._both = function Future$both(other){
return this._transform(new BothAction(other));
};
Core._and = function Core$and(other){
return new Sequence(this)._and(other);
Future.prototype._and = function Future$and(other){
return this._transform(new AndAction(other));
};
Core._or = function Core$or(other){
return new Sequence(this)._or(other);
Future.prototype._or = function Future$or(other){
return this._transform(new OrAction(other));
};
Core._swap = function Core$swap(){
return new Sequence(this)._swap();
Future.prototype._swap = function Future$swap(){
return this._transform(new SwapAction);
};
Core._fold = function Core$fold(lmapper, rmapper){
return new Sequence(this)._fold(lmapper, rmapper);
Future.prototype._fold = function Future$fold(lmapper, rmapper){
return this._transform(new FoldAction(lmapper, rmapper));
};
Core._finally = function Core$finally(other){
return new Sequence(this)._finally(other);
Future.prototype._finally = function Future$finally(other){
return this._transform(new FinallyAction(other));
};

@@ -259,3 +249,3 @@

Computation.prototype = Object.create(Core);
Computation.prototype = Object.create(Future.prototype);

@@ -306,2 +296,27 @@ Computation.prototype._interpret = function Computation$interpret(rec, rej, res){

export function Crashed(error){
this._error = error;
}
Crashed.prototype = Object.create(Future.prototype);
Crashed.prototype._ap = moop;
Crashed.prototype._parallelAp = moop;
Crashed.prototype._map = moop;
Crashed.prototype._bimap = moop;
Crashed.prototype._chain = moop;
Crashed.prototype._mapRej = moop;
Crashed.prototype._chainRej = moop;
Crashed.prototype._both = moop;
Crashed.prototype._or = moop;
Crashed.prototype._swap = moop;
Crashed.prototype._fold = moop;
Crashed.prototype._finally = moop;
Crashed.prototype._race = moop;
Crashed.prototype._interpret = function Crashed$interpret(rec){
rec(this._error);
return noop;
};
export function Rejected(value){

@@ -311,3 +326,3 @@ this._value = value;

Rejected.prototype = Object.create(Core);
Rejected.prototype = Object.create(Future.prototype);

@@ -339,6 +354,2 @@ Rejected.prototype._ap = moop;

Rejected.prototype.isRejected = function Rejected$isRejected(){
return true;
};
Rejected.prototype.extractLeft = function Rejected$extractLeft(){

@@ -360,3 +371,3 @@ return [this._value];

Resolved.prototype = Object.create(Core);
Resolved.prototype = Object.create(Future.prototype);

@@ -394,6 +405,2 @@ Resolved.prototype._race = moop;

Resolved.prototype.isResolved = function Resolved$isResolved(){
return true;
};
Resolved.prototype.extractRight = function Resolved$extractRight(){

@@ -448,27 +455,2 @@ return [this._value];

export function Crashed(error){
this._error = error;
}
Crashed.prototype = Object.create(Future.prototype);
Crashed.prototype._ap = moop;
Crashed.prototype._parallelAp = moop;
Crashed.prototype._map = moop;
Crashed.prototype._bimap = moop;
Crashed.prototype._chain = moop;
Crashed.prototype._mapRej = moop;
Crashed.prototype._chainRej = moop;
Crashed.prototype._both = moop;
Crashed.prototype._or = moop;
Crashed.prototype._swap = moop;
Crashed.prototype._fold = moop;
Crashed.prototype._finally = moop;
Crashed.prototype._race = moop;
Crashed.prototype._interpret = function Crashed$interpret(rec){
rec(this._error);
return noop;
};
function Eager(future){

@@ -501,3 +483,3 @@ var _this = this;

Eager.prototype = Object.create(Core);
Eager.prototype = Object.create(Future.prototype);

@@ -710,3 +692,3 @@ Eager.prototype._interpret = function Eager$interpret(rec, rej, res){

RaceAction.prototype.run = function RaceAction$run(early){
return new RaceActionState(early, new Eager(this.other));
return new RaceActionState(early, this.other);
};

@@ -726,3 +708,3 @@

BothAction.prototype.run = function BothAction$run(early){
return new BothActionState(early, new Eager(this.other));
return new BothActionState(early, this.other);
};

@@ -737,3 +719,3 @@

_this.other = new Eager(other);
_this.cancel = this.other._interpret(
_this.cancel = _this.other._interpret(
function ParallelApActionState$rec(x){ early(new Crashed(x), _this) },

@@ -749,4 +731,4 @@ function ParallelApActionState$rej(x){ early(new Rejected(x), _this) },

var _this = this;
_this.other = other;
_this.cancel = other._interpret(
_this.other = new Eager(other);
_this.cancel = _this.other._interpret(
function RaceActionState$rec(x){ early(new Crashed(x), _this) },

@@ -762,4 +744,4 @@ function RaceActionState$rej(x){ early(new Rejected(x), _this) },

var _this = this;
_this.other = other;
_this.cancel = other._interpret(
_this.other = new Eager(other);
_this.cancel = _this.other._interpret(
function BothActionState$rec(x){ early(new Crashed(x), _this) },

@@ -775,3 +757,3 @@ function BothActionState$rej(x){ early(new Rejected(x), _this) },

this._spawn = spawn;
this._actions = actions || nil;
this._actions = actions;
}

@@ -785,58 +767,2 @@

Sequence.prototype._ap = function Sequence$ap(other){
return this._transform(new ApAction(other));
};
Sequence.prototype._parallelAp = function Sequence$pap(other){
return this._transform(new ParallelApAction(other));
};
Sequence.prototype._map = function Sequence$map(mapper){
return this._transform(new MapAction(mapper));
};
Sequence.prototype._bimap = function Sequence$bimap(lmapper, rmapper){
return this._transform(new BimapAction(lmapper, rmapper));
};
Sequence.prototype._chain = function Sequence$chain(mapper){
return this._transform(new ChainAction(mapper));
};
Sequence.prototype._mapRej = function Sequence$mapRej(mapper){
return this._transform(new MapRejAction(mapper));
};
Sequence.prototype._chainRej = function Sequence$chainRej(mapper){
return this._transform(new ChainRejAction(mapper));
};
Sequence.prototype._race = function Sequence$race(other){
return isNever(other) ? this : this._transform(new RaceAction(other));
};
Sequence.prototype._both = function Sequence$both(other){
return this._transform(new BothAction(other));
};
Sequence.prototype._and = function Sequence$and(other){
return this._transform(new AndAction(other));
};
Sequence.prototype._or = function Sequence$or(other){
return this._transform(new OrAction(other));
};
Sequence.prototype._swap = function Sequence$swap(){
return this._transform(new SwapAction);
};
Sequence.prototype._fold = function Sequence$fold(lmapper, rmapper){
return this._transform(new FoldAction(lmapper, rmapper));
};
Sequence.prototype._finally = function Sequence$finally(other){
return this._transform(new FinallyAction(other));
};
Sequence.prototype._interpret = function Sequence$interpret(rec, rej, res){

@@ -843,0 +769,0 @@ return interpret(this, rec, rej, res);

@@ -5,2 +5,3 @@ import {isFuture} from '../core';

import {throwInvalidArgument, throwInvalidFuture} from '../internal/throw';
import {valueToError} from '../internal/error';

@@ -15,3 +16,3 @@ export function forkCatch(f, g, h, m){

if(!isFuture(m)) throwInvalidFuture('Future.forkCatch', 3, m);
return m._interpret(f, g, h);
return m._interpret(function forkCatch$recover(x){ f(valueToError(x)) }, g, h);
}

@@ -1,2 +0,2 @@

import {Core} from './core';
import {Future} from './core';
import {show, showf, partial1, noop} from './internal/fn';

@@ -11,3 +11,3 @@ import {isFunction} from './internal/is';

EncaseN.prototype = Object.create(Core);
EncaseN.prototype = Object.create(Future.prototype);

@@ -14,0 +14,0 @@ EncaseN.prototype._interpret = function EncaseN$interpret(rec, rej, res){

@@ -1,2 +0,2 @@

import {Core} from './core';
import {Future} from './core';
import {show, showf, partial1, partial2, noop} from './internal/fn';

@@ -12,3 +12,3 @@ import {isFunction} from './internal/is';

EncaseN2.prototype = Object.create(Core);
EncaseN2.prototype = Object.create(Future.prototype);

@@ -15,0 +15,0 @@ EncaseN2.prototype._interpret = function EncaseN2$interpret(rec, rej, res){

@@ -1,2 +0,2 @@

import {Core} from './core';
import {Future} from './core';
import {show, showf, partial1, partial2, partial3, noop} from './internal/fn';

@@ -13,3 +13,3 @@ import {isFunction} from './internal/is';

EncaseN3.prototype = Object.create(Core);
EncaseN3.prototype = Object.create(Future.prototype);

@@ -16,0 +16,0 @@ EncaseN3.prototype._interpret = function EncaseN3$interpret(rec, rej, res){

@@ -1,2 +0,2 @@

import {Core} from './core';
import {Future} from './core';
import {noop, show, showf, partial1} from './internal/fn';

@@ -20,3 +20,3 @@ import {isThenable, isFunction} from './internal/is';

EncaseP.prototype = Object.create(Core);
EncaseP.prototype = Object.create(Future.prototype);

@@ -23,0 +23,0 @@ EncaseP.prototype._interpret = function EncaseP$interpret(rec, rej, res){

@@ -1,2 +0,2 @@

import {Core} from './core';
import {Future} from './core';
import {noop, show, showf, partial1, partial2} from './internal/fn';

@@ -22,3 +22,3 @@ import {isThenable, isFunction} from './internal/is';

EncaseP2.prototype = Object.create(Core);
EncaseP2.prototype = Object.create(Future.prototype);

@@ -25,0 +25,0 @@ EncaseP2.prototype._interpret = function EncaseP2$interpret(rec, rej, res){

@@ -1,2 +0,2 @@

import {Core} from './core';
import {Future} from './core';
import {noop, show, showf, partial1, partial2, partial3} from './internal/fn';

@@ -24,3 +24,3 @@ import {isThenable, isFunction} from './internal/is';

EncaseP3.prototype = Object.create(Core);
EncaseP3.prototype = Object.create(Future.prototype);

@@ -27,0 +27,0 @@ EncaseP3.prototype._interpret = function EncaseP3$interpret(rec, rej, res){

@@ -1,2 +0,2 @@

import {Core} from './core';
import {Future} from './core';
import {noop, show, showf, partial1} from './internal/fn';

@@ -11,3 +11,3 @@ import {isFunction} from './internal/is';

Encase.prototype = Object.create(Core);
Encase.prototype = Object.create(Future.prototype);

@@ -14,0 +14,0 @@ Encase.prototype._interpret = function Encase$interpret(rec, rej, res){

@@ -1,2 +0,2 @@

import {Core} from './core';
import {Future} from './core';
import {noop, show, showf, partial1, partial2} from './internal/fn';

@@ -12,3 +12,3 @@ import {isFunction} from './internal/is';

Encase2.prototype = Object.create(Core);
Encase2.prototype = Object.create(Future.prototype);

@@ -15,0 +15,0 @@ Encase2.prototype._interpret = function Encase2$interpret(rec, rej, res){

@@ -1,2 +0,2 @@

import {Core} from './core';
import {Future} from './core';
import {noop, show, showf, partial1, partial2, partial3} from './internal/fn';

@@ -13,3 +13,3 @@ import {isFunction} from './internal/is';

Encase3.prototype = Object.create(Core);
Encase3.prototype = Object.create(Future.prototype);

@@ -16,0 +16,0 @@ Encase3.prototype._interpret = function Encase3$interpret(rec, rej, res){

/*eslint consistent-return: 0, no-cond-assign: 0*/
import {Core, isFuture} from './core';
import {Future, isFuture} from './core';
import {isFunction, isIterator} from './internal/is';

@@ -31,3 +31,3 @@ import {isIteration} from './internal/iteration';

Go.prototype = Object.create(Core);
Go.prototype = Object.create(Future.prototype);

@@ -34,0 +34,0 @@ Go.prototype._interpret = function Go$interpret(rec, rej, res){

/* eslint no-param-reassign:0 */
import {Core, isFuture} from './core';
import {Future, isFuture} from './core';
import {noop, show, showf, partial1, partial2} from './internal/fn';

@@ -33,3 +33,3 @@ import {isFunction} from './internal/is';

Hook.prototype = Object.create(Core);
Hook.prototype = Object.create(Future.prototype);

@@ -36,0 +36,0 @@ Hook.prototype._interpret = function Hook$interpret(rec, rej, res){

@@ -1,2 +0,2 @@

import {Core} from './core';
import {Future} from './core';
import {showf, noop} from './internal/fn';

@@ -10,3 +10,3 @@ import {isFunction} from './internal/is';

Node.prototype = Object.create(Core);
Node.prototype = Object.create(Future.prototype);

@@ -13,0 +13,0 @@ Node.prototype._interpret = function Node$interpret(rec, rej, res){

@@ -1,2 +0,2 @@

import {Core, Resolved, isFuture} from './core';
import {Future, Resolved, isFuture} from './core';
import {throwInvalidFuture, throwInvalidArgument} from './internal/throw';

@@ -12,3 +12,3 @@ import {noop, show, partial1} from './internal/fn';

Parallel.prototype = Object.create(Core);
Parallel.prototype = Object.create(Future.prototype);

@@ -15,0 +15,0 @@ Parallel.prototype._interpret = function Parallel$interpret(rec, rej, res){

@@ -1,2 +0,2 @@

import {Core} from './core';
import {Future} from './core';
import {noop, show, showf} from './internal/fn';

@@ -18,3 +18,3 @@ import {isThenable, isFunction} from './internal/is';

TryP.prototype = Object.create(Core);
TryP.prototype = Object.create(Future.prototype);

@@ -21,0 +21,0 @@ TryP.prototype._interpret = function TryP$interpret(rec, rej, res){

Sorry, the diff of this file is too big to display

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