You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by gi...@git.apache.org on 2017/04/26 17:02:05 UTC

[GitHub] knpwrs opened a new issue #491: It should be easier to find out what JavaScript features are supported by CouchDB

knpwrs opened a new issue #491: It should be easier to find out what JavaScript features are supported by CouchDB
URL: https://github.com/apache/couchdb/issues/491
 
 
   Most CouchDB tutorials/guides are written with ye olde JavaScript, i.e., ES5 and below. I was curious to find out if any ES2015 features were natively supported by CouchDB, so I did a few google searches for `couchdb es2015` and `couchdb es6`. Neither search returned any relevant results. With that, I had to start experimenting with a local installation of CouchDB (I went with the latest version from Docker Hub). I was pleasantly surprised to see that CouchDB supports `const` as well as object and argument destructuring, and somewhat disappointed to see that it does not support [`String.prototype.includes`], forcing me to use the inelegant snippet we're all familiar with, `str.indexOf(...) > -1` (or, if you like hacks, `~str.indexOf(...)`). I have yet to test for any other features.
   
   I think there should be some easier way than trial and error to see what features are supported by CouchDB. The google searches, like I said, were not very helpful. Most browsers are starting to ship ES2017 features (such as async functions) and JavaScript developers are getting used to working in such environments.
   
   I've been thinking about this a little bit and I think I have a simple solution that could work. Take, for example, Electron. It's built on Chromium but doesn't use Chromium version numbers. The solution to this is an npm package, [`electron-to-chromium`]. It converts Electron version numbers to feature-equivalent Chromium version numbers. This package is used by [`babel-preset-env`] to determine which features need to be transpiled to run on certain versions of Electron.
   
   My solution is inspired by the notion of converting version numbers. My understanding is that CouchDB by default uses SpiderMonkey as its JavaScript engine. The simplest thing to do would be to have a table somewhere on the CouchDB website converting CouchDB version numbers to feature-equivalent Firefox version numbers. At a minimum people could see what features are supported by the listed version of Firefox and use only those features. Otherwise, people who already include transpiling in their pipeline could plug that version number into [`babel-preset-env`] and get valid JavaScript to use with CouchDB that way. Other avenues to explore include:
   
   * A package similar to [`electron-to-chromium`], e.g., `couchdb-to-firefox`, which converts version numbers programmatically which we could nag the maintainers of [`babel-preset-env`] to include.
   * A babel preset, e.g., `babel-preset-couchdb` so we don't have to nag the maintainers of [`babel-preset-env`].
   
   To start off the discussion, is there a version of Firefox which the latest version of CouchDB could be considered equivalent to in terms of supported JavaScript features? My guess is some version < 40 given the lack of support for [`String.prototype.includes`]. I'm also curious if there are any plans to update the JavaScript engine in CouchDB to support newer features natively.
   
   I could also be overlooking something. Is there already such a table or list of supported JavaScript features available somewhere? I found [this page](http://docs.couchdb.org/en/2.0.0/query-server/javascript.html), but that only talks about CouchDB functions available in JavaScript.
   
   [`String.prototype.includes`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes
   [`electron-to-chromium`]: https://github.com/Kilian/electron-to-chromium
   [`babel-preset-env`]: https://github.com/babel/babel-preset-env
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services