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

should return an error if passed object is not a promise #15

Closed
agarwalkartik opened this issue Jun 7, 2018 · 6 comments
Closed

should return an error if passed object is not a promise #15

agarwalkartik opened this issue Jun 7, 2018 · 6 comments

Comments

@agarwalkartik
Copy link

If the passed object is not a promise then to() should return an error.
This feature is quite useful when using await-to-js in a non type script environment.

@json2d
Copy link

json2d commented Jun 10, 2018

I personally find the await fuzzy type handling helpful in some cases. Would be nice to preserve that behavior with to()

eg.

let fuzzyAsync = async (maybePromiseFn) => await maybePromiseFn()

@agarwalkartik
Copy link
Author

@bitstrider Hey, I didn't understand you, can you be little more descriptive with "await fuzzy type" handling

@json2d
Copy link

json2d commented Jun 15, 2018

@agarwalkartik I give a better example in the issue here #17 if that helps.

My argument is that the normal behavior when awaiting a non-promise type is to simply let the it pass through, and so this should be the same with on().

// the desired behavior
const A = await 42; //> 42
const [err, B] = await on(42); //> [null, 42]

@agarwalkartik
Copy link
Author

@bitstrider Yes I agree, any ideas on how can we implement it in this library?

@json2d
Copy link

json2d commented Oct 9, 2018

@agarwalkartik I ended up creating a new project to implement the feature since this project seems to be unmaintained https://github.com/bitstrider/await-on

@scopsy
Copy link
Owner

scopsy commented Nov 21, 2018

Not exactly sure that the library should support this fuzziness. feel free to create your own helper function suited for your needs. This is library is about sharing a concept and the use of it should not be tied to specific implementation.

@scopsy scopsy closed this as completed Nov 21, 2018
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

No branches or pull requests

3 participants