andrewplummer / Sugar

A Javascript library for working with native objects.
https://sugarjs.com/
MIT License
4.53k stars 306 forks source link

Is there a way to check if function was delayed? #616

Open Costegillio opened 6 years ago

Costegillio commented 6 years ago

Greetings!

How can i check if function called by Sugar.Function.delay(myFunction, 500)?

Thx!

andrewplummer commented 6 years ago

In version 2+ there is a property _sugar_timers that exists on a delayed function and can be used in a pinch, however it should be considered private and subject to change.

It might help to know specifically what you're trying to do... there might be a different approach....

andrewplummer commented 6 years ago

Would like to revisit this for the next major version. I could see how it could be useful but I would like to avoid mapping custom properties onto native objects if at all possible. This happens now with the _utc property on dates, however I would prefer to remove that going forward. Unfortunately, this may be hard to do without it. I suppose something like Sugar.Function.isDelayed() may work ... would that work for you if it were possible?