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

Feature Request: Google Apps Script Support

Open leoherzog opened this issue 5 years ago • 3 comments

Amazing library, thanks for all your work.

It would be great if Chroma worked out-of-the-box with Google Apps Script.

If I:

  1. Copy and paste the latest chroma.js release into a script file in an apps script project
  2. Write a function like function test() { chroma('red'); }
  3. 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.

leoherzog avatar Jan 04 '19 20:01 leoherzog

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.

leoherzog avatar Jan 04 '19 20:01 leoherzog

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.

gka avatar Feb 16 '19 23:02 gka

This is really Google's fault, and.. Google does have a "Closure Compiler" thingy that transcompiles to ES3.

Artoria2e5 avatar Aug 15 '19 01:08 Artoria2e5

Now that Google Apps Script supports the V8 runtime with modern Javascript features, I'm happy to report that Chroma.js works perfectly.

leoherzog avatar Aug 24 '22 19:08 leoherzog