Detalhes do pacote

@nll/datum

nullpub17.3kMPL-2.03.5.0

ADT for handling fetchable and refreshable data

fp-ts, adt, AsyncData

readme (leia-me)

An fp-ts style ADT to capture the concept of an Option in progress.

build status Coverage Status npm downloads

dependency status dev dependency status peer dependency status

@nll/datum

ADT for asynchronous data updated to work with fp-ts@2+.

Version 3+ release only includes an es module build. It also references the fp-ts/es6 build.

Documentation

Full Documentation

Usage Example

npm i @nll/datum fp-ts
import { sequenceT } from 'fp-ts/es6/Apply';
import { pipe } from 'fp-ts/es6/pipeable';

import {
  DatumEither,
  datumEither,
  failure,
  initial,
  map,
  pending,
  success,
  toRefresh
} from '../src/DatumEither';

const sequence = sequenceT(datumEither);

// Here are some DatumEithers
const someInitial: DatumEither<string, string> = initial; // Type: Initial
const somePending: DatumEither<string, string> = pending; // Type: Pending
const someSuccess: DatumEither<string, string> = success('DATA!'); // Type: Replete<Right<string>>
const someFailure: DatumEither<string, string> = failure('ERROR!'); // Type: Replete<Left<string>>

// Here are some Refreshing Datume
const someRefreshingSuccess = toRefresh(someSuccess); // Type: Refresh<Right<string>>
const someRefreshingFailure = toRefresh(someFailure); // Type: Refresh<Left<string>>

const result1 = pipe(
  sequence(someInitial, somePending, someSuccess),
  map(([a, b, c]) => a + b + c)
);
console.log(result1);
/**
 * The initial short circuits the sequence
 * result1 === initial
 */

const result2 = pipe(
  sequence(someRefreshingSuccess, someRefreshingFailure),
  map(([a, b]) => a + b)
);
console.log(result2);
/**
 * The failure shortcircuits the sequence.
 * result2 === refresh(left('ERROR!'))
 */

const result3 = pipe(
  sequence(someSuccess, someRefreshingSuccess),
  map(([a, b]) => a + b)
);
console.log(result3);
/**
 * All values are good, so map is called, since one of the DatumEithers is refreshing, the sequence is refreshing
 * result3 = refresh(right('DATA!DATA!'))
 */

changelog (log de mudanças)

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

4.0.0 (2022-02-04)

⚠ BREAKING CHANGES

  • This commit removes and replaces existing apis Co-authored-by: Sam Protas sprotas@50onred.com

Features

  • remove mega instances and old ap (#21) (00d934d)

Bug Fixes

3.5.0 (2021-04-01)

Features

  • deprecate ap/chain disagreement and standalone instances (#19) (484d81d)
  • implement initial DatumThese ADT (#15) (0ee8a3d)

3.4.0 (2021-02-06)

Features

  • add Valued type and fix docs (2db2625)

3.3.2 (2021-02-05)

Bug Fixes

  • expand types on DatumEither constructors (472c7ae), closes #12

3.3.1 (2021-02-02)

Bug Fixes

  • correct type for fromOption (b10a388), closes #11

3.3.0 (2020-11-13)

Features

  • implement experimental OneShot adt based on Datum (6c47f40)

3.2.0 (2020-10-15)

Features

  • export sequenceTuple and sequenceStruct (968aa84)

3.1.0 (2020-05-05)

Features

  • Re-export modules from a main index file (263644f)

3.0.3 (2020-03-11)

3.0.2 (2020-03-11)

3.0.1 (2020-03-07)

Bug Fixes

  • cleaned up testing config (a8f48fc)
  • moved prepare script and update build (6f2bbcd)

3.0.0 (2020-03-06)

Bug Fixes

  • fix coveralls command in nodejs workflow (26d656b)
  • fix env vars for coveralls (4beec9c)
  • try using the coveralls action (95a6661)

3.0.0-prerelease.0 (2020-03-06)

⚠ BREAKING CHANGES

  • simplified api

Features

  • migrate to es6 only build (3d65d65)

2.7.2-prerelease.0 (2020-03-06)

2.7.1 (2020-01-29)

Bug Fixes

  • added since tags to modules for documentation (6aa72d0)
  • bumped deps, refactored constants, cleaned up tests (68ad17e)

2.7.0 (2019-09-17)

Features

  • added DatumEither features (8a71a40)

2.6.3 (2019-09-16)

2.6.2 (2019-09-12)

Bug Fixes

  • added source to package.json files so sourcemaps work (a081616)

2.6.1 (2019-08-29)

2.6.0 (2019-08-26)

Features

  • added additional pipeable Datum operators that were missed (ae71d30)

2.5.1 (2019-08-22)

Bug Fixes

  • removed refershFoldR hangover from initial work (2922490)

2.5.0 (2019-08-22)

Features

  • added better typing to exports of initial and pending from DatumEither (2b95784)

2.4.0 (2019-08-20)

Bug Fixes

  • various fixes to Datum to pass tests (4769c24)

Features

  • add fromNullable for DatumEither (c3d2f21)

2.3.1 (2019-08-20)

Bug Fixes

  • various fixes to Datum to pass tests (4769c24)

2.3.0 (2019-08-16)

Features

  • additions to DatumEither (e7e2e7a)

2.2.1 (2019-08-14)

2.2.0 (2019-08-14)

Features

  • fromEither and fromOption for DatumEither (7a24d63)

2.1.0 (2019-08-14)

Features

  • added more documentation and helper functions (91de033)

2.0.2 (2019-08-14)

2.0.1 (2019-08-14)

2.0.0 (2019-08-13)

Features