lazy.js icon indicating copy to clipboard operation
lazy.js copied to clipboard

clearTimeout not defined in all environments

Open ShawnTalbert opened this issue 10 years ago • 5 comments
trafficstars

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!

ShawnTalbert avatar Jan 11 '15 05:01 ShawnTalbert

I might add this makes lazy.js 0.4.0 unusable as-is in the netsuite javascript environment.

ghost avatar Jan 27 '15 18:01 ghost

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.

dtao avatar Jan 29 '15 03:01 dtao

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)!

ShawnTalbert avatar Jan 30 '15 21:01 ShawnTalbert

You can try this: https://gist.github.com/nbeloglazov/9633318 Works for me.

mjwong avatar Jun 23 '15 07:06 mjwong

@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?

ShawnTalbert avatar Nov 06 '15 01:11 ShawnTalbert