chroma.js
chroma.js copied to clipboard
Feature Request: Google Apps Script Support
Amazing library, thanks for all your work.
It would be great if Chroma worked out-of-the-box with Google Apps Script.
If I:
- Copy and paste the latest
chroma.js
release into a script file in an apps script project - Write a function like
function test() { chroma('red'); }
- Run the function
I get the error TypeError: Cannot convert null to an object. (line 198, file "chroma")
. It points me to the line
198: return new (Function.prototype.bind.apply( chroma.Color, [ null ].concat( args) ));
in Chroma.js.
Apps Script uses ES3 with a few cherrypicked ES5 features. chroma().contrast
works if I include an Array.includes()
polyfill in the project, but chroma('color')
still doesn't work. I assume the problem is some other modern-ish function that Chroma is using that isn't supported in Apps Script? I've tried running it through Babel first, but no luck.
At the moment I have no plan of supporting EcmaScript 3 (which came out 20 years ago!). Sorry if that means you can't use chroma.js in Google App scripts.
This is really Google's fault, and.. Google does have a "Closure Compiler" thingy that transcompiles to ES3.
Now that Google Apps Script supports the V8 runtime with modern Javascript features, I'm happy to report that Chroma.js works perfectly.