@typed/fp
Version:
Data Structures and Resources for fp-ts
59 lines • 1.64 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.map = exports.loadEnv = exports.toReplete = exports.toRefresh = exports.toLoading = exports.toNoData = void 0;
const tslib_1 = require("tslib");
/**
* RefData is a collection of helpers for working with Refs that manage Data.
* @since 0.12.1
*/
const function_1 = require("fp-ts/function");
const D = (0, tslib_1.__importStar)(require("./Data"));
const E = (0, tslib_1.__importStar)(require("./Env"));
const Ref = (0, tslib_1.__importStar)(require("./Ref"));
/**
* @since 0.12.1
* @category Combinator
*/
function toNoData(rd) {
return rd.update(() => E.of(D.noData));
}
exports.toNoData = toNoData;
/**
* @since 0.12.1
* @category Combinator
*/
function toLoading(rd) {
return rd.update((0, function_1.flow)(D.toLoading, E.of));
}
exports.toLoading = toLoading;
/**
* @since 0.12.1
* @category Combinator
*/
function toRefresh(value, progress) {
return (rd) => rd.update(() => E.of(D.refresh(value, progress)));
}
exports.toRefresh = toRefresh;
/**
* @since 0.12.1
* @category Combinator
*/
function toReplete(value) {
return (rd) => rd.update(() => E.of(D.replete(value)));
}
exports.toReplete = toReplete;
/**
* @since 0.12.1
* @category Combinator
*/
function loadEnv(env) {
return (rd) => (0, function_1.pipe)(rd, toLoading, E.chainW(() => rd.update(() => (0, function_1.pipe)(env, E.map(D.replete)))));
}
exports.loadEnv = loadEnv;
/**
* @since 0.12.1
* @category Combinator
*/
const map = (f) => (ref) => (0, function_1.pipe)(ref, Ref.map(D.map(f)));
exports.map = map;
//# sourceMappingURL=RefData.js.map