gka / chroma.js

JavaScript library for all kinds of color manipulations
https://gka.github.io/chroma.js/
Other
10.1k stars 543 forks source link

Feature Request: Google Apps Script Support #207

Closed leoherzog closed 2 years ago

leoherzog commented 5 years ago

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 commented 5 years ago

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.

gka commented 5 years ago

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.

Artoria2e5 commented 5 years ago

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

leoherzog commented 2 years ago

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