Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It should be easier to find out what JavaScript features are supported by CouchDB #491

Closed
knpwrs opened this issue Apr 26, 2017 · 2 comments

Comments

@knpwrs
Copy link

knpwrs commented Apr 26, 2017

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, but that only talks about CouchDB functions available in JavaScript.

@knpwrs
Copy link
Author

knpwrs commented Apr 26, 2017

After some more research, it appears that the features supported will depend on external factors making a table like what I suggested more difficult.

@wohali
Copy link
Member

wohali commented Apr 26, 2017

CouchDB is based on SpiderMonkey 1.8.5 which is equivalent to approximately Firefox 4.0. There are plans to update the JS engine in CouchDB but they are still in the formative stages.

Closing this for now.

@wohali wohali closed this as completed Apr 26, 2017
nickva pushed a commit to nickva/couchdb that referenced this issue Sep 7, 2022
…che#491)

* Update documentation for document partitioned databases.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants