[Pkg-javascript-commits] [node-universalify] 01/03: New upstream version 0.1.1
Julien Puydt
julien.puydt at laposte.net
Sun Jul 23 15:36:42 UTC 2017
This is an automated email from the git hooks/post-receive script.
jpuydt-guest pushed a commit to branch master
in repository node-universalify.
commit 55360974a77fb22864e1c994148fef9908b85493
Author: Julien Puydt <julien.puydt at laposte.net>
Date: Sun Jul 23 10:38:40 2017 +0200
New upstream version 0.1.1
---
README.md | 4 ++--
index.js | 2 +-
package.json | 2 +-
test/from-promise.js | 11 +++++++++++
4 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/README.md b/README.md
index f5b5da6..d0d9652 100644
--- a/README.md
+++ b/README.md
@@ -36,7 +36,7 @@ fn('Hello World!')
fn('Hi!', (error, result) => {
if (error) return console.error(error)
console.log(result)
- // -> Hello World!
+ // -> Hi!
})
```
@@ -64,7 +64,7 @@ fn('Hello World!')
fn('Hi!', (error, result) => {
if (error) return console.error(error)
console.log(result)
- // -> Hello World!
+ // -> Hi!
})
```
diff --git a/index.js b/index.js
index e4dc180..0c9ba39 100644
--- a/index.js
+++ b/index.js
@@ -20,6 +20,6 @@ exports.fromPromise = function (fn) {
return Object.defineProperty(function () {
const cb = arguments[arguments.length - 1]
if (typeof cb !== 'function') return fn.apply(this, arguments)
- else fn.apply(this, arguments).then(r => cb(null, r)).catch(cb)
+ else fn.apply(this, arguments).then(r => cb(null, r), cb)
}, 'name', { value: fn.name })
}
diff --git a/package.json b/package.json
index 5c4b211..fc791ae 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "universalify",
- "version": "0.1.0",
+ "version": "0.1.1",
"description": "Make a callback- or promise-based function support both promises and callbacks.",
"keywords": [
"callback",
diff --git a/test/from-promise.js b/test/from-promise.js
index ede45f4..adaa523 100644
--- a/test/from-promise.js
+++ b/test/from-promise.js
@@ -63,3 +63,14 @@ test('fromPromise() sets correct .name', t => {
t.is(res.name, 'hello')
t.end()
})
+
+test('fromPromise() handles an error in callback correctly', t => {
+ // We need to make sure that the callback isn't called twice if there's an
+ // error inside the callback. This should instead generate an unhandled
+ // promise rejection. tape swallows this rejection for us.
+ t.plan(1)
+ fn(1, 2, err => {
+ t.ifError(err, 'no error here')
+ throw new Error('some callback error')
+ })
+})
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-universalify.git
More information about the Pkg-javascript-commits
mailing list