dojo / has

:rocket: Dojo 2 - feature detection library.
http://dojo.io
Other
3 stars 18 forks source link

Allow Thenables as return values for feature tests #2

Closed kitsonk closed 7 years ago

kitsonk commented 8 years ago

Currently all features tests must be async. It would be nice if has supported the ability to add a feature test that sets the result based on the resolution of a Thenable.

There are considerations of if a feature is being defined async, and that the feature is requested sync before the detection is resolved, could cause some false issues. has() could be modified to not error if a unresolved Thenable feature is being detected and exists() could return false.

The ability to return Promises and the like from the API would likely only complicate things and "bloat" the dependencies of has though, just handling Thenables would require no additional dependencies, as it would simply detect the Thenable and chain on the setting of the result.