Closed agarwalkartik closed 5 years ago
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()
@bitstrider Hey, I didn't understand you, can you be little more descriptive with "await fuzzy type" handling
@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]
@bitstrider Yes I agree, any ideas on how can we implement it in this library?
@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
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.
If the passed object is not a promise then
to()
should return an error. This feature is quite useful when usingawait-to-js
in a non type script environment.