-
Notifications
You must be signed in to change notification settings - Fork 415
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
Added promise support #298
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,13 +60,16 @@ function Library (libfile, funcs, lib) { | |
, fopts = info[2] | ||
, abi = fopts && fopts.abi | ||
, async = fopts && fopts.async | ||
, promise = fopts && fopts.promise | ||
, varargs = fopts && fopts.varargs | ||
|
||
if (varargs) { | ||
lib[func] = VariadicForeignFunction(fptr, resultType, paramTypes, abi) | ||
} else { | ||
var ff = ForeignFunction(fptr, resultType, paramTypes, abi) | ||
lib[func] = async ? ff.async : ff | ||
if (async) lib[func] = ff.async | ||
else if (promise) lib[func] = ff.promise | ||
else lib[func] = ff | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I should have brackets here, let me know. |
||
} | ||
}) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,13 +23,15 @@ | |
}, | ||
"main": "./lib/ffi", | ||
"dependencies": { | ||
"any-promise": "^1.1.0", | ||
"bindings": "~1.2.0", | ||
"debug": "2", | ||
"nan": "2", | ||
"ref": "1", | ||
"ref-struct": "1", | ||
"nan": "2" | ||
"ref-struct": "1" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NPM did reordered nan and ref-struct by itself. I can change it back if you'd like, but NPM seems to want it this way. |
||
}, | ||
"devDependencies": { | ||
"bluebird": "^3.3.4", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use standard Promise instead of Bluebird? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We test Node 0.10. |
||
"fs-extra": "^0.23.1", | ||
"mocha": "*", | ||
"ref-array": "1" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Node 0.10 doesn't have a builtin Promise implementation | ||
// Because of that, we use Bluebird for tests | ||
// We need to run this before requiring the project | ||
|
||
if (!require('any-promise/implementation')) { | ||
require('any-promise/register')('bluebird') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't need this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes we do, because travis runs on Node 0.10. It's literally in the comment above that (I suppose the fact that we test it wasn't though). |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need
any-promise
? Node 0.10 is extremely old, and standard Promises were introduced in Node 0.12. Could we just deprecate 0.10? Node 6 just came out.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We still test 0.10, and also a lot of users use bluebird which has
.finally
. Our promises should match the user's, that's the point of any-promise.