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 2.0.3 to 2.0.4

39

CHANGELOG.md

@@ -0,1 +1,10 @@

## [2.0.4](https://github.com/devexperts/remote-data-ts/compare/v2.0.3...v2.0.4) (2020-08-11)
### Bug Fixes
* rewrite imports from lib to es6 in es6 output ([c6899d8](https://github.com/devexperts/remote-data-ts/commit/c6899d8e70ee5f3c617b0bf7756dfb2a7f0dda6e)), closes [#46](https://github.com/devexperts/remote-data-ts/issues/46) [#49](https://github.com/devexperts/remote-data-ts/issues/49)
## [2.0.3](https://github.com/devexperts/remote-data-ts/compare/v2.0.2...v2.0.3) (2020-01-24)

@@ -6,3 +15,3 @@

* fix bimap, mapLeft, extend to forward progress correctly ([#45](https://github.com/devexperts/remote-data-ts/issues/45)) ([be78635](https://github.com/devexperts/remote-data-ts/commit/be78635))
* fix bimap, mapLeft, extend to forward progress correctly ([#45](https://github.com/devexperts/remote-data-ts/issues/45)) ([be78635](https://github.com/devexperts/remote-data-ts/commit/be78635c4cf77a9dd1531b745f17638194b0e15a))

@@ -24,3 +33,3 @@

* fp-ts@2 support added ([#34](https://github.com/devexperts/remote-data-ts/issues/34)) ([b7ad152](https://github.com/devexperts/remote-data-ts/commit/b7ad152))
* fp-ts@2 support added ([#34](https://github.com/devexperts/remote-data-ts/issues/34)) ([b7ad152](https://github.com/devexperts/remote-data-ts/commit/b7ad152d5058129f05c9e5a1d901310250b1dbbe))

@@ -30,4 +39,4 @@

* classless ([#35](https://github.com/devexperts/remote-data-ts/issues/35)) ([7351a88](https://github.com/devexperts/remote-data-ts/commit/7351a88))
* update RemoteDataT ([#36](https://github.com/devexperts/remote-data-ts/issues/36)) ([4249fc2](https://github.com/devexperts/remote-data-ts/commit/4249fc2))
* classless ([#35](https://github.com/devexperts/remote-data-ts/issues/35)) ([7351a88](https://github.com/devexperts/remote-data-ts/commit/7351a880e2cd416449d33e870675e967a2f23916))
* update RemoteDataT ([#36](https://github.com/devexperts/remote-data-ts/issues/36)) ([4249fc2](https://github.com/devexperts/remote-data-ts/commit/4249fc2722a28727132ced10d255d327007b93b0))

@@ -49,3 +58,3 @@

* incorrect json pending type ([#32](https://github.com/devexperts/remote-data-ts/issues/32)) ([eba21eb](https://github.com/devexperts/remote-data-ts/commit/eba21eb)), closes [#31](https://github.com/devexperts/remote-data-ts/issues/31)
* incorrect json pending type ([#32](https://github.com/devexperts/remote-data-ts/issues/32)) ([eba21eb](https://github.com/devexperts/remote-data-ts/commit/eba21eb7643741d01ce8776ea56b94b18103dc82)), closes [#31](https://github.com/devexperts/remote-data-ts/issues/31)

@@ -55,3 +64,3 @@

* Add RemoteDataT transformer ([#29](https://github.com/devexperts/remote-data-ts/issues/29)) ([9d2d0f2](https://github.com/devexperts/remote-data-ts/commit/9d2d0f2))
* Add RemoteDataT transformer ([#29](https://github.com/devexperts/remote-data-ts/issues/29)) ([9d2d0f2](https://github.com/devexperts/remote-data-ts/commit/9d2d0f2bec494a033f10f2659eb456c0f781dcdd))

@@ -65,3 +74,3 @@

* move peer dependencies to dependencies ([#24](https://github.com/devexperts/remote-data-ts/issues/24)) ([0812d29](https://github.com/devexperts/remote-data-ts/commit/0812d29)), closes [#23](https://github.com/devexperts/remote-data-ts/issues/23)
* move peer dependencies to dependencies ([#24](https://github.com/devexperts/remote-data-ts/issues/24)) ([0812d29](https://github.com/devexperts/remote-data-ts/commit/0812d29796723f51ef8c1ea6c222b6e2291ab34e)), closes [#23](https://github.com/devexperts/remote-data-ts/issues/23)

@@ -71,6 +80,6 @@

* add io-ts type ([#19](https://github.com/devexperts/remote-data-ts/issues/19)) ([7d6785f](https://github.com/devexperts/remote-data-ts/commit/7d6785f))
* major update - Fail fast ap, TS/fp-ts/io-ts upgrade, Traversable2v, Bifunctor ([#28](https://github.com/devexperts/remote-data-ts/issues/28)) ([3955c17](https://github.com/devexperts/remote-data-ts/commit/3955c17)), closes [#26](https://github.com/devexperts/remote-data-ts/issues/26)
* provide progress parameter via fold pending parameter ([#20](https://github.com/devexperts/remote-data-ts/issues/20)) ([1cf41ce](https://github.com/devexperts/remote-data-ts/commit/1cf41ce))
* relax getMonoid dependencies to Semigroup instances instead of Monoid ([#21](https://github.com/devexperts/remote-data-ts/issues/21)) ([d7b060e](https://github.com/devexperts/remote-data-ts/commit/d7b060e))
* add io-ts type ([#19](https://github.com/devexperts/remote-data-ts/issues/19)) ([7d6785f](https://github.com/devexperts/remote-data-ts/commit/7d6785f4211ee263dacc73100677ca5c0b1994d2))
* major update - Fail fast ap, TS/fp-ts/io-ts upgrade, Traversable2v, Bifunctor ([#28](https://github.com/devexperts/remote-data-ts/issues/28)) ([3955c17](https://github.com/devexperts/remote-data-ts/commit/3955c175e427dacdb87ec7351ea451b0b7c454ad)), closes [#26](https://github.com/devexperts/remote-data-ts/issues/26)
* provide progress parameter via fold pending parameter ([#20](https://github.com/devexperts/remote-data-ts/issues/20)) ([1cf41ce](https://github.com/devexperts/remote-data-ts/commit/1cf41ceda67507d979068471214d687ffe8b967c))
* relax getMonoid dependencies to Semigroup instances instead of Monoid ([#21](https://github.com/devexperts/remote-data-ts/issues/21)) ([d7b060e](https://github.com/devexperts/remote-data-ts/commit/d7b060e9298af11419991629f5da28d44759f972))

@@ -90,3 +99,3 @@

* Add toEither method ([#16](https://github.com/devexperts/remote-data-ts/issues/16)) ([a314bb5](https://github.com/devexperts/remote-data-ts/commit/a314bb5))
* Add toEither method ([#16](https://github.com/devexperts/remote-data-ts/issues/16)) ([a314bb5](https://github.com/devexperts/remote-data-ts/commit/a314bb53e753307879d069ad1591e819260a871b))

@@ -100,5 +109,5 @@

* add "recover" method ([27d5591](https://github.com/devexperts/remote-data-ts/commit/27d5591)), closes [#12](https://github.com/devexperts/remote-data-ts/issues/12)
* Add progress to RemotePending ([4c89823](https://github.com/devexperts/remote-data-ts/commit/4c89823)), closes [#9](https://github.com/devexperts/remote-data-ts/issues/9)
* update to TS@2.8.1, fp-ts@1.2.0 + implement Monoidal ([d9a4a09](https://github.com/devexperts/remote-data-ts/commit/d9a4a09))
* add "recover" method ([27d5591](https://github.com/devexperts/remote-data-ts/commit/27d559131dee5aa316b8c1e91d56db9176b1db05)), closes [#12](https://github.com/devexperts/remote-data-ts/issues/12)
* Add progress to RemotePending ([4c89823](https://github.com/devexperts/remote-data-ts/commit/4c89823a66852ea0bb4924e95603d5c2bad388f8)), closes [#9](https://github.com/devexperts/remote-data-ts/issues/9)
* update to TS@2.8.1, fp-ts@1.2.0 + implement Monoidal ([d9a4a09](https://github.com/devexperts/remote-data-ts/commit/d9a4a09296940dbadd54c3b8c32aeaba31a7686d))

@@ -105,0 +114,0 @@

import { RemoteData, RemoteFailure, RemoteInitial, RemoteSuccess } from './remote-data';
import { Type } from 'io-ts';
import { Type } from 'io-ts/lib/index';
export declare type JSONRemoteProgress = {

@@ -4,0 +4,0 @@ loaded: number;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var optionFromNullable_1 = require("io-ts-types/lib/optionFromNullable");
var io_ts_1 = require("io-ts");
var RemoteInitialCodec = io_ts_1.type({
_tag: io_ts_1.literal('RemoteInitial'),
var index_1 = require("io-ts/lib/index");
var RemoteInitialCodec = index_1.type({
_tag: index_1.literal('RemoteInitial'),
});
var RemoteProgressCodec = io_ts_1.type({
loaded: io_ts_1.number,
total: optionFromNullable_1.optionFromNullable(io_ts_1.number),
var RemoteProgressCodec = index_1.type({
loaded: index_1.number,
total: optionFromNullable_1.optionFromNullable(index_1.number),
});
var RemotePendingCodec = io_ts_1.type({
_tag: io_ts_1.literal('RemotePending'),
var RemotePendingCodec = index_1.type({
_tag: index_1.literal('RemotePending'),
progress: optionFromNullable_1.optionFromNullable(RemoteProgressCodec),
});
function createRemoteDataFromJSON(leftCodec, rightCodec) {
var RemoteFailureCodec = io_ts_1.type({
_tag: io_ts_1.literal('RemoteFailure'),
var RemoteFailureCodec = index_1.type({
_tag: index_1.literal('RemoteFailure'),
error: leftCodec,
});
var RemoteSuccessCodec = io_ts_1.type({
_tag: io_ts_1.literal('RemoteSuccess'),
var RemoteSuccessCodec = index_1.type({
_tag: index_1.literal('RemoteSuccess'),
value: rightCodec,
});
return io_ts_1.union([RemoteInitialCodec, RemotePendingCodec, RemoteFailureCodec, RemoteSuccessCodec], '_tag');
return index_1.union([RemoteInitialCodec, RemotePendingCodec, RemoteFailureCodec, RemoteSuccessCodec], '_tag');
}
exports.createRemoteDataFromJSON = createRemoteDataFromJSON;
import { RemoteData, RemoteFailure, RemoteInitial, RemoteSuccess } from './remote-data';
import { Type } from 'io-ts';
import { Type } from 'io-ts/es6/index';
export declare type JSONRemoteProgress = {

@@ -4,0 +4,0 @@ loaded: number;

@@ -1,11 +0,11 @@

import { optionFromNullable } from 'io-ts-types/lib/optionFromNullable';
import { literal, number, type, union } from 'io-ts';
var RemoteInitialCodec = type({
import { optionFromNullable } from 'io-ts-types/es6/optionFromNullable';
import { literal, number, type, union } from 'io-ts/es6/index';
const RemoteInitialCodec = type({
_tag: literal('RemoteInitial'),
});
var RemoteProgressCodec = type({
const RemoteProgressCodec = type({
loaded: number,
total: optionFromNullable(number),
});
var RemotePendingCodec = type({
const RemotePendingCodec = type({
_tag: literal('RemotePending'),

@@ -15,7 +15,7 @@ progress: optionFromNullable(RemoteProgressCodec),

export function createRemoteDataFromJSON(leftCodec, rightCodec) {
var RemoteFailureCodec = type({
const RemoteFailureCodec = type({
_tag: literal('RemoteFailure'),
error: leftCodec,
});
var RemoteSuccessCodec = type({
const RemoteSuccessCodec = type({
_tag: literal('RemoteSuccess'),

@@ -22,0 +22,0 @@ value: rightCodec,

import { RemoteData, RemoteProgress, URI } from './remote-data';
import { ApplicativeComposition12, ApplicativeComposition22, ApplicativeCompositionHKT2 } from 'fp-ts/lib/Applicative';
import { HKT, Kind, Kind2, Kind3, Kind4, URIS, URIS2, URIS3, URIS4 } from 'fp-ts/lib/HKT';
import { Monad, Monad1, Monad2, Monad3, Monad4 } from 'fp-ts/lib/Monad';
import { Option } from 'fp-ts/lib/Option';
import { ApplicativeComposition12, ApplicativeComposition22, ApplicativeCompositionHKT2 } from 'fp-ts/es6/Applicative';
import { HKT, Kind, Kind2, Kind3, Kind4, URIS, URIS2, URIS3, URIS4 } from 'fp-ts/es6/HKT';
import { Monad, Monad1, Monad2, Monad3, Monad4 } from 'fp-ts/es6/Monad';
import { Option } from 'fp-ts/es6/Option';
export declare type RemoteDataT<M, E, A> = HKT<M, RemoteData<E, A>>;

@@ -7,0 +7,0 @@ export interface RemoteDataM<M> extends ApplicativeCompositionHKT2<M, URI> {

@@ -1,9 +0,6 @@

import * as tslib_1 from "tslib";
import { failure, fold, progress, remoteData, success, initial, pending, fromOption, } from './remote-data';
import { getApplicativeComposition, } from 'fp-ts/lib/Applicative';
import { getApplicativeComposition, } from 'fp-ts/es6/Applicative';
export function getRemoteDataM(M) {
var A = getApplicativeComposition(M, remoteData);
return tslib_1.__assign({}, A, { chain: function (fa, f) { return M.chain(fa, function (a) { return (a._tag === 'RemoteSuccess' ? f(a.value) : M.of(a)); }); }, alt: function (fa, f) { return M.chain(fa, function (a) { return (a._tag === 'RemoteSuccess' ? A.of(a.value) : f()); }); }, bimap: function (fa, f, g) { return M.map(fa, function (a) { return remoteData.bimap(a, f, g); }); }, mapLeft: function (ma, f) { return M.map(ma, function (a) { return remoteData.mapLeft(a, f); }); }, fold: function (ma, onInitial, onPending, onFailure, onSuccess) {
return M.chain(ma, fold(onInitial, onPending, onFailure, onSuccess));
}, getOrElse: function (ma, a) { return M.chain(ma, fold(a, a, a, M.of)); }, orElse: function (ma, f) { return M.chain(ma, fold(f, f, f, function (a) { return A.of(a); })); }, initial: M.of(initial), pending: M.of(pending), progress: function (p) { return M.of(progress(p)); }, progressM: function (mp) { return M.map(mp, progress); }, failure: function (e) { return M.of(failure(e)); }, failureM: function (me) { return M.map(me, failure); }, fromM: function (ma) { return M.map(ma, success); }, fromOption: function (a, e) { return M.of(fromOption(a, e)); } });
const A = getApplicativeComposition(M, remoteData);
return Object.assign({}, A, { chain: (fa, f) => M.chain(fa, a => (a._tag === 'RemoteSuccess' ? f(a.value) : M.of(a))), alt: (fa, f) => M.chain(fa, a => (a._tag === 'RemoteSuccess' ? A.of(a.value) : f())), bimap: (fa, f, g) => M.map(fa, a => remoteData.bimap(a, f, g)), mapLeft: (ma, f) => M.map(ma, a => remoteData.mapLeft(a, f)), fold: (ma, onInitial, onPending, onFailure, onSuccess) => M.chain(ma, fold(onInitial, onPending, onFailure, onSuccess)), getOrElse: (ma, a) => M.chain(ma, fold(a, a, a, M.of)), orElse: (ma, f) => M.chain(ma, fold(f, f, f, a => A.of(a))), initial: M.of(initial), pending: M.of(pending), progress: p => M.of(progress(p)), progressM: mp => M.map(mp, progress), failure: e => M.of(failure(e)), failureM: me => M.map(me, failure), fromM: ma => M.map(ma, success), fromOption: (a, e) => M.of(fromOption(a, e)) });
}

@@ -1,19 +0,19 @@

import { FunctionN, Lazy, Predicate } from 'fp-ts/lib/function';
import { Monad2 } from 'fp-ts/lib/Monad';
import { Foldable2 } from 'fp-ts/lib/Foldable';
import { Alt2 } from 'fp-ts/lib/Alt';
import { Extend2 } from 'fp-ts/lib/Extend';
import { Traversable2 } from 'fp-ts/lib/Traversable';
import { Bifunctor2 } from 'fp-ts/lib/Bifunctor';
import { Option } from 'fp-ts/lib/Option';
import { Either } from 'fp-ts/lib/Either';
import { Eq } from 'fp-ts/lib/Eq';
import { Alternative2 } from 'fp-ts/lib/Alternative';
import { Ord } from 'fp-ts/lib/Ord';
import { Semigroup } from 'fp-ts/lib/Semigroup';
import { Monoid } from 'fp-ts/lib/Monoid';
import { Show } from 'fp-ts/lib/Show';
import { FunctionN, Lazy, Predicate } from 'fp-ts/es6/function';
import { Monad2 } from 'fp-ts/es6/Monad';
import { Foldable2 } from 'fp-ts/es6/Foldable';
import { Alt2 } from 'fp-ts/es6/Alt';
import { Extend2 } from 'fp-ts/es6/Extend';
import { Traversable2 } from 'fp-ts/es6/Traversable';
import { Bifunctor2 } from 'fp-ts/es6/Bifunctor';
import { Option } from 'fp-ts/es6/Option';
import { Either } from 'fp-ts/es6/Either';
import { Eq } from 'fp-ts/es6/Eq';
import { Alternative2 } from 'fp-ts/es6/Alternative';
import { Ord } from 'fp-ts/es6/Ord';
import { Semigroup } from 'fp-ts/es6/Semigroup';
import { Monoid } from 'fp-ts/es6/Monoid';
import { Show } from 'fp-ts/es6/Show';
export declare const URI = "RemoteData";
export declare type URI = typeof URI;
declare module 'fp-ts/lib/HKT' {
declare module 'fp-ts/es6/HKT' {
interface URItoKind2<E, A> {

@@ -20,0 +20,0 @@ RemoteData: RemoteData<E, A>;

@@ -1,28 +0,27 @@

import * as tslib_1 from "tslib";
import { constFalse, identity, constant } from 'fp-ts/lib/function';
import { isNone, isSome, none, some, fold as foldO, getShow as getShowOption } from 'fp-ts/lib/Option';
import { left, right, fold as foldEither } from 'fp-ts/lib/Either';
import { array } from 'fp-ts/lib/Array';
import { sign } from 'fp-ts/lib/Ordering';
import { pipe, pipeable } from 'fp-ts/lib/pipeable';
import { showNumber } from 'fp-ts/lib/Show';
export var URI = 'RemoteData';
import { constFalse, identity, constant } from 'fp-ts/es6/function';
import { isNone, isSome, none, some, fold as foldO, getShow as getShowOption } from 'fp-ts/es6/Option';
import { left, right, fold as foldEither } from 'fp-ts/es6/Either';
import { array } from 'fp-ts/es6/Array';
import { sign } from 'fp-ts/es6/Ordering';
import { pipe, pipeable } from 'fp-ts/es6/pipeable';
import { showNumber } from 'fp-ts/es6/Show';
export const URI = 'RemoteData';
//constructors
export var failure = function (error) { return ({
export const failure = (error) => ({
_tag: 'RemoteFailure',
error: error,
}); };
export var success = function (value) { return ({
error,
});
export const success = (value) => ({
_tag: 'RemoteSuccess',
value: value,
}); };
export var pending = {
value,
});
export const pending = {
_tag: 'RemotePending',
progress: none,
};
export var progress = function (progress) { return ({
export const progress = (progress) => ({
_tag: 'RemotePending',
progress: some(progress),
}); };
export var initial = {
});
export const initial = {
_tag: 'RemoteInitial',

@@ -34,15 +33,15 @@ };

*/
export var isFailure = function (data) { return data._tag === 'RemoteFailure'; };
export const isFailure = (data) => data._tag === 'RemoteFailure';
/**
* Returns true only if {@link RemoteData} is {@link RemoteSuccess}
*/
export var isSuccess = function (data) { return data._tag === 'RemoteSuccess'; };
export const isSuccess = (data) => data._tag === 'RemoteSuccess';
/**
* Returns true only if {@link RemoteData} is {@link RemotePending}
*/
export var isPending = function (data) { return data._tag === 'RemotePending'; };
export const isPending = (data) => data._tag === 'RemotePending';
/**
* Returns true only if {@link RemoteData} is {@link RemoteInitial}
*/
export var isInitial = function (data) { return data._tag === 'RemoteInitial'; };
export const isInitial = (data) => data._tag === 'RemoteInitial';
/**

@@ -59,3 +58,3 @@ * Takes a default value as an argument.

*/
export var getOrElse = function (f) { return function (ma) { return (isSuccess(ma) ? ma.value : f()); }; };
export const getOrElse = (f) => (ma) => (isSuccess(ma) ? ma.value : f());
/**

@@ -77,3 +76,3 @@ * Needed for "unwrap" value from {@link RemoteData} "container".

*/
export var fold = function (onInitial, onPending, onFailure, onSuccess) { return function (ma) {
export const fold = (onInitial, onPending, onFailure, onSuccess) => (ma) => {
switch (ma._tag) {

@@ -93,3 +92,3 @@ case 'RemoteInitial': {

}
}; };
};
/**

@@ -111,4 +110,4 @@ * One more way to fold (unwrap) value from {@link RemoteData}.

*/
export var toNullable = function (ma) { return (isSuccess(ma) ? ma.value : null); };
export var toUndefined = function (ma) { return (isSuccess(ma) ? ma.value : undefined); };
export const toNullable = (ma) => (isSuccess(ma) ? ma.value : null);
export const toUndefined = (ma) => (isSuccess(ma) ? ma.value : undefined);
export function fromOption(option, error) {

@@ -139,3 +138,3 @@ if (isNone(option)) {

*/
export var fromEither = foldEither(failure, success);
export const fromEither = foldEither(failure, success);
/**

@@ -160,8 +159,6 @@ * Convert {@link RemoteData} to `Either`.

export function toEither(onInitial, onPending) {
return function (data) {
return pipe(data, fold(function () { return left(onInitial()); }, function () { return left(onPending()); }, left, right));
};
return data => pipe(data, fold(() => left(onInitial()), () => left(onPending()), left, right));
}
export function fromPredicate(predicate, whenFalse) {
return function (a) { return (predicate(a) ? success(a) : failure(whenFalse(a))); };
return a => (predicate(a) ? success(a) : failure(whenFalse(a)));
}

@@ -187,3 +184,3 @@ /**

export function elem(E) {
return function (a, fa) { return fa._tag === 'RemoteSuccess' && E.equals(a, fa.value); };
return (a, fa) => fa._tag === 'RemoteSuccess' && E.equals(a, fa.value);
}

@@ -195,3 +192,3 @@ /**

export function exists(p) {
return function (fa) { return fa._tag === 'RemoteSuccess' && p(fa.value); };
return fa => fa._tag === 'RemoteSuccess' && p(fa.value);
}

@@ -202,4 +199,4 @@ /**

export function recover(f) {
var r = recoverMap(f, identity);
return function (fa) { return (fa._tag === 'RemoteFailure' ? r(fa) : fa); };
const r = recoverMap(f, identity);
return fa => (fa._tag === 'RemoteFailure' ? r(fa) : fa);
}

@@ -211,3 +208,3 @@ /**

export function recoverMap(f, g) {
return function (fa) {
return fa => {
switch (fa._tag) {

@@ -221,3 +218,3 @@ case 'RemoteInitial': {

case 'RemoteFailure': {
var b = f(fa.error);
const b = f(fa.error);
return b._tag === 'Some' ? success(b.value) : fa;

@@ -231,6 +228,6 @@ }

}
var concatPendings = function (a, b) {
const concatPendings = (a, b) => {
if (isSome(a.progress) && isSome(b.progress)) {
var progressA = a.progress.value;
var progressB = b.progress.value;
const progressA = a.progress.value;
const progressB = b.progress.value;
if (isNone(progressA.total) || isNone(progressB.total)) {

@@ -242,13 +239,13 @@ return progress({

}
var totalA = progressA.total.value;
var totalB = progressB.total.value;
var total = totalA + totalB;
var loaded = (progressA.loaded * totalA + progressB.loaded * totalB) / (total * total);
const totalA = progressA.total.value;
const totalB = progressB.total.value;
const total = totalA + totalB;
const loaded = (progressA.loaded * totalA + progressB.loaded * totalB) / (total * total);
return progress({
loaded: loaded,
loaded,
total: some(total),
});
}
var noA = isNone(a.progress);
var noB = isNone(b.progress);
const noA = isNone(a.progress);
const noB = isNone(b.progress);
if (noA && !noB) {

@@ -263,8 +260,8 @@ return b;

//instance
export var remoteData = {
export const remoteData = {
//HKT
URI: URI,
URI,
//Monad
of: function (value) { return success(value); },
ap: function (fab, fa) {
of: (value) => success(value),
ap: (fab, fa) => {
switch (fa._tag) {

@@ -285,20 +282,12 @@ case 'RemoteInitial': {

},
map: function (fa, f) {
return isSuccess(fa) ? success(f(fa.value)) : fa;
},
chain: function (fa, f) {
return isSuccess(fa) ? f(fa.value) : fa;
},
map: (fa, f) => isSuccess(fa) ? success(f(fa.value)) : fa,
chain: (fa, f) => isSuccess(fa) ? f(fa.value) : fa,
//Foldable
reduce: function (fa, b, f) {
return pipe(fa, fold(function () { return b; }, function () { return b; }, function () { return b; }, function (a) { return f(b, a); }));
},
reduceRight: function (fa, b, f) { return (isSuccess(fa) ? f(fa.value, b) : b); },
foldMap: function (M) { return function (fa, f) {
return isSuccess(fa) ? f(fa.value) : M.empty;
}; },
reduce: (fa, b, f) => pipe(fa, fold(() => b, () => b, () => b, a => f(b, a))),
reduceRight: (fa, b, f) => (isSuccess(fa) ? f(fa.value, b) : b),
foldMap: (M) => (fa, f) => isSuccess(fa) ? f(fa.value) : M.empty,
//Traversable
traverse: function (F) { return function (ta, f) {
traverse: (F) => (ta, f) => {
if (isSuccess(ta)) {
return F.map(f(ta.value), function (a) { return remoteData.of(a); });
return F.map(f(ta.value), a => remoteData.of(a));
}

@@ -308,66 +297,34 @@ else {

}
}; },
sequence: function (F) { return function (ta) {
return remoteData.traverse(F)(ta, identity);
}; },
},
sequence: (F) => (ta) => remoteData.traverse(F)(ta, identity),
//Bifunctor
bimap: function (fla, f, g) {
return pipe(fla, fold(function () { return initial; }, foldO(function () { return pending; }, progress), function (e) { return failure(f(e)); }, function (a) { return success(g(a)); }));
},
mapLeft: function (fla, f) {
return fold(function () { return initial; }, foldO(function () { return pending; }, progress), function (e) { return failure(f(e)); }, function () { return fla; })(fla);
},
bimap: (fla, f, g) => pipe(fla, fold(() => initial, foldO(() => pending, progress), e => failure(f(e)), a => success(g(a)))),
mapLeft: (fla, f) => fold(() => initial, foldO(() => pending, progress), e => failure(f(e)), () => fla)(fla),
//Alt
alt: function (fx, fy) { return fold(fy, fy, fy, function () { return fx; })(fx); },
alt: (fx, fy) => fold(fy, fy, fy, () => fx)(fx),
//Alternative
zero: function () { return initial; },
zero: () => initial,
//Extend
extend: function (fla, f) {
return pipe(fla, fold(function () { return initial; }, foldO(function () { return pending; }, progress), function () { return fla; }, function () { return success(f(fla)); }));
},
extend: (fla, f) => pipe(fla, fold(() => initial, foldO(() => pending, progress), () => fla, () => success(f(fla)))),
};
//Eq
export var getEq = function (EE, EA) {
export const getEq = (EE, EA) => {
return {
equals: function (x, y) {
return pipe(x, fold(function () { return isInitial(y); }, function () { return isPending(y); }, function (xError) {
return pipe(y, fold(constFalse, constFalse, function (yError) { return EE.equals(xError, yError); }, constFalse));
}, function (ax) {
return pipe(y, fold(constFalse, constFalse, constFalse, function (ay) { return EA.equals(ax, ay); }));
}));
},
equals: (x, y) => pipe(x, fold(() => isInitial(y), () => isPending(y), xError => pipe(y, fold(constFalse, constFalse, yError => EE.equals(xError, yError), constFalse)), ax => pipe(y, fold(constFalse, constFalse, constFalse, ay => EA.equals(ax, ay))))),
};
};
//Ord
var constLt = constant(-1);
var constEq = constant(0);
var constGt = constant(1);
export var getOrd = function (OE, OA) {
return tslib_1.__assign({}, getEq(OE, OA), { compare: function (x, y) {
return sign(pipe(x, fold(function () {
return pipe(y, fold(constEq, constLt, constLt, constLt));
}, function () {
return pipe(y, fold(constGt, constEq, constLt, constLt));
}, function (xError) {
return pipe(y, fold(constGt, constGt, function (yError) { return OE.compare(xError, yError); }, constLt));
}, function (xValue) {
return pipe(y, fold(constGt, constGt, constGt, function (yValue) { return OA.compare(xValue, yValue); }));
})));
} });
const constLt = constant(-1);
const constEq = constant(0);
const constGt = constant(1);
export const getOrd = (OE, OA) => {
return Object.assign({}, getEq(OE, OA), { compare: (x, y) => sign(pipe(x, fold(() => pipe(y, fold(constEq, constLt, constLt, constLt)), () => pipe(y, fold(constGt, constEq, constLt, constLt)), xError => pipe(y, fold(constGt, constGt, yError => OE.compare(xError, yError), constLt)), xValue => pipe(y, fold(constGt, constGt, constGt, yValue => OA.compare(xValue, yValue)))))) });
};
//Semigroup
export var getSemigroup = function (SE, SA) {
export const getSemigroup = (SE, SA) => {
return {
concat: function (x, y) {
var constX = constant(x);
var constY = constant(y);
return pipe(x, fold(function () {
return pipe(y, fold(constY, constY, constY, constY));
}, function () {
return pipe(y, fold(constX, function () { return concatPendings(x, y); }, constY, constY));
}, function (xError) {
return pipe(y, fold(constX, constX, function (yError) { return failure(SE.concat(xError, yError)); }, function () { return y; }));
}, function (xValue) {
return pipe(y, fold(constX, constX, function () { return x; }, function (yValue) { return success(SA.concat(xValue, yValue)); }));
}));
concat: (x, y) => {
const constX = constant(x);
const constY = constant(y);
return pipe(x, fold(() => pipe(y, fold(constY, constY, constY, constY)), () => pipe(y, fold(constX, () => concatPendings(x, y), constY, constY)), xError => pipe(y, fold(constX, constX, yError => failure(SE.concat(xError, yError)), () => y)), xValue => pipe(y, fold(constX, constX, () => x, yValue => success(SA.concat(xValue, yValue))))));
},

@@ -377,19 +334,13 @@ };

//Monoid
export var getMonoid = function (SL, SA) {
return tslib_1.__assign({}, getSemigroup(SL, SA), { empty: initial });
export const getMonoid = (SL, SA) => {
return Object.assign({}, getSemigroup(SL, SA), { empty: initial });
};
var showOptionNumber = getShowOption(showNumber);
const showOptionNumber = getShowOption(showNumber);
//Show
export var getShow = function (SE, SA) { return ({
show: fold(function () { return 'initial'; }, foldO(function () { return 'pending'; }, function (progress) {
return "progress({ loaded: " + showNumber.show(progress.loaded) + ", total: " + showOptionNumber.show(progress.total) + " })";
}), function (e) { return "failure(" + SE.show(e) + ")"; }, function (a) { return "success(" + SA.show(a) + ")"; }),
}); };
var _a = pipeable(remoteData), alt = _a.alt, ap = _a.ap, apFirst = _a.apFirst, apSecond = _a.apSecond, bimap = _a.bimap, chain = _a.chain, chainFirst = _a.chainFirst, duplicate = _a.duplicate, extend = _a.extend, flatten = _a.flatten, foldMap = _a.foldMap, map = _a.map, mapLeft = _a.mapLeft, reduce = _a.reduce, reduceRight = _a.reduceRight;
export const getShow = (SE, SA) => ({
show: fold(() => 'initial', foldO(() => 'pending', progress => `progress({ loaded: ${showNumber.show(progress.loaded)}, total: ${showOptionNumber.show(progress.total)} })`), e => `failure(${SE.show(e)})`, a => `success(${SA.show(a)})`),
});
const { alt, ap, apFirst, apSecond, bimap, chain, chainFirst, duplicate, extend, flatten, foldMap, map, mapLeft, reduce, reduceRight, } = pipeable(remoteData);
export { alt, ap, apFirst, apSecond, bimap, chain, chainFirst, duplicate, extend, flatten, foldMap, map, mapLeft, reduce, reduceRight, };
export function combine() {
var list = [];
for (var _i = 0; _i < arguments.length; _i++) {
list[_i] = arguments[_i];
}
export function combine(...list) {
if (list.length === 0) {

@@ -396,0 +347,0 @@ return remoteData.of([]);

{
"name": "@devexperts/remote-data-ts",
"version": "2.0.3",
"version": "2.0.4",
"main": "dist/index.js",

@@ -16,2 +16,3 @@ "module": "es6/index.js",

"prepublishOnly": "npm run test && npm run build",
"postbuild": "import-path-rewrite",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0",

@@ -26,2 +27,3 @@ "version": "npm run changelog && git add CHANGELOG.md"

"conventional-changelog-cli": "^2.0.21",
"import-path-rewrite": "github:gcanti/import-path-rewrite",
"jest": "^24.8.0",

@@ -39,3 +41,3 @@ "jest-cli": "^24.8.0",

"io-ts": "^2.0.0",
"io-ts-types": "^0.5.0",
"io-ts-types": "^0.5.7",
"tslib": "^1.9.3"

@@ -42,0 +44,0 @@ },

@@ -5,4 +5,5 @@ {

"outDir": "./es6",
"target": "es6",
"module": "es6"
}
}
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