share/ShareJS — pull request #245 by tedsuo (2013-09-02 23:18:48+00:00)
Title: return 'undefined' if last elem in path is not present

Small tweak to make json paths work more like javascript objects.

old behavior: doc.get(['foo','bar']) would throw an error if 'bar' is not present.

new behavior: doc.get(['foo','bar']) returns undefined if 'bar' is not present.

*note: doc.get(['foo','bar','none']) still throws 'bad path' error if 'bar' is not present.

This allows for existence checks to work how you would expect:

var bar = doc.get(['foo','bar']);
if(bar) { // do something... }
else { // do something else... }