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

Added promise support #298

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

PlasmaPower
Copy link

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.

"ref": "1",
"ref-struct": "1",
"nan": "2"
"ref-struct": "1"
Copy link
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
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
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
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
Author

The build seems to be passing now.

@PlasmaPower
Copy link
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
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
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.

@@ -6,6 +6,7 @@
var assert = require('assert')
, debug = require('debug')('ffi:_ForeignFunction')
, ref = require('ref')
, Promise = require('any-promise')

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.

Copy link
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

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

@king6cong
Copy link

Any updates? 😄

@PlasmaPower
Copy link
Author

Node 0.10 still hasn't been deprecated, but at this point if we were inclined to merge this I'd be in favor of deprecating Node 0.10 or skipping the test on node 0.10, then not using any-promise but instead the global Promise.

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