Socket
Socket
Sign inDemoInstall

fluture

Package Overview
Dependencies
Maintainers
2
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 12.1.1 to 12.2.0

src/bichain.js

3

index.d.ts

@@ -82,2 +82,5 @@ /// <reference lib="es2015.generator" />

/** Create a Future using the inner value of the given Future. See https://github.com/fluture-js/Fluture#bichain */
export function bichain<LA, LB, RB>(lmapper: (reason: LA) => FutureInstance<LB, RB>): <RA>(rmapper: (value: RA) => FutureInstance<LB, RB>) => (source: FutureInstance<LA, RA>) => FutureInstance<LB, RB>
/** Map over both branches of the given Bifunctor at once. See https://github.com/fluture-js/Fluture#bimap */

@@ -84,0 +87,0 @@ export function bimap<LA, LB>(lmapper: (reason: LA) => LB): <RA, RB>(rmapper: (value: RA) => RB) => (source: FutureInstance<LA, RA>) => FutureInstance<LB, RB>

@@ -18,2 +18,3 @@ export {

export {bimap} from './src/bimap.js';
export {bichain} from './src/bichain.js';
export {both} from './src/both.js';

@@ -20,0 +21,0 @@ export {cache} from './src/cache.js';

6

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

@@ -63,3 +63,3 @@ "main": "index.cjs",

"dependencies": {
"sanctuary-show": "^1.0.0",
"sanctuary-show": "^2.0.0",
"sanctuary-type-identifiers": "^2.0.0"

@@ -77,3 +77,3 @@ },

"oletus": "^2.0.0",
"ramda": "^0.26.1",
"ramda": "^0.27.0",
"remark-cli": "^7.0.0",

@@ -80,0 +80,0 @@ "remark-validate-links": "^9.0.1",

@@ -94,3 +94,3 @@ # [![Fluture](logo.png)](#butterfly)

Fluture is hosted in full with all of its dependencies at
https://cdn.jsdelivr.net/gh/fluture-js/Fluture@12.1.1/dist/bundle.js
https://cdn.jsdelivr.net/gh/fluture-js/Fluture@12.2.0/dist/bundle.js

@@ -175,2 +175,3 @@ This script will add `Fluture` to the global scope.

- [`chain`: Asynchronously process the success value in a Future](#chain)
- [`bichain`: Asynchronously process the success or failure value in a Future](#bichain)
- [`swap`: Swap the success with the failure value](#swap)

@@ -867,2 +868,38 @@ - [`mapRej`: Synchronously process the failure value in a Future](#maprej)

#### bichain
```hs
bichain :: (a -> Future c d) -> (b -> Future c d) -> Future a b -> Future c d
```
Sequence a new Future using either the resolution or the rejection value from
another. Similarly to [`bimap`](#bimap), `bichain` expects two functions. But
instead of returning the new *value*, bichain expects Futures to be returned.
```js
> fork (log ('rejection'))
. (log ('resolution'))
. (bichain (resolve) (x => resolve (x + 1)) (resolve (41)))
[resolution]: 42
> fork (log ('rejection'))
. (log ('resolution'))
. (bichain (x => resolve (x + 1)) (resolve) (reject (41)))
[resolution]: 42
```
For comparison, an approximation with Promises is:
```js
> Promise.resolve (41)
. .then (x => Promise.resolve (x + 1), Promise.resolve)
. .then (log ('resolution'), log ('rejection'))
[resolution]: 42
> Promise.reject (41)
. .then (Promise.resolve, x => Promise.resolve (x + 1))
. .then (log ('resolution'), log ('rejection'))
[resolution]: 42
```
#### swap

@@ -869,0 +906,0 @@

Sorry, the diff of this file is not supported yet

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