Which version of JavaScript for views? And what is builtin?

Gentlefolk,

My Google-fu is weak and I cannot find the answer to the below questions.

What version of Javascript is running the map and reduce functions? Because I have some conditional loops building up an object, I only want to emit it as a value when it actually has properties. This snippet:

Object.keys(value).length

will do the job. But keys() is only available in later versions of Javascript.

Hence, which version of Javascript is running in CB v2.1.1 and what subset of browser Javascript does it support?

Andrew

1 Answer

« Back to question.

Couchbase server uses libv8 to execute javascript.

 $ cat /opt/couchbase/VERSION.txt 
2.1.0-718-rel
 $ cat /opt/couchbase/lib/libv8.ver 
447decb75060a106131ab4de934bcc374648e7f2

Then you can get information about this version on github page for this commit:
https://github.com/v8/v8/commit/447decb75060a106131ab4de934bcc374648e7f2

In this particular case couchbase uses libv8 3.9.7. At this moment debian unstable has 3.14.5.8-4. Most recent release 3.21.6 (9 hours ago).

Having the version you can google on which version of javascript does this v8 implements.

The answer regarding built-ins:
All of them described in the docs: http://couchbase.com/docs/couchbase-manual-2.0/couchbase-views-writing-u...
Also for reduce you can use special macros instead of reduce function body, which will allow to execute native implementation: http://couchbase.com/docs/couchbase-devguide-2.0/using-built-in-reduces....