Comparing version 0.5.0 to 0.5.1
{ | ||
"name": "letta", | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"description": "Promisify sync, async or generator function, using [relike][]. Kind of promisify, but lower level. Full compatibility with [co][]4 and passing 100% of its tests.", | ||
@@ -5,0 +5,0 @@ "repository": "hybridables/letta", |
@@ -11,3 +11,5 @@ # [letta][author-www-url] [![npmjs.com][npmjs-img]][npmjs-url] [![The MIT License][license-img]][license-url] [![npm downloads][downloads-img]][downloads-url] | ||
- [Highlights](#highlights) | ||
- [Note](#note) | ||
- [Notes](#notes) | ||
* [Sync and async functions](#sync-and-async-functions) | ||
* [Absolutely silent - never crash](#absolutely-silent---never-crash) | ||
- [Install](#install) | ||
@@ -50,3 +52,5 @@ - [Usage](#usage) | ||
## Note | ||
## Notes | ||
### Sync and async functions | ||
Note that it treats functions as asynchronous, based on [is-async-function][]. | ||
@@ -58,2 +62,47 @@ | ||
### Absolutely silent - never crash | ||
Using `letta` you should be absolutely careful. Because it makes your application absolutely silent. Which means | ||
if you have some `ReferenceError` or something like it, after the execution of `letta` it will be muted. And the | ||
only way to handle it is through `.catch` from the returned promise. | ||
Let's visualise it. In the following examples we'll use [relike][] first and then `letta`, and you can see the differences. | ||
```js | ||
var relike = require('relike') | ||
var promise = relike(function () { | ||
return 123 | ||
}) | ||
promise.then(console.log, err => { | ||
console.error(err.stack) | ||
// => errors only happened in function wrapped by relike | ||
}) | ||
foo | ||
// => throws ReferenceError directly, immediately | ||
// and your application will crash | ||
``` | ||
But the things, using `letta` are little bit different, because we have listeners on `unhandledRejection` and | ||
on `uncaughtException` events. The same example from above, using `letta` | ||
```js | ||
var letta = require('letta') | ||
var promise = letta(function () { | ||
return 123 | ||
}) | ||
promise.then(console.log, err => { | ||
console.error(err.stack) | ||
// => ReferenceError: foo is not defined | ||
}) | ||
foo | ||
// => never throws directly, never crash | ||
// this error should be handled from the promise | ||
``` | ||
So, if you don't want this behavior, you should use [relike][]. But if you want generators support, you should | ||
do some little wrapper for [relike][]. | ||
## Install | ||
@@ -417,3 +466,3 @@ ``` | ||
* [promise2stream](https://www.npmjs.com/package/promise2stream): Transform ES2015 Promise to Stream - specifically, Transform Stream using… [more](https://www.npmjs.com/package/promise2stream) | [homepage](https://github.com/hybridables/promise2stream) | ||
* [relike-all](https://www.npmjs.com/package/relike-all): Promisify all functions in an object, using `relike`. | [homepage](https://github.com/hybridables/relike-all) | ||
* [relike-all](https://www.npmjs.com/package/relike-all): Promisify all functions in an object, using [relike][]. | [homepage](https://github.com/hybridables/relike-all) | ||
* [relike-value](https://www.npmjs.com/package/relike-value): Create promise from sync, async, string, number, array and so on. Handle… [more](https://www.npmjs.com/package/relike-value) | [homepage](https://github.com/hybridables/relike-value) | ||
@@ -431,3 +480,2 @@ * [relike](https://www.npmjs.com/package/relike): Simple promisify async or sync function with sane defaults. Lower level than… [more](https://www.npmjs.com/package/relike) | [homepage](https://github.com/hybridables/relike) | ||
[through2]: https://github.com/rvagg/through2 | ||
[bluebird]: https://github.com/petkaantonov/bluebird | ||
@@ -441,2 +489,3 @@ [co]: https://github.com/tj/co | ||
[relike-value]: https://github.com/hybridables/relike-value | ||
[through2]: https://github.com/rvagg/through2 | ||
@@ -443,0 +492,0 @@ [npmjs-url]: https://www.npmjs.com/package/letta |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27267
530