typechecker icon indicating copy to clipboard operation
typechecker copied to clipboard

Generator Functions

Open devmckeon opened this issue 8 years ago • 4 comments

I don't think your implementation of isFunction, considers generator functions. I think you should probably do a test for (typeof x==='function') first, instead of only looking at the to string output and looking for regular and async function types. Unless of course, this is intentional... in which case I would recommend adding that intention to the documentation. Regardless, you may want to consider adding an isGenerator test. =)

devmckeon avatar Sep 20 '18 03:09 devmckeon

I think the issue is that sometimes functions can be returned as objects via typeof (like es5 class workarounds). Hence why Object.prototype.toString.call(function () {}) is used, which isn't the same as (function () {}).toString(). Perhaps this behaviour is more reliable now (ecmascript has certainly refined itself over the years). Can you send me a fixture for generator functions, that I should test for.

balupton avatar Sep 20 '18 06:09 balupton

I am currently preoccupied with tasks with revenue potential as my finances have depleted, so FOSS issues have been pushed to the backburner. If you want to speed them up on my queue, then consider making them a paid task by posting a bounty, as currently I earn nothing from my open-source work, so it cannot be a priority. Details for posting a bounty on this issue to incentivise its accomplishment sooner can be found here: https://bevry.me/bounties/

Otherwise a pull request will be the best means.

balupton avatar Nov 27 '18 01:11 balupton

https://devdocs.io/node/util#util_util_types_isgeneratorfunction_value

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/isGenerator

could be ways to go about this

balupton avatar Dec 07 '18 03:12 balupton

PR welcome

balupton avatar Nov 18 '19 04:11 balupton