New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@devexperts/remote-data-ts

Package Overview
Dependencies
Maintainers
6
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@devexperts/remote-data-ts - npm Package Compare versions

Comparing version 0.4.2 to 0.5.0

15

CHANGELOG.md

@@ -0,1 +1,16 @@

<a name="0.5.0"></a>
# [0.5.0](https://github.com/devex-web-frontend/remote-data-ts/compare/v0.4.2...v0.5.0) (2019-01-31)
### Features
* major update - Fail fast ap, TS/fp-ts/io-ts upgrade, Traversable2v, Bifunctor ([#28](https://github.com/devex-web-frontend/remote-data-ts/issues/28)) ([3955c17](https://github.com/devex-web-frontend/remote-data-ts/commit/3955c17)), closes [#26](https://github.com/devex-web-frontend/remote-data-ts/issues/26)
### BREAKING CHANGES
* new status priority, new dependencies, see #28 for more info
<a name="0.4.2"></a>

@@ -2,0 +17,0 @@ ## [0.4.2](https://github.com/devex-web-frontend/remote-data-ts/compare/v0.4.1...v0.4.2) (2018-11-20)

99

dist/__tests__/remote-data.spec.js

@@ -6,3 +6,2 @@ "use strict";

var function_1 = require("fp-ts/lib/function");
var Traversable_1 = require("fp-ts/lib/Traversable");
var Option_1 = require("fp-ts/lib/Option");

@@ -117,3 +116,3 @@ var Array_1 = require("fp-ts/lib/Array");

expect(initialRD.ap(progressRD)).toBe(initialRD);
expect(initialRD.ap(failedF)).toBe(initialRD);
expect(initialRD.ap(failedF)).toBe(failedF);
expect(initialRD.ap(f)).toBe(initialRD);

@@ -125,9 +124,9 @@ });

expect(pendingRD.ap(progressRD)).toBe(progressRD);
expect(pendingRD.ap(failedF)).toBe(pendingRD);
expect(pendingRD.ap(failedF)).toBe(failedF);
expect(pendingRD.ap(f)).toBe(pendingRD);
});
it('failure', function () {
expect(failureRD.ap(remote_data_1.initial)).toBe(remote_data_1.initial);
expect(failureRD.ap(remote_data_1.pending)).toBe(remote_data_1.pending);
expect(failureRD.ap(progressRD)).toBe(progressRD);
expect(failureRD.ap(remote_data_1.initial)).toBe(failureRD);
expect(failureRD.ap(remote_data_1.pending)).toBe(failureRD);
expect(failureRD.ap(progressRD)).toBe(failureRD);
expect(failureRD.ap(failedF)).toBe(failedF);

@@ -147,3 +146,3 @@ expect(failureRD.ap(f)).toBe(failureRD);

describe('sequence', function () {
var s = Traversable_1.sequence(remote_data_1.remoteData, Array_1.array);
var s = Array_1.array.sequence(remote_data_1.remoteData);
it('initial', function () {

@@ -208,5 +207,5 @@ expect(s([initialRD, successRD])).toBe(initialRD);

});
describe('Traversable', function () {
describe('Traversable2v', function () {
describe('traverse', function () {
var t = Traversable_1.traverse(Option_1.option, remote_data_1.remoteData);
var t = remote_data_1.remoteData.traverse(Option_1.option);
var f = function (x) { return (x >= 2 ? Option_1.some(x) : Option_1.none); };

@@ -228,17 +227,50 @@ it('initial', function () {

});
describe('Foldable', function () {
describe('Foldable2v', function () {
describe('reduce', function () {
var f = function (a, b) { return a + b; };
var g = function (a) { return a + 1; };
it('initial', function () {
expect(initialRD.reduce(f, 1)).toBe(1);
expect(remote_data_1.remoteData.foldMap(Monoid_1.monoidSum)(initialRD, g)).toBe(0);
expect(remote_data_1.remoteData.foldr(initialRD, 1, f)).toBe(1);
});
it('pending', function () {
expect(pendingRD.reduce(f, 1)).toBe(1);
expect(remote_data_1.remoteData.foldMap(Monoid_1.monoidSum)(pendingRD, g)).toBe(0);
expect(remote_data_1.remoteData.foldr(pendingRD, 1, f)).toBe(1);
});
it('failure', function () {
expect(failureRD.reduce(f, 1)).toBe(1);
expect(remote_data_1.remoteData.foldMap(Monoid_1.monoidSum)(failureRD, g)).toBe(0);
expect(remote_data_1.remoteData.foldr(failureRD, 1, f)).toBe(1);
});
it('success', function () {
expect(successRD.reduce(f, 1)).toBe(2);
expect(remote_data_1.remoteData.foldMap(Monoid_1.monoidSum)(successRD, g)).toBe(2);
expect(remote_data_1.remoteData.foldr(successRD, 1, f)).toBe(2);
});
});
});
describe('Bifunctor', function () {
describe('bimap', function () {
var f = function (l) { return "Error: " + l; };
var g = function (a) { return a + 1; };
it('initial', function () {
expect(initialRD.bimap(f, g)).toBe(remote_data_1.initial);
expect(initialRD.bimap(function_1.identity, function_1.identity)).toBe(remote_data_1.initial);
});
it('pending', function () {
expect(pendingRD.bimap(f, g)).toBe(remote_data_1.pending);
expect(pendingRD.bimap(function_1.identity, function_1.identity)).toBe(remote_data_1.pending);
});
it('failure', function () {
expect(remote_data_1.success(1).reduce(f, 1)).toBe(2);
expect(failureRD.bimap(f, g)).toEqual(failureRD.mapLeft(f));
expect(failureRD.bimap(f, g)).toEqual(remote_data_1.failure('Error: foo'));
expect(failureRD.bimap(function_1.identity, function_1.identity)).toEqual(failureRD);
});
it('success', function () {
expect(successRD.bimap(f, g)).toEqual(successRD.map(g));
expect(successRD.bimap(f, g)).toEqual(remote_data_1.success(2));
expect(successRD.bimap(function_1.identity, function_1.identity)).toEqual(successRD);
});
});

@@ -389,34 +421,29 @@ });

});
it('should combine arbitrary values to first initial', function () {
var values = [remote_data_1.success(123), remote_data_1.success('foo'), remote_data_1.failure('bar'), remote_data_1.pending, remote_data_1.initial];
expect(remote_data_1.combine.apply(null, values)).toBe(remote_data_1.initial);
expect(remote_data_1.combine.apply(null, values.reverse())).toBe(remote_data_1.initial);
it('should combine arbitrary non-failure values to first initial', function () {
expect(remote_data_1.combine(remote_data_1.success(123), remote_data_1.success('foo'), remote_data_1.pending, remote_data_1.initial)).toBe(remote_data_1.initial);
expect(remote_data_1.combine(remote_data_1.initial, remote_data_1.pending, remote_data_1.success('foo'), remote_data_1.success(123))).toBe(remote_data_1.initial);
});
it('should combine arbitrary values to first pending', function () {
var values = [remote_data_1.success(123), remote_data_1.success('foo'), remote_data_1.failure('bar'), remote_data_1.pending];
expect(remote_data_1.combine.apply(null, values)).toBe(remote_data_1.pending);
expect(remote_data_1.combine.apply(null, values.reverse())).toBe(remote_data_1.pending);
it('should combine arbitrary non-failure & non-initial values to first pending', function () {
expect(remote_data_1.combine(remote_data_1.success(123), remote_data_1.success('foo'), remote_data_1.pending)).toBe(remote_data_1.pending);
expect(remote_data_1.combine(remote_data_1.pending, remote_data_1.success('foo'), remote_data_1.success(123))).toBe(remote_data_1.pending);
});
it('should combine arbitrary values to first failure', function () {
var values = [remote_data_1.success(123), remote_data_1.success('foo'), remote_data_1.failure('bar')];
expect(remote_data_1.combine.apply(null, values)).toEqual(remote_data_1.failure('bar'));
expect(remote_data_1.combine.apply(null, values.reverse())).toEqual(remote_data_1.failure('bar'));
expect(remote_data_1.combine(remote_data_1.success(123), remote_data_1.success('foo'), remote_data_1.failure('bar'))).toEqual(remote_data_1.failure('bar'));
expect(remote_data_1.combine(remote_data_1.failure('bar'), remote_data_1.success('foo'), remote_data_1.success(123))).toEqual(remote_data_1.failure('bar'));
});
describe('progress', function () {
it('should combine pendings without progress', function () {
var values = [remote_data_1.pending, remote_data_1.pending];
expect(remote_data_1.combine.apply(null, values)).toBe(remote_data_1.pending);
expect(remote_data_1.combine.apply(null, values.reverse())).toBe(remote_data_1.pending);
expect(remote_data_1.combine(remote_data_1.pending, remote_data_1.pending)).toBe(remote_data_1.pending);
expect(remote_data_1.combine(remote_data_1.pending, remote_data_1.pending, remote_data_1.pending)).toBe(remote_data_1.pending);
expect(remote_data_1.combine(remote_data_1.pending, remote_data_1.pending, remote_data_1.pending, remote_data_1.pending)).toBe(remote_data_1.pending);
});
it('should combine pending and progress', function () {
var withProgress = remote_data_1.progress({ loaded: 1, total: Option_1.none });
var values = [remote_data_1.pending, withProgress];
expect(remote_data_1.combine.apply(null, values)).toBe(withProgress);
expect(remote_data_1.combine.apply(null, values.reverse())).toBe(withProgress);
expect(remote_data_1.combine(remote_data_1.pending, withProgress)).toBe(withProgress);
expect(remote_data_1.combine(withProgress, remote_data_1.pending)).toBe(withProgress);
});
it('should combine progress without total', function () {
var withProgress = remote_data_1.progress({ loaded: 1, total: Option_1.none });
var values = [withProgress, withProgress];
expect(remote_data_1.combine.apply(null, values)).toEqual(remote_data_1.progress({ loaded: 2, total: Option_1.none }));
expect(remote_data_1.combine.apply(null, values.reverse())).toEqual(remote_data_1.progress({ loaded: 2, total: Option_1.none }));
expect(remote_data_1.combine(withProgress, withProgress)).toEqual(remote_data_1.progress({ loaded: 2, total: Option_1.none }));
expect(remote_data_1.combine(withProgress, withProgress, withProgress)).toEqual(remote_data_1.progress({ loaded: 3, total: Option_1.none }));
});

@@ -426,8 +453,6 @@ it('should combine progress without total and progress with total', function () {

var withProgressAndTotal = remote_data_1.progress({ loaded: 1, total: Option_1.some(2) });
var values = [withProgress, withProgressAndTotal];
expect(remote_data_1.combine.apply(null, values)).toEqual(remote_data_1.progress({ loaded: 2, total: Option_1.none }));
expect(remote_data_1.combine.apply(null, values.reverse())).toEqual(remote_data_1.progress({ loaded: 2, total: Option_1.none }));
expect(remote_data_1.combine(withProgress, withProgressAndTotal)).toEqual(remote_data_1.progress({ loaded: 2, total: Option_1.none }));
expect(remote_data_1.combine(withProgressAndTotal, withProgress)).toEqual(remote_data_1.progress({ loaded: 2, total: Option_1.none }));
});
it('should combine progresses with total', function () {
var values = [remote_data_1.progress({ loaded: 2, total: Option_1.some(10) }), remote_data_1.progress({ loaded: 2, total: Option_1.some(30) })];
var expected = remote_data_1.progress({

@@ -437,4 +462,4 @@ loaded: (2 * 10 + 2 * 30) / (40 * 40),

});
expect(remote_data_1.combine.apply(null, values)).toEqual(expected);
expect(remote_data_1.combine.apply(null, values.reverse())).toEqual(expected);
expect(remote_data_1.combine(remote_data_1.progress({ loaded: 2, total: Option_1.some(10) }), remote_data_1.progress({ loaded: 2, total: Option_1.some(30) }))).toEqual(expected);
expect(remote_data_1.combine(remote_data_1.progress({ loaded: 2, total: Option_1.some(30) }), remote_data_1.progress({ loaded: 2, total: Option_1.some(10) }))).toEqual(expected);
});

@@ -441,0 +466,0 @@ });

import { Function2, Function1, Lazy, Predicate } from 'fp-ts/lib/function';
import { Monad2 } from 'fp-ts/lib/Monad';
import { Foldable2 } from 'fp-ts/lib/Foldable';
import { Foldable2v2 } from 'fp-ts/lib/Foldable2v';
import { Alt2 } from 'fp-ts/lib/Alt';
import { Extend2 } from 'fp-ts/lib/Extend';
import { Traversable2 } from 'fp-ts/lib/Traversable';
import { Traversable2v2 } from 'fp-ts/lib/Traversable2v';
import { Bifunctor2 } from 'fp-ts/lib/Bifunctor';
import { Option } from 'fp-ts/lib/Option';

@@ -53,4 +54,4 @@ import { Either } from 'fp-ts/lib/Either';

* and applies that function to this `RemoteData`'s value.
* If the `RemoteData` calling `ap` is "Left" part it will return same "Left" part.
* If you pass "Left" part to `ap` as an argument, it will return same "Left" part regardless on `RemoteData` which calls `ap`.
* If the `RemoteData` calling `ap` is a "Left" part it will return same "Left" part.
* If you pass a "Left" part to `ap` as an argument, it will return same "Left" part regardless on `RemoteData` which calls `ap`.
*

@@ -65,3 +66,3 @@ * For example:

*
* `failure(new Error('err text')).ap(initial) will return initial.`
* `failure(new Error('err text')).ap(initial) will return failure.`
*/

@@ -83,2 +84,3 @@ ap<B>(fab: RemoteData<L, Function1<A, B>>): RemoteData<L, B>;

chain<B>(f: Function1<A, RemoteData<L, B>>): RemoteData<L, B>;
bimap<V, B>(f: (l: L) => V, g: (a: A) => B): RemoteData<V, B>;
/**

@@ -108,3 +110,3 @@ * Takes a function `f` and returns a result of applying it to `RemoteData`.

*/
fold<B>(initial: B, pending: B, failure: Function1<L, B>, success: Function1<A, B>): B;
fold<B>(onInitial: B, onPending: B, onFailure: Function1<L, B>, onSuccess: Function1<A, B>): B;
/**

@@ -120,3 +122,3 @@ * Same as `fold` but lazy: in `initial` and `pending` state it takes a function instead of value.

*/
foldL<B>(initial: Lazy<B>, pending: Function1<Option<RemoteProgress>, B>, failure: Function1<L, B>, success: Function1<A, B>): B;
foldL<B>(onInitial: Lazy<B>, onPending: Function1<Option<RemoteProgress>, B>, onFailure: Function1<L, B>, onSuccess: Function1<A, B>): B;
/**

@@ -233,3 +235,3 @@ * Same as `getOrElse` but lazy: it pass as an argument a function which returns a default value.

*/
toEither(initial: L, pending: L): Either<L, A>;
toEither(onInitial: L, onPending: L): Either<L, A>;
/**

@@ -248,3 +250,3 @@ * Like `toEither`, but lazy: it takes functions that return an `L` value

*/
toEitherL(initial: Lazy<L>, pending: Lazy<L>): Either<L, A>;
toEitherL(onInitial: Lazy<L>, onPending: Lazy<L>): Either<L, A>;
/**

@@ -306,5 +308,6 @@ * One more way to fold (unwrap) value from `RemoteData`.

chain<B>(f: Function1<A, RemoteData<L, B>>): RemoteData<L, B>;
bimap<V, B>(f: (l: L) => V, g: (a: A) => B): RemoteData<V, B>;
extend<B>(f: Function1<RemoteData<L, A>, B>): RemoteData<L, B>;
fold<B>(initial: B, pending: B, failure: Function1<L, B>, success: Function1<A, B>): B;
foldL<B>(initial: Lazy<B>, pending: Function1<Option<RemoteProgress>, B>, failure: Function1<L, B>, success: Function1<A, B>): B;
fold<B>(onInitial: B, onPending: B, onFailure: Function1<L, B>, onSuccess: Function1<A, B>): B;
foldL<B>(onInitial: Lazy<B>, onPending: Function1<Option<RemoteProgress>, B>, onFailure: Function1<L, B>, onSuccess: Function1<A, B>): B;
getOrElseL(f: Lazy<A>): A;

@@ -320,4 +323,4 @@ map<B>(f: (a: A) => B): RemoteData<L, B>;

toOption(): Option<A>;
toEither(initial: L, pending: L): Either<L, A>;
toEitherL(initial: Lazy<L>, pending: Lazy<L>): Either<L, A>;
toEither(onInitial: L, onPending: L): Either<L, A>;
toEitherL(onInitial: Lazy<L>, onPending: Lazy<L>): Either<L, A>;
toNullable(): A | null;

@@ -341,5 +344,6 @@ toString(): string;

chain<B>(f: Function1<A, RemoteData<L, B>>): RemoteData<L, B>;
bimap<V, B>(f: (l: L) => V, g: (a: A) => B): RemoteData<V, B>;
extend<B>(f: Function1<RemoteData<L, A>, B>): RemoteData<L, B>;
fold<B>(initial: B, pending: B, failure: Function1<L, B>, success: Function1<A, B>): B;
foldL<B>(initial: Lazy<B>, pending: Function1<Option<RemoteProgress>, B>, failure: Function1<L, B>, success: Function1<A, B>): B;
fold<B>(onInitial: B, onPending: B, onFailure: Function1<L, B>, onSuccess: Function1<A, B>): B;
foldL<B>(onInitial: Lazy<B>, onPending: Function1<Option<RemoteProgress>, B>, onFailure: Function1<L, B>, onSuccess: Function1<A, B>): B;
getOrElseL(f: Lazy<A>): A;

@@ -355,4 +359,4 @@ map<B>(f: Function1<A, B>): RemoteData<L, B>;

toOption(): Option<A>;
toEither(initial: L, pending: L): Either<L, A>;
toEitherL(initial: Lazy<L>, pending: Lazy<L>): Either<L, A>;
toEither(onInitial: L, onPending: L): Either<L, A>;
toEitherL(onInitial: Lazy<L>, onPending: Lazy<L>): Either<L, A>;
toNullable(): A | null;

@@ -376,5 +380,6 @@ toString(): string;

chain<B>(f: Function1<A, RemoteData<L, B>>): RemoteData<L, B>;
bimap<V, B>(f: (l: L) => V, g: (a: A) => B): RemoteData<V, B>;
extend<B>(f: Function1<RemoteData<L, A>, B>): RemoteData<L, B>;
fold<B>(initial: B, pending: B, failure: Function1<L, B>, success: Function1<A, B>): B;
foldL<B>(initial: Lazy<B>, pending: Function1<Option<RemoteProgress>, B>, failure: Function1<L, B>, success: Function1<A, B>): B;
fold<B>(onInitial: B, onPending: B, onFailure: Function1<L, B>, onSuccess: Function1<A, B>): B;
foldL<B>(onInitial: Lazy<B>, onPending: Function1<Option<RemoteProgress>, B>, onFailure: Function1<L, B>, onSuccess: Function1<A, B>): B;
getOrElseL(f: Lazy<A>): A;

@@ -390,4 +395,4 @@ map<B>(f: Function1<A, B>): RemoteData<L, B>;

toOption(): Option<A>;
toEither(initial: L, pending: L): Either<L, A>;
toEitherL(initial: Lazy<L>, pending: Lazy<L>): Either<L, A>;
toEither(onInitial: L, onPending: L): Either<L, A>;
toEitherL(onInitial: Lazy<L>, onPending: Lazy<L>): Either<L, A>;
toNullable(): A | null;

@@ -430,3 +435,3 @@ toString(): string;

export declare function fromProgressEvent<L, A>(event: ProgressEvent): RemoteData<L, A>;
export declare const remoteData: Monad2<URI> & Foldable2<URI> & Traversable2<URI> & Alt2<URI> & Extend2<URI> & Alternative2<URI> & Monoidal2<URI>;
export declare const remoteData: Monad2<URI> & Foldable2v2<URI> & Traversable2v2<URI> & Bifunctor2<URI> & Alt2<URI> & Extend2<URI> & Alternative2<URI> & Monoidal2<URI>;
export declare function combine<A, L>(a: RemoteData<L, A>): RemoteData<L, [A]>;

@@ -433,0 +438,0 @@ export declare function combine<A, B, L>(a: RemoteData<L, A>, b: RemoteData<L, B>): RemoteData<L, [A, B]>;

@@ -5,3 +5,2 @@ "use strict";

var function_1 = require("fp-ts/lib/function");
var Traversable_1 = require("fp-ts/lib/Traversable");
var Option_1 = require("fp-ts/lib/Option");

@@ -75,4 +74,4 @@ var Either_1 = require("fp-ts/lib/Either");

* and applies that function to this `RemoteData`'s value.
* If the `RemoteData` calling `ap` is "Left" part it will return same "Left" part.
* If you pass "Left" part to `ap` as an argument, it will return same "Left" part regardless on `RemoteData` which calls `ap`.
* If the `RemoteData` calling `ap` is a "Left" part it will return same "Left" part.
* If you pass a "Left" part to `ap` as an argument, it will return same "Left" part regardless on `RemoteData` which calls `ap`.
*

@@ -87,6 +86,6 @@ * For example:

*
* `failure(new Error('err text')).ap(initial) will return initial.`
* `failure(new Error('err text')).ap(initial) will return failure.`
*/
RemoteInitial.prototype.ap = function (fab) {
return exports.initial; //tslint:disable-line no-use-before-declare
return fab.isFailure() ? fab : exports.initial; //tslint:disable-line no-use-before-declare
};

@@ -109,2 +108,5 @@ /**

};
RemoteInitial.prototype.bimap = function (f, g) {
return exports.initial; //tslint:disable-line no-use-before-declare
};
/**

@@ -136,4 +138,4 @@ * Takes a function `f` and returns a result of applying it to `RemoteData`.

*/
RemoteInitial.prototype.fold = function (initial, pending, failure, success) {
return initial;
RemoteInitial.prototype.fold = function (onInitial, onPending, onFailure, onSuccess) {
return onInitial;
};

@@ -150,4 +152,4 @@ /**

*/
RemoteInitial.prototype.foldL = function (initial, pending, failure, success) {
return initial();
RemoteInitial.prototype.foldL = function (onInitial, onPending, onFailure, onSuccess) {
return onInitial();
};

@@ -285,4 +287,4 @@ /**

*/
RemoteInitial.prototype.toEither = function (initial, pending) {
return Either_1.left(initial);
RemoteInitial.prototype.toEither = function (onInitial, onPending) {
return Either_1.left(onInitial);
};

@@ -302,4 +304,4 @@ /**

*/
RemoteInitial.prototype.toEitherL = function (initial, pending) {
return Either_1.left(initial());
RemoteInitial.prototype.toEitherL = function (onInitial, onPending) {
return Either_1.left(onInitial());
};

@@ -377,4 +379,4 @@ /**

RemoteFailure.prototype.ap = function (fab) {
var _this = this;
return fab.fold(exports.initial, fab, function () { return fab; }, function () { return _this; }); //tslint:disable-line no-use-before-declare
//tslint:disable-next-line no-use-before-declare
return fab.isFailure() ? fab : this;
};

@@ -384,10 +386,13 @@ RemoteFailure.prototype.chain = function (f) {

};
RemoteFailure.prototype.bimap = function (f, g) {
return exports.failure(f(this.error)); //tslint:disable-line no-use-before-declare
};
RemoteFailure.prototype.extend = function (f) {
return this;
};
RemoteFailure.prototype.fold = function (initial, pending, failure, success) {
return failure(this.error);
RemoteFailure.prototype.fold = function (onInitial, onPending, onFailure, onSuccess) {
return onFailure(this.error);
};
RemoteFailure.prototype.foldL = function (initial, pending, failure, success) {
return failure(this.error);
RemoteFailure.prototype.foldL = function (onInitial, onPending, onFailure, onSuccess) {
return onFailure(this.error);
};

@@ -424,6 +429,6 @@ RemoteFailure.prototype.getOrElseL = function (f) {

};
RemoteFailure.prototype.toEither = function (initial, pending) {
RemoteFailure.prototype.toEither = function (onInitial, onPending) {
return Either_1.left(this.error);
};
RemoteFailure.prototype.toEitherL = function (initial, pending) {
RemoteFailure.prototype.toEitherL = function (onInitial, onPending) {
return Either_1.left(this.error);

@@ -447,3 +452,3 @@ };

RemoteFailure.prototype.recoverMap = function (f, g) {
return f(this.error).fold(this, exports.success); //tslint:disable-line no-use-before-declare
return f(this.error).fold(this, exports.success);
};

@@ -466,3 +471,4 @@ return RemoteFailure;

var _this = this;
return fab.fold(exports.initial, fab, function () { return fab; }, function (value) { return _this.map(value); }); //tslint:disable-line no-use-before-declare
return fab.fold(exports.initial, //tslint:disable-line no-use-before-declare
fab, function () { return fab; }, function (value) { return _this.map(value); });
};

@@ -472,10 +478,13 @@ RemoteSuccess.prototype.chain = function (f) {

};
RemoteSuccess.prototype.bimap = function (f, g) {
return exports.success(g(this.value)); //tslint:disable-line no-use-before-declare
};
RemoteSuccess.prototype.extend = function (f) {
return of(f(this)); //tslint:disable-line no-use-before-declare
};
RemoteSuccess.prototype.fold = function (initial, pending, failure, success) {
return success(this.value);
RemoteSuccess.prototype.fold = function (onInitial, onPending, onFailure, onSuccess) {
return onSuccess(this.value);
};
RemoteSuccess.prototype.foldL = function (initial, pending, failure, success) {
return success(this.value);
RemoteSuccess.prototype.foldL = function (onInitial, onPending, onFailure, onSuccess) {
return onSuccess(this.value);
};

@@ -512,6 +521,6 @@ RemoteSuccess.prototype.getOrElseL = function (f) {

};
RemoteSuccess.prototype.toEither = function (initial, pending) {
RemoteSuccess.prototype.toEither = function (onInitial, onPending) {
return Either_1.right(this.value);
};
RemoteSuccess.prototype.toEitherL = function (initial, pending) {
RemoteSuccess.prototype.toEitherL = function (onInitial, onPending) {
return Either_1.right(this.value);

@@ -555,3 +564,5 @@ };

return fab.fold(exports.initial, //tslint:disable-line no-use-before-declare
fab.isPending() ? concatPendings(this, fab) : this, function () { return _this; }, function () { return _this; });
fab.isPending()
? concatPendings(this, fab)
: this, function () { return fab; }, function () { return _this; });
};

@@ -561,10 +572,13 @@ RemotePending.prototype.chain = function (f) {

};
RemotePending.prototype.bimap = function (f, g) {
return exports.pending; //tslint:disable-line no-use-before-declare
};
RemotePending.prototype.extend = function (f) {
return exports.pending; //tslint:disable-line no-use-before-declare
};
RemotePending.prototype.fold = function (initial, pending, failure, success) {
return pending;
RemotePending.prototype.fold = function (onInitial, onPending, onFailure, onSuccess) {
return onPending;
};
RemotePending.prototype.foldL = function (initial, pending, failure, success) {
return pending(this.progress);
RemotePending.prototype.foldL = function (onInitial, onPending, onFailure, onSuccess) {
return onPending(this.progress);
};

@@ -601,7 +615,7 @@ RemotePending.prototype.getOrElseL = function (f) {

};
RemotePending.prototype.toEither = function (initial, pending) {
return Either_1.left(pending);
RemotePending.prototype.toEither = function (onInitial, onPending) {
return Either_1.left(onPending);
};
RemotePending.prototype.toEitherL = function (initial, pending) {
return Either_1.left(pending());
RemotePending.prototype.toEitherL = function (onInitial, onPending) {
return Either_1.left(onPending());
};

@@ -634,14 +648,24 @@ RemotePending.prototype.toNullable = function () {

var chain = function (fa, f) { return fa.chain(f); };
//Foldable
//Foldable2v
var reduce = function (fa, b, f) { return fa.reduce(f, b); };
function traverse(F) {
return function (ta, f) {
if (ta.isSuccess()) {
return F.map(f(ta.value), of);
}
else {
return F.of(ta);
}
};
}
var foldMap = function (M) { return function (fa, f) {
return fa.isSuccess() ? f(fa.value) : M.empty;
}; };
var foldr = function (fa, b, f) { return (fa.isSuccess() ? f(fa.value, b) : b); };
//Traversable2v
var traverse = function (F) { return function (ta, f) {
if (ta.isSuccess()) {
return F.map(f(ta.value), of);
}
else {
return F.of(ta);
}
}; };
var sequence = function (F) { return function (ta) {
return traverse(F)(ta, function_1.identity);
}; };
//Bifunctor
var bimap = function (fla, f, g) {
return fla.bimap(f, g);
};
//Alt

@@ -685,3 +709,5 @@ var alt = function (fx, fy) { return fx.alt(fy); };

concat: function (x, y) {
return x.foldL(function () { return y.fold(y, y, function () { return y; }, function () { return y; }); }, function () { return y.foldL(function () { return x; }, function () { return concatPendings(x, y); }, function () { return y; }, function () { return y; }); }, function (xError) { return y.fold(x, x, function (yError) { return exports.failure(SL.concat(xError, yError)); }, function () { return y; }); }, function (xValue) { return y.fold(x, x, function () { return x; }, function (yValue) { return exports.success(SA.concat(xValue, yValue)); }); });
return x.foldL(function () { return y.fold(y, y, function () { return y; }, function () { return y; }); }, function () {
return y.foldL(function () { return x; }, function () { return concatPendings(x, y); }, function () { return y; }, function () { return y; });
}, function (xError) { return y.fold(x, x, function (yError) { return exports.failure(SL.concat(xError, yError)); }, function () { return y; }); }, function (xValue) { return y.fold(x, x, function () { return x; }, function (yValue) { return exports.success(SA.concat(xValue, yValue)); }); });
},

@@ -732,6 +758,11 @@ };

chain: chain,
//Foldable
//Foldable2v
reduce: reduce,
//Traversable
foldMap: foldMap,
foldr: foldr,
//Traversable2v
traverse: traverse,
sequence: sequence,
//Bifunctor
bimap: bimap,
//Alt

@@ -755,4 +786,4 @@ alt: alt,

}
return Traversable_1.sequence(exports.remoteData, Array_1.array)(list);
return Array_1.array.sequence(exports.remoteData)(list);
}
exports.combine = combine;
{
"name": "@devexperts/remote-data-ts",
"version": "0.4.2",
"version": "0.5.0",
"main": "dist/index.js",

@@ -27,10 +27,10 @@ "typings": "dist/index.d.ts",

"ts-jest": "^23.10.4",
"tslint": "^5.9.1",
"tslint": "^5.12.1",
"tslint-config-prettier": "^1.7.0",
"tslint-plugin-prettier": "^1.3.0",
"typescript": "^2.8.1"
"typescript": "^3.2.4"
},
"dependencies": {
"fp-ts": "^1.2.0",
"io-ts": "^1.3.1",
"fp-ts": "^1.13.0",
"io-ts": "^1.7.0",
"io-ts-types": "^0.3.14",

@@ -37,0 +37,0 @@ "tslib": "^1.9.0"

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