lazy.js
lazy.js copied to clipboard
clearTimeout not defined in all environments
The lazy.js getCancelCallback() function can return clearTimeout .
In NetSuite (which uses a Rhino based javascript backend) clearTimeout() is not defined, and hence throws an error just loading the script.
In general, the *Timeout() functions are not there in NetSuite, but lazy.js is still otherwise awesome in that environment!
I might add this makes lazy.js 0.4.0 unusable as-is in the netsuite javascript environment.
OK! Sounds like the fix is pretty straightforward: don't assume the existence of clearTimeout on all platforms.
I must admit I've never heard of NetSuite, and I've done virtually no work in Rhino before. I'll do a little research and (hopefully) come up with a solution that makes sense. I've been meaning to get a version 0.4.1 out the door soonish anyway.
My workaround was to just define clearTimeout(){} in some code before including lazy.js.
Look forward to 0.4.1 - Lazy is slowly replacing my previous favorite (lodash)!
You can try this: https://gist.github.com/nbeloglazov/9633318 Works for me.
@mjwong thanks for the link, but unfortunately we don't get access to the underlying Rhino in NetSuite code. :(
@dtao is this resolved in 0.4.1 or 0.4.2?