Added promise support by PlasmaPower · Pull Request #298 · node-ffi/node-ffi · GitHub
Skip to content

Added promise support#298

Open
PlasmaPower wants to merge 1 commit into
node-ffi:masterfrom
PlasmaPower:promises
Open

Added promise support#298
PlasmaPower wants to merge 1 commit into
node-ffi:masterfrom
PlasmaPower:promises

Conversation

@PlasmaPower

Copy link
Copy Markdown

With JS as a whole moving toward promises, I think it's important to natively support promises. The simplification of the promises tests vs the async tests shows this.

JSHint seems to be throwing errors all over the place, even for things I didn't touch. If I styled something wrong, please let me know.

Comment thread package.json

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The 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.

@PlasmaPower

Copy link
Copy Markdown
Author

Hmm, the build is failing on node 0.10 because it doesn't have a builtin promise implementation. I could supply any-promise bluebird or something, but that would add a dev dependency that isn't needed in 90% of cases. Thoughts?

Edit: I'm going to register bluebird as the provider for the tests, with a note about node 0.10.

Edit 2: that seems to be working.

@PlasmaPower

Copy link
Copy Markdown
Author

Am I correct that the only docs are in the wiki, which I can't package with a PR? In that case, I'll edit the wiki to add promise information after this merges.

@PlasmaPower

Copy link
Copy Markdown
Author

The appveyor builds appear to be failing because of another any-promise issue. I'm not quite sure how they work, but I'll try to figure it out.

Edit: It appears to be due to the windows file listing order, which mocha uses.

@PlasmaPower

Copy link
Copy Markdown
Author

The build seems to be passing now.

@PlasmaPower

Copy link
Copy Markdown
Author

The appveyor test seems to be failing only on one node version (3.2), and on variadic args (which I didn't touch). I think it's a race condition; I'm going to retry the build.

@PlasmaPower

Copy link
Copy Markdown
Author

And it's now passing. Looks like there's a race condition in variadic args, or at least the tests for it

Anybody have any comments on this PR, now that the builds are passing?

@PlasmaPower

Copy link
Copy Markdown
Author

Any thoughts @TooTallNate? This PR only adds a useful feature, it doesn't change or remove features, so in my opinion if you have nothing against this PR you should merge it.

Comment thread lib/_foreign_function.js
var assert = require('assert')
, debug = require('debug')('ffi:_ForeignFunction')
, ref = require('ref')
, Promise = require('any-promise')

Copy link
Copy Markdown

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.

@PlasmaPower PlasmaPower Apr 27, 2016

Copy link
Copy Markdown
Author

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.

@RobLoach

Copy link
Copy Markdown

Didn't realize we're still testing Node 0.10. I'll make an issue about deprecating it. Thanks @PlasmaPower!

@king6cong

Copy link
Copy Markdown

Any updates? 😄

@PlasmaPower

Copy link
Copy Markdown
Author

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.

3 participants