Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename and improve fromPromise #98

Merged
merged 5 commits into from
May 7, 2017
Merged

Rename and improve fromPromise #98

merged 5 commits into from
May 7, 2017

Conversation

Avaq
Copy link
Member

@Avaq Avaq commented May 6, 2017

  • Merges master to get @SoullessWaffle's improvements to the documentation
  • Renames fromPromise to encaseP.
  • Adds tryP, the nullary version of encaseP.
  • Prevents Promises from catching (and subsequently silently ignoring) errors thrown synchronously in transformations following the encasement of a Promise.

This last change is perhaps best explained through code:

Before:

> Future.tryP(_ => Promise.resolve(1)).map(x => { throw new Error('kaputt') }).value(console.log)
(node:8546) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: kaputt

After:

> Future.tryP(_ => Promise.resolve(1)).map(x => { throw new Error('kaputt') }).value(console.log)
Future.tryP(_ => Promise.resolve(1)).map(x => { throw new Error('kaputt') }).value(console.log)
                                                ^
Error: kaputt

Closes #92

@codecov-io
Copy link

codecov-io commented May 7, 2017

Codecov Report

Merging #98 into 6.0 will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@         Coverage Diff         @@
##            6.0    #98   +/-   ##
===================================
  Coverage   100%   100%           
===================================
  Files        36     36           
  Lines       962    972   +10     
===================================
+ Hits        962    972   +10
Impacted Files Coverage Δ
src/encase-p.js 100% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3d0f4f4...2991699. Read the comment docs.

@Avaq Avaq merged commit 15b7f52 into 6.0 May 7, 2017
@Avaq Avaq deleted the avaq/encasep branch May 7, 2017 18:09
Avaq added a commit that referenced this pull request May 13, 2017
Breaking changes

- #80 The ES5 import has been moved from `fluture/es5` to `fluture`.
- #80 The `Future#hook` *method* (but not the function) has been removed.
- #80 Old environments are asked to bring their own polyfills for
  `Object.create`, `Object.assign` and `Array.isArray`.
- #96 The arguments to the `ap`-method have been flipped back.
- #97 `and` and `or` no longer run the two Futures in parallel.
- #98 `fromPromise` has been renamed to `encaseP`.

New features

- #80 Added an ES6 module for use with tools like [Rollup](https://rollupjs.org/).
- #80 All transformations, including recursive `chain`, are now stack safe!
- #80 Added `isNever`.
- #80 Added aliases `attempt = try`, `go = do`, `lastly = finally`.
- #98 Added `tryP`, the nullary version of `encaseP`.

Bug fixes and improvements

- Added fast failure to `encase` and `encaseP`.
- #98 Errors thrown while transforming Futures produced by `tryP` or `encaseP`
  no longer get caught (and silenced) by the Promise.
- #80 User-supplied functions no longer have strict arity requirements.
- #80 `Future.hook` no longer cancels the acquire Future after it has settled.
- #80 `Future.hook` now always cancels running Futures appropriately.
- #102 Supplying incompatible or outdated instances of Fluture now throws more
  sensible error messages.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants