diff --git a/bower.json b/bower.json index 89121e6..1a798fd 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "baobab", "main": "build/baobab.min.js", - "version": "1.0.1", + "version": "1.0.2", "homepage": "https://github.com/Yomguithereal/baobab", "author": { "name": "Guillaume Plique", diff --git a/build/baobab.min.js b/build/baobab.min.js index 0d4340e..68a4608 100644 --- a/build/baobab.min.js +++ b/build/baobab.min.js @@ -1,2 +1,2 @@ -/* baobab.js - Version: 1.0.1 - Author: Yomguithereal (Guillaume Plique) */ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.Baobab=t()}}(function(){var t;return function e(t,r,n){function o(s,a){if(!r[s]){if(!t[s]){var u="function"==typeof require&&require;if(!a&&u)return u(s,!0);if(i)return i(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var h=r[s]={exports:{}};t[s][0].call(h.exports,function(e){var r=t[s][1][e];return o(r?r:e)},h,h.exports,e,t,r,n)}return r[s].exports}for(var i="function"==typeof require&&require,s=0;sn;n++)t[n].fn!==e&&o.push(t[n]);return o}var s={once:"boolean",scope:"object"},a=0,u=function(){this._enabled=!0,this.unbindAll()};u.prototype.unbindAll=function(){return this._handlers={},this._handlersAll=[],this._handlersComplex=[],this},u.prototype.on=function(t,e,r){var n,i,u,c,h,l,f;if(o(t)){for(c in t)this.on(c,t[c],e);return this}for("function"==typeof t&&(r=e,e=t,t=null),h=[].concat(t),n=0,i=h.length;i>n;n++){if(c=h[n],f={order:a++,fn:e},"string"==typeof c)this._handlers[c]||(this._handlers[c]=[]),l=this._handlers[c];else if(c instanceof RegExp)l=this._handlersComplex,f.pattern=c;else{if(null!==c)throw Error("Emitter.on: invalid event.");l=this._handlersAll}for(u in r||{})s[u]&&(f[u]=r[u]);f.once&&(f.parent=l),l.push(f)}return this},u.prototype.once=function(){var t=Array.prototype.slice.call(arguments),r=t.length-1;return o(t[r])&&t.length>1?t[r]=e(t[r],{once:!0}):t.push({once:!0}),this.on.apply(this,t)},u.prototype.off=function(t,e){var r,n,s,a;if(1===arguments.length&&"function"==typeof t){e=arguments[0];for(s in this._handlers)this._handlers[s]=i(this._handlers[s],e),0===this._handlers[s].length&&delete this._handlers[s];this._handlersAll=i(this._handlersAll,e),this._handlersComplex=i(this._handlersComplex,e)}else if(1===arguments.length&&"string"==typeof t)delete this._handlers[t];else if(2===arguments.length){var u=[].concat(t);for(r=0,n=u.length;n>r;r++)a=u[r],this._handlers[a]=i(this._handlers[a],e),0===(this._handlers[a]||[]).length&&delete this._handlers[a]}else if(o(t))for(s in t)this.off(s,t[s]);return this},u.prototype.listeners=function(t){var e,r,n,o=this._handlersAll||[],i=!1;if(!t)throw Error("Emitter.listeners: no event provided.");for(o=o.concat(this._handlers[t]||[]),r=0,n=this._handlersComplex.length;n>r;r++)e=this._handlersComplex[r],~t.search(e.pattern)&&(i=!0,o.push(e));return this._handlersAll.length||i?o.sort(function(t,e){return t.order-e.order}):o.slice(0)},u.prototype.emit=function(t,e){if(!this._enabled)return this;if(o(t)){for(var r in t)this.emit(r,t[r]);return this}var n,i,s,a,u,c,h,l=[].concat(t),f=[];for(a=0,c=l.length;c>a;a++){for(i=this.listeners(l[a]),u=0,h=i.length;h>u;u++)s=i[u],n={type:l[a],target:this},arguments.length>1&&(n.data=e),s.fn.call("scope"in s?s.scope:this,n),s.once&&f.push(s);for(u=f.length-1;u>=0;u--)f[u].parent.splice(f[u].parent.indexOf(f[u]),1)}return this},u.prototype.kill=function(){this.unbindAll(),this._handlers=null,this._handlersAll=null,this._handlersComplex=null,this._enabled=!1},u.prototype.disable=function(){return this._enabled=!1,this},u.prototype.enable=function(){return this._enabled=!0,this},u.version="3.0.0","undefined"!=typeof n?("undefined"!=typeof r&&r.exports&&(n=r.exports=u),n.Emitter=u):"function"==typeof t&&t.amd?t("emmett",[],function(){return u}):this.Emitter=u}).call(this)},{}],4:[function(t,e,r){function n(t){return t+"$"+(new Date).getTime()+(""+Math.random()).replace("0.","")}function o(t,e){function r(t){this[t]=function(){var e=this.root[t].apply(this.root,arguments);return e instanceof i?this:e}}if(arguments.length<1&&(t={}),!(this instanceof o))return new o(t,e);if(!f.Object(t)&&!f.Array(t))throw Error("Baobab: invalid data.");if(s.call(this),this.options=u.shallowMerge(l,e),this._transaction={},this._future=void 0,this._cursors={},this._identity="[object Baobab]",this.data=u.deepClone(t),this.root=this.select([]),this.facets={},["get","set","unset","update"].forEach(r.bind(this)),!f.Object(this.options.facets))throw Error("Baobab: invalid facets.");for(var n in this.options.facets)this.addFacet(n,this.options.facets[n])}var i=t("./cursor.js"),s=t("emmett"),a=t("./facet.js"),u=t("./helpers.js"),c=t("./update.js"),h=t("./merge.js"),l=t("../defaults.js"),f=t("./type.js");u.inherits(o,s),o.prototype.addFacet=function(t,e,r){return this.facets[t]=this.createFacet(e,r),this},o.prototype.createFacet=function(t,e){return new a(this,t,e)},o.prototype.select=function(t){if(arguments.length>1&&(t=u.arrayOf(arguments)),!f.Path(t))throw Error("Baobab.select: invalid path.");t=[].concat(t);var e,r=f.ComplexPath(t);r&&(e=u.solvePath(this.data,t,this));var o=t.map(function(t){return f.Function(t)?n("fn"):f.Object(t)?n("ob"):t}).join("|λ|");if(this._cursors[o])return this._cursors[o];var s=new i(this,t,e,o);return this._cursors[o]=s,s},o.prototype.stack=function(t,e){var r=this;if(!f.Object(t))throw Error("Baobab.update: wrong specification.");return this._transaction=e&&!Object.keys(this._transaction).length?t:h(this._transaction,t),this.options.autoCommit?this.options.asynchronous?(this._future||(this._future=setTimeout(r.commit.bind(r,null),0)),this):this.commit():this},o.prototype.commit=function(){var t=c(this.data,this._transaction,this.options),e=this.data;this._transaction={},this._future&&(this._future=clearTimeout(this._future));var r=this.options.validate,n=this.options.validationBehavior;if("function"==typeof r){var o=r.call(this,e,t.data,t.log);if(o instanceof Error&&(this.emit("invalid",{error:o}),"rollback"===n))return this}return this.data=t.data,this.emit("update",{log:t.log,previousState:e}),this},o.prototype.release=function(){var t;delete this.data,delete this._transaction;for(t in this._cursors)this._cursors[t].release();delete this._cursors;for(t in this.facets)this.facets[t].release();delete this.facets,this.kill()},o.prototype.toJSON=function(){return this.get()},o.prototype.toString=function(){return this._identity},e.exports=o},{"../defaults.js":2,"./cursor.js":5,"./facet.js":6,"./helpers.js":7,"./merge.js":8,"./type.js":9,"./update.js":10,emmett:3}],5:[function(t,e,r){function n(t,e,r,n){function o(t){if(i.recording&&!i.undoing){var e=a.getIn(t,i.solvedPath,i.tree);i.archive.add(e)}return i.undoing=!1,i.emit("update")}var i=this;s.call(this),e=e||[],this.tree=t,this.path=e,this.hash=n,this.archive=null,this.recording=!1,this.undoing=!1,this._identity="[object Cursor]",this.complexPath=!!r,this.solvedPath=this.complexPath?r:this.path,this.relevant=void 0!==this.get(),this.updateHandler=function(t){var e=t.data.log,r=t.data.previousState,n=!1;if(i.complexPath&&(i.solvedPath=a.solvePath(i.tree.data,i.path,i.tree)),!i.path.length)return o(r);i.solvedPath&&(n=a.solveUpdate(e,[i.solvedPath]));var s=void 0!==i.get();i.relevant?s&&n?o(r):s||(i.emit("irrelevant"),i.relevant=!1):s&&n&&(i.emit("relevant"),o(r),i.relevant=!0)};var u=!1;this._lazyBind=function(){u||(u=!0,i.tree.on("update",i.updateHandler))},this.on=a.before(this._lazyBind,this.on.bind(this)),this.once=a.before(this._lazyBind,this.once.bind(this)),this.complexPath&&this._lazyBind()}function o(t,e,r,n){if(arguments.length>5)throw Error("baobab.Cursor."+t+": too many arguments.");if("unset"===t?(n=!0,2===arguments.length&&(r=[])):arguments.length<4&&(n=r,r=[]),!u.Path(r))throw Error("baobab.Cursor."+t+': invalid path "'+r+'".');if("splice"===t&&!u.Splicer(n)){if(!u.Array(n))throw Error("baobab.Cursor.splice: incorrect value.");n=[n]}if(e&&!e(n))throw Error("baobab.Cursor."+t+": incorrect value.");var o=[].concat(r),i=a.solvePath(this.get(),o,this.tree);if(!i)throw Error("baobab.Cursor."+t+": could not solve dynamic path.");var s={};s["$"+t]=n;var c=a.pathObject(i,s);return c}function i(t,e){n.prototype[t]=function(){var r=o.bind(this,t,e).apply(this,arguments);return this.update(r,!0)}}var s=t("emmett"),a=t("./helpers.js"),u=(t("../defaults.js"),t("./type.js"));a.inherits(n,s),n.prototype.isRoot=function(){return!this.path.length},n.prototype.isLeaf=function(){return u.Primitive(this.get())},n.prototype.isBranch=function(){return!this.isLeaf()&&!this.isRoot()},n.prototype.root=function(){return this.tree.root()},n.prototype.select=function(t){if(arguments.length>1&&(t=a.arrayOf(arguments)),!u.Path(t))throw Error("baobab.Cursor.select: invalid path.");return this.tree.select(this.path.concat(t))},n.prototype.up=function(){return this.solvedPath&&this.solvedPath.length?this.tree.select(this.path.slice(0,-1)):null},n.prototype.left=function(){var t=+this.solvedPath[this.solvedPath.length-1];if(isNaN(t))throw Error("baobab.Cursor.left: cannot go left on a non-list type.");return t?this.tree.select(this.solvedPath.slice(0,-1).concat(t-1)):null},n.prototype.leftmost=function(){var t=+this.solvedPath[this.solvedPath.length-1];if(isNaN(t))throw Error("baobab.Cursor.leftmost: cannot go left on a non-list type.");return this.tree.select(this.solvedPath.slice(0,-1).concat(0))},n.prototype.right=function(){var t=+this.solvedPath[this.solvedPath.length-1];if(isNaN(t))throw Error("baobab.Cursor.right: cannot go right on a non-list type.");return t+1===this.up().get().length?null:this.tree.select(this.solvedPath.slice(0,-1).concat(t+1))},n.prototype.rightmost=function(){var t=+this.solvedPath[this.solvedPath.length-1];if(isNaN(t))throw Error("baobab.Cursor.right: cannot go right on a non-list type.");var e=this.up().get();return this.tree.select(this.solvedPath.slice(0,-1).concat(e.length-1))},n.prototype.down=function(){+this.solvedPath[this.solvedPath.length-1];return this.get()instanceof Array?this.tree.select(this.solvedPath.concat(0)):null},n.prototype.get=function(t){arguments.length>1&&(t=a.arrayOf(arguments));var e=this.solvedPath.concat([].concat(t||0===t?t:[]));return a.getIn(this.tree.data,e,this.tree)},i("set"),i("apply",u.Function),i("chain",u.Function),i("push"),i("unshift"),i("merge",u.Object),i("splice"),n.prototype.unset=function(t){if(void 0===t&&this.isRoot())throw Error("baobab.Cursor.unset: cannot remove root node.");var e=o.bind(this,"unset",null).apply(this,arguments);return this.update(e,!0)},n.prototype.update=function(t,e){if(!u.Object(t))throw Error("baobab.Cursor.update: invalid specifications.");return this.tree.stack(a.pathObject(this.solvedPath,t),e),this},n.prototype.startRecording=function(t){if(t=t||5,1>t)throw Error("baobab.Cursor.startRecording: invalid maximum number of records.");return this.archive?this:(this._lazyBind(),this.archive=a.archive(t),this.recording=!0,this)},n.prototype.stopRecording=function(){return this.recording=!1,this},n.prototype.undo=function(t){if(t=t||1,!this.recording)throw Error("baobab.Cursor.undo: cursor is not recording.");if(!u.PositiveInteger(t))throw Error("baobab.Cursor.undo: expecting a positive integer.");var e=this.archive.back(t);if(!e)throw Error("boabab.Cursor.undo: cannot find a relevant record ("+t+" back).");return this.undoing=!0,this.set(e)},n.prototype.hasHistory=function(){return!(!this.archive||!this.archive.get().length)},n.prototype.getHistory=function(){return this.archive?this.archive.get():[]},n.prototype.clearHistory=function(){return this.archive=null,this},n.prototype.release=function(){this.tree.off("update",this.updateHandler),this.hash&&delete this.tree._cursors[this.hash],delete this.tree,delete this.path,delete this.solvedPath,delete this.archive,this.kill()},n.prototype.toJSON=function(){return this.get()},n.prototype.toString=function(){return this._identity},e.exports=n},{"../defaults.js":2,"./helpers.js":7,"./type.js":9,emmett:3}],6:[function(t,e,r){function n(t,e,r){function u(e,r,o,s,u){if(e||f){p=!1;var c=r;if(e&&(c=r.apply(this,u)),!s(c))throw Error("baobab.Facet: incorrect "+o+" mapping.");l[o]={},Object.keys(c).forEach(function(e){if("cursors"===o){if(c[e]instanceof i)return void(l.cursors[e]=c[e]);if(a.Path(c[e]))return void(l.cursors[e]=t.select(c[e]))}else{if(c[e]instanceof n)return void(l.facets[e]=c[e]);if("string"==typeof c[e]){if(l.facets[e]=t.facets[c[e]],!l.facets[e])throw Error('baobab.Facet: unkown "'+c[e]+'" facet in facets mapping.');return}}})}}function c(t){return Object.keys(t).map(function(e){return t[e].solvedPath})}function h(t){var e=Object.keys(t).map(function(e){return c(t[e].cursors)});return[].concat.apply([],e)}var l=this,f=!0,p=!1,d=e.get,y=null;o.call(this),this.tree=t,this.cursors={},this.facets={};var g=e.cursors,v=e.facets,b="function"==typeof e.cursors,m="function"==typeof e.facets;this.refresh=function(t){if(t=t||[],!a.Array(t))throw Error("baobab.Facet.refresh: first argument should be an array.");g&&u(b,g,"cursors",a.FacetCursors,t),v&&u(m,v,"facets",a.FacetFacets,t)},this.get=function(){if(p)return y;var t,e={};for(t in l.facets)e[t]=l.facets[t].get();for(t in l.cursors)e[t]=l.cursors[t].get();return e="function"==typeof d?d.call(null,e):e,p=!0,y=e},this.updateHandler=function(t){var e=c(l.cursors).concat(h(l.facets));s.solveUpdate(t.data.log,e)&&(p=!1,l.emit("update"))},this.refresh(r),this.tree.on("update",this.updateHandler),f=!1}var o=t("emmett"),i=t("./cursor.js"),s=t("./helpers.js"),a=t("./type.js");s.inherits(n,o),n.prototype.release=function(){this.tree.off("update",this.updateHandler),this.tree=null,this.cursors=null,this.facets=null,this.kill()},e.exports=n},{"./cursor.js":5,"./helpers.js":7,"./type.js":9,emmett:3}],7:[function(t,e,r){(function(r){function n(t){return Array.prototype.slice.call(t)}function o(t,e){return function(){t(),e.apply(null,arguments)}}function i(t,e,r){var o=n(arguments).slice(3);return t.slice(0,e).concat(o).concat(t.slice(e+r))}function s(t,e){var r,n={};for(r in t)n[r]=t[r];for(r in e)n[r]=e[r];return n}function a(t){var e=t.source,r="";return t.global&&(r+="g"),t.multiline&&(r+="m"),t.ignoreCase&&(r+="i"),t.sticky&&(r+="y"),t.unicode&&(r+="u"),new RegExp(e,r)}function u(t,e){if(!e||"object"!=typeof e||e instanceof Error||"ArrayBuffer"in r&&e instanceof ArrayBuffer)return e;if(w.Array(e)){if(t){var n,o,i=[];for(n=0,o=e.length;o>n;n++)i.push(P(e[n]));return i}return e.slice(0)}if(w.Date(e))return new Date(e.getTime());if(e instanceof RegExp)return a(e);if(w.Object(e)){var s,u={};e.constructor&&e.constructor!==Object&&(u=Object.create(e.constructor.prototype));for(s in e)e.hasOwnProperty(s)&&(u[s]=t?P(e[s]):e[s]);return u}return e}function c(t,e){return function(r){return e(t(r))}}function h(t,e){var r,n;for(r=0,n=t.length;n>r;r++)if(e(t[r]))return t[r]}function l(t,e){var r,n;for(r=0,n=t.length;n>r;r++)if(e(t[r]))return r;return-1}function f(t,e){var r,n=!0;if(!t)return!1;for(r in e)if(w.Object(e[r]))n=n&&f(t[r],e[r]);else if(w.Array(e[r]))n=n&&!!~e[r].indexOf(t[r]);else if(t[r]!==e[r])return!1;return n}function d(t,e){return h(t,function(t){return f(t,e)})}function y(t,e){return l(t,function(t){return f(t,e)})}function g(t,e,r){e=e||[];var n,o,i,s=t;for(o=0,i=e.length;i>o;o++){if(!s)return;if("function"==typeof e[o]){if(!w.Array(s))return;s=h(s,e[o])}else if("object"==typeof e[o])if(r&&"$cursor"in e[o]){if(!w.Path(e[o].$cursor))throw Error("baobab.getIn: $cursor path must be an array.");n=r.get(e[o].$cursor),s=s[n]}else{if(!w.Array(s))return;s=d(s,e[o])}else s=s[e[o]]}return s}function v(t,e,r){var n,o,i,s=[],a=t;for(o=0,i=e.length;i>o;o++){if(!a)return null;if("function"==typeof e[o]){if(!w.Array(a))return;n=l(a,e[o]),s.push(n),a=a[n]}else if("object"==typeof e[o])if(r&&"$cursor"in e[o]){if(!w.Path(e[o].$cursor))throw Error("baobab.getIn: $cursor path must be an array.");p=r.get(e[o].$cursor),s.push(p),a=a[p]}else{if(!w.Array(a))return;n=y(a,e[o]),s.push(n),a=a[n]}else s.push(e[o]),a=a[e[o]]||{}}return s}function b(t,e){var r,n,o,i,s,a,u,c,h;for(r=0,i=e.length;i>r;r++)for(u=e[r],n=0,s=t.length;s>n;n++)for(c=t[n],o=0,a=c.length;a>o&&(h=c[o],h==u[o]);o++)if(o+1===a||o+1===u.length)return!0;return!1}function m(t,e){var r,n=t.length,o={},i=o;for(n||(o=e),r=0;n>r;r++)i[t[r]]=r+1===n?e:{},i=i[t[r]];return o}function j(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function _(t){var e=[];return{add:function(r){e.unshift(r),e.length>t&&(e.length=t)},back:function(t){var r=e[t-1];return r&&(e=e.slice(t)),r},get:function(){return e}}}var w=t("./type.js"),$=u.bind(null,!1),P=u.bind(null,!0);e.exports={archive:_,arrayOf:n,before:o,deepClone:P,shallowClone:$,shallowMerge:s,compose:c,getIn:g,inherits:j,pathObject:m,solvePath:v,solveUpdate:b,splice:i}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./type.js":9}],8:[function(t,e,r){function n(t,e){var r={};return r[t]=e,r}function o(t,e){var r,u=i.shallowClone(t||{}),c=!1;if(a.forEach(function(t){t in e&&(u=n(t,e[t]),c=!0)}),e.$chain&&(u.$apply=u.$apply?i.compose(u.$apply,e.$chain):e.$chain,u=n("$apply",u.$apply),c=!0),e.$merge&&(u.$merge=i.shallowMerge(u.$merge||{},e.$merge),c=!0),(e.$splice||e.$splice)&&(u.$splice=[].concat(u.$splice||[]).concat(e.$splice||[]),c=!0),(e.$push||u.$push)&&(u.$push=[].concat(u.$push||[]).concat(e.$push||[]),c=!0),(e.$unshift||u.$unshift)&&(u.$unshift=[].concat(e.$unshift||[]).concat(u.$unshift||[]),c=!0),c)return u;for(r in u)"$"===r.charAt(0)&&delete u[r];for(r in e)s.Object(e[r])&&(u[r]=o(u[r],e[r]));return u}var i=t("./helpers.js"),s=t("./type.js"),a=["$unset","$set","$apply"];e.exports=o},{"./helpers.js":7,"./type.js":9}],9:[function(t,e,r){function n(t,e){return e.some(function(e){return o[e](t)})}var o={};o.Array=function(t){return Array.isArray(t)},o.Object=function(t){return t&&"object"==typeof t&&!Array.isArray(t)&&!(t instanceof Function)},o.String=function(t){return"string"==typeof t},o.Number=function(t){return"number"==typeof t},o.PositiveInteger=function(t){return"number"==typeof t&&t>0&&t%1===0},o.Function=function(t){return"function"==typeof t},o.Primitive=function(t){return!t||"string"==typeof t||"number"==typeof t||"boolean"==typeof t},o.Date=function(t){return t instanceof Date},o.NonScalar=function(t){return o.Object(t)||o.Array(t)},o.Splicer=function(t){return o.Array(t)&&t.every(o.Array)},o.Path=function(t,e){return e=e||["String","Number","Function","Object"],o.Array(t)?t.every(function(t){return n(t,e)}):n(t,e)},o.ComplexPath=function(t){return t.some(function(t){return n(t,["Object","Function"])})},o.FacetCursors=function(e){return o.Object(e)?Object.keys(e).every(function(r){var n=e[r];return o.Path(n,["String","Number","Object"])||n instanceof t("./cursor.js")}):!1},o.FacetFacets=function(e){return o.Object(e)?Object.keys(e).every(function(r){var n=e[r];return"string"==typeof n||n instanceof t("./facet.js")}):!1},e.exports=o},{"./cursor.js":5,"./facet.js":6}],10:[function(t,e,r){function n(t,e){var r=new Error("baobab.update: "+e+" at path /"+t.slice(1).join("/"));return r.path=t,r}var o=t("./helpers.js"),i=t("./type.js");e.exports=function(t,e,r){r=r||{};var s={};t={root:o.shallowClone(t)};var a=function(t,e,r,u){r=r||["root"];var c,h,l,f,p,d=r.join("|λ|"),y=r[r.length-1],g=t[y];t[y]=i.Primitive(t[y])?{}:o.shallowClone(t[y]);var v=Object.keys(e).some(function(t){return"$"===t.charAt(0)});if(v){s[d]=!0;for(h in e){if("$unset"===h){var b=r[r.length-2];if(!i.Object(u[b]))throw n(r.slice(0,-1),"using command $unset on a non-object");u[b]=o.shallowClone(t),delete u[b][y];break}if("$set"===h)l=e.$set,t[y]=l;else if("$apply"===h||"$chain"===h){if(c=e.$apply||e.$chain,"function"!=typeof c)throw n(r,"using command $apply with a non function");t[y]=c.call(null,g)}else if("$merge"===h){if(l=e.$merge,!i.Object(t[y])||!i.Object(l))throw n(r,"using command $merge with a non object");t[y]=o.shallowMerge(t[y],l)}if("$splice"===h){if(l=e.$splice,!i.Array(t[y]))throw n(r,"using command $push to a non array");for(f=0,p=l.length;p>f;f++)t[y]=o.splice.apply(null,[t[y]].concat(l[f]))}if("$push"===h){if(l=e.$push,!i.Array(t[y]))throw n(r,"using command $push to a non array");t[y]=t[y].concat(l)}if("$unshift"===h){if(l=e.$unshift,!i.Array(t[y]))throw n(r,"using command $unshift to a non array");t[y]=[].concat(l).concat(t[y])}}}else for(h in e)a(t[y],e[h],r.concat(h),t)};return a(t,e),{data:t.root,log:Object.keys(s).map(function(t){return t.split("|λ|").slice(1)})}}},{"./helpers.js":7,"./type.js":9}]},{},[1])(1)}); \ No newline at end of file +/* baobab.js - Version: 1.0.2 - Author: Yomguithereal (Guillaume Plique) */ +!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.Baobab=t()}}(function(){var t;return function e(t,r,n){function o(s,a){if(!r[s]){if(!t[s]){var u="function"==typeof require&&require;if(!a&&u)return u(s,!0);if(i)return i(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var h=r[s]={exports:{}};t[s][0].call(h.exports,function(e){var r=t[s][1][e];return o(r?r:e)},h,h.exports,e,t,r,n)}return r[s].exports}for(var i="function"==typeof require&&require,s=0;sn;n++)t[n].fn!==e&&o.push(t[n]);return o}var s={once:"boolean",scope:"object"},a=0,u=function(){this._enabled=!0,this.unbindAll()};u.prototype.unbindAll=function(){return this._handlers={},this._handlersAll=[],this._handlersComplex=[],this},u.prototype.on=function(t,e,r){var n,i,u,c,h,l,f;if(o(t)){for(c in t)this.on(c,t[c],e);return this}for("function"==typeof t&&(r=e,e=t,t=null),h=[].concat(t),n=0,i=h.length;i>n;n++){if(c=h[n],f={order:a++,fn:e},"string"==typeof c)this._handlers[c]||(this._handlers[c]=[]),l=this._handlers[c];else if(c instanceof RegExp)l=this._handlersComplex,f.pattern=c;else{if(null!==c)throw Error("Emitter.on: invalid event.");l=this._handlersAll}for(u in r||{})s[u]&&(f[u]=r[u]);f.once&&(f.parent=l),l.push(f)}return this},u.prototype.once=function(){var t=Array.prototype.slice.call(arguments),r=t.length-1;return o(t[r])&&t.length>1?t[r]=e(t[r],{once:!0}):t.push({once:!0}),this.on.apply(this,t)},u.prototype.off=function(t,e){var r,n,s,a;if(1===arguments.length&&"function"==typeof t){e=arguments[0];for(s in this._handlers)this._handlers[s]=i(this._handlers[s],e),0===this._handlers[s].length&&delete this._handlers[s];this._handlersAll=i(this._handlersAll,e),this._handlersComplex=i(this._handlersComplex,e)}else if(1===arguments.length&&"string"==typeof t)delete this._handlers[t];else if(2===arguments.length){var u=[].concat(t);for(r=0,n=u.length;n>r;r++)a=u[r],this._handlers[a]=i(this._handlers[a],e),0===(this._handlers[a]||[]).length&&delete this._handlers[a]}else if(o(t))for(s in t)this.off(s,t[s]);return this},u.prototype.listeners=function(t){var e,r,n,o=this._handlersAll||[],i=!1;if(!t)throw Error("Emitter.listeners: no event provided.");for(o=o.concat(this._handlers[t]||[]),r=0,n=this._handlersComplex.length;n>r;r++)e=this._handlersComplex[r],~t.search(e.pattern)&&(i=!0,o.push(e));return this._handlersAll.length||i?o.sort(function(t,e){return t.order-e.order}):o.slice(0)},u.prototype.emit=function(t,e){if(!this._enabled)return this;if(o(t)){for(var r in t)this.emit(r,t[r]);return this}var n,i,s,a,u,c,h,l=[].concat(t),f=[];for(a=0,c=l.length;c>a;a++){for(i=this.listeners(l[a]),u=0,h=i.length;h>u;u++)s=i[u],n={type:l[a],target:this},arguments.length>1&&(n.data=e),s.fn.call("scope"in s?s.scope:this,n),s.once&&f.push(s);for(u=f.length-1;u>=0;u--)f[u].parent.splice(f[u].parent.indexOf(f[u]),1)}return this},u.prototype.kill=function(){this.unbindAll(),this._handlers=null,this._handlersAll=null,this._handlersComplex=null,this._enabled=!1},u.prototype.disable=function(){return this._enabled=!1,this},u.prototype.enable=function(){return this._enabled=!0,this},u.version="3.0.0","undefined"!=typeof n?("undefined"!=typeof r&&r.exports&&(n=r.exports=u),n.Emitter=u):"function"==typeof t&&t.amd?t("emmett",[],function(){return u}):this.Emitter=u}).call(this)},{}],4:[function(t,e,r){function n(t){return t+"$"+(new Date).getTime()+(""+Math.random()).replace("0.","")}function o(t,e){function r(t){this[t]=function(){var e=this.root[t].apply(this.root,arguments);return e instanceof i?this:e}}if(arguments.length<1&&(t={}),!(this instanceof o))return new o(t,e);if(!f.Object(t)&&!f.Array(t))throw Error("Baobab: invalid data.");if(s.call(this),this.options=u.shallowMerge(l,e),this._transaction={},this._future=void 0,this._cursors={},this._identity="[object Baobab]",this.data=u.deepClone(t),this.root=this.select([]),this.facets={},["get","set","unset","update"].forEach(r.bind(this)),!f.Object(this.options.facets))throw Error("Baobab: invalid facets.");for(var n in this.options.facets)this.addFacet(n,this.options.facets[n])}var i=t("./cursor.js"),s=t("emmett"),a=t("./facet.js"),u=t("./helpers.js"),c=t("./update.js"),h=t("./merge.js"),l=t("../defaults.js"),f=t("./type.js");u.inherits(o,s),o.prototype.addFacet=function(t,e,r){return this.facets[t]=this.createFacet(e,r),this},o.prototype.createFacet=function(t,e){return new a(this,t,e)},o.prototype.select=function(t){if(arguments.length>1&&(t=u.arrayOf(arguments)),!f.Path(t))throw Error("Baobab.select: invalid path.");t=[].concat(t);var e,r=f.ComplexPath(t);r&&(e=u.solvePath(this.data,t,this));var o=t.map(function(t){return f.Function(t)?n("fn"):f.Object(t)?n("ob"):t}).join("|λ|");if(this._cursors[o])return this._cursors[o];var s=new i(this,t,e,o);return this._cursors[o]=s,s},o.prototype.stack=function(t,e){var r=this;if(!f.Object(t))throw Error("Baobab.update: wrong specification.");return this._transaction=e&&!Object.keys(this._transaction).length?t:h(this._transaction,t),this.options.autoCommit?this.options.asynchronous?(this._future||(this._future=setTimeout(r.commit.bind(r,null),0)),this):this.commit():this},o.prototype.commit=function(){var t=c(this.data,this._transaction,this.options),e=this.data;this._transaction={},this._future&&(this._future=clearTimeout(this._future));var r=this.options.validate,n=this.options.validationBehavior;if("function"==typeof r){var o=r.call(this,e,t.data,t.log);if(o instanceof Error&&(this.emit("invalid",{error:o}),"rollback"===n))return this}return this.data=t.data,this.emit("update",{log:t.log,previousState:e}),this},o.prototype.release=function(){var t;delete this.data,delete this._transaction;for(t in this._cursors)this._cursors[t].release();delete this._cursors;for(t in this.facets)this.facets[t].release();delete this.facets,this.kill()},o.prototype.toJSON=function(){return this.get()},o.prototype.toString=function(){return this._identity},e.exports=o},{"../defaults.js":2,"./cursor.js":5,"./facet.js":6,"./helpers.js":7,"./merge.js":8,"./type.js":9,"./update.js":10,emmett:3}],5:[function(t,e,r){function n(t,e,r,n){function o(t){if(i.recording&&!i.undoing){var e=a.getIn(t,i.solvedPath,i.tree);i.archive.add(e)}return i.undoing=!1,i.emit("update")}var i=this;s.call(this),e=e||[],this.tree=t,this.path=e,this.hash=n,this.archive=null,this.recording=!1,this.undoing=!1,this._identity="[object Cursor]",this.complexPath=!!r,this.solvedPath=this.complexPath?r:this.path,this.relevant=void 0!==this.get(),this.updateHandler=function(t){var e=t.data.log,r=t.data.previousState,n=!1;if(i.complexPath&&(i.solvedPath=a.solvePath(i.tree.data,i.path,i.tree)),!i.path.length)return o(r);i.solvedPath&&(n=a.solveUpdate(e,[i.solvedPath]));var s=void 0!==i.get();i.relevant?s&&n?o(r):s||(i.emit("irrelevant"),i.relevant=!1):s&&n&&(i.emit("relevant"),o(r),i.relevant=!0)};var u=!1;this._lazyBind=function(){u||(u=!0,i.tree.on("update",i.updateHandler))},this.on=a.before(this._lazyBind,this.on.bind(this)),this.once=a.before(this._lazyBind,this.once.bind(this)),this.complexPath&&this._lazyBind()}function o(t,e,r,n){if(arguments.length>5)throw Error("baobab.Cursor."+t+": too many arguments.");if("unset"===t?(n=!0,2===arguments.length&&(r=[])):arguments.length<4&&(n=r,r=[]),!u.Path(r))throw Error("baobab.Cursor."+t+': invalid path "'+r+'".');if("splice"===t&&!u.Splicer(n)){if(!u.Array(n))throw Error("baobab.Cursor.splice: incorrect value.");n=[n]}if(e&&!e(n))throw Error("baobab.Cursor."+t+": incorrect value.");var o=[].concat(r),i=a.solvePath(this.get(),o,this.tree);if(!i)throw Error("baobab.Cursor."+t+": could not solve dynamic path.");var s={};s["$"+t]=n;var c=a.pathObject(i,s);return c}function i(t,e){n.prototype[t]=function(){var r=o.bind(this,t,e).apply(this,arguments);return this.update(r,!0)}}var s=t("emmett"),a=t("./helpers.js"),u=(t("../defaults.js"),t("./type.js"));a.inherits(n,s),n.prototype.isRoot=function(){return!this.path.length},n.prototype.isLeaf=function(){return u.Primitive(this.get())},n.prototype.isBranch=function(){return!this.isLeaf()&&!this.isRoot()},n.prototype.root=function(){return this.tree.root()},n.prototype.select=function(t){if(arguments.length>1&&(t=a.arrayOf(arguments)),!u.Path(t))throw Error("baobab.Cursor.select: invalid path.");return this.tree.select(this.path.concat(t))},n.prototype.up=function(){return this.solvedPath&&this.solvedPath.length?this.tree.select(this.path.slice(0,-1)):null},n.prototype.left=function(){var t=+this.solvedPath[this.solvedPath.length-1];if(isNaN(t))throw Error("baobab.Cursor.left: cannot go left on a non-list type.");return t?this.tree.select(this.solvedPath.slice(0,-1).concat(t-1)):null},n.prototype.leftmost=function(){var t=+this.solvedPath[this.solvedPath.length-1];if(isNaN(t))throw Error("baobab.Cursor.leftmost: cannot go left on a non-list type.");return this.tree.select(this.solvedPath.slice(0,-1).concat(0))},n.prototype.right=function(){var t=+this.solvedPath[this.solvedPath.length-1];if(isNaN(t))throw Error("baobab.Cursor.right: cannot go right on a non-list type.");return t+1===this.up().get().length?null:this.tree.select(this.solvedPath.slice(0,-1).concat(t+1))},n.prototype.rightmost=function(){var t=+this.solvedPath[this.solvedPath.length-1];if(isNaN(t))throw Error("baobab.Cursor.right: cannot go right on a non-list type.");var e=this.up().get();return this.tree.select(this.solvedPath.slice(0,-1).concat(e.length-1))},n.prototype.down=function(){+this.solvedPath[this.solvedPath.length-1];return this.get()instanceof Array?this.tree.select(this.solvedPath.concat(0)):null},n.prototype.get=function(t){arguments.length>1&&(t=a.arrayOf(arguments));var e=this.solvedPath.concat([].concat(t||0===t?t:[]));return a.getIn(this.tree.data,e,this.tree)},i("set"),i("apply",u.Function),i("chain",u.Function),i("push"),i("unshift"),i("merge",u.Object),i("splice"),n.prototype.unset=function(t){if(void 0===t&&this.isRoot())throw Error("baobab.Cursor.unset: cannot remove root node.");var e=o.bind(this,"unset",null).apply(this,arguments);return this.update(e,!0)},n.prototype.update=function(t,e){if(!u.Object(t))throw Error("baobab.Cursor.update: invalid specifications.");return this.tree.stack(a.pathObject(this.solvedPath,t),e),this},n.prototype.startRecording=function(t){if(t=t||5,1>t)throw Error("baobab.Cursor.startRecording: invalid maximum number of records.");return this.archive?this:(this._lazyBind(),this.archive=a.archive(t),this.recording=!0,this)},n.prototype.stopRecording=function(){return this.recording=!1,this},n.prototype.undo=function(t){if(t=t||1,!this.recording)throw Error("baobab.Cursor.undo: cursor is not recording.");if(!u.PositiveInteger(t))throw Error("baobab.Cursor.undo: expecting a positive integer.");var e=this.archive.back(t);if(!e)throw Error("boabab.Cursor.undo: cannot find a relevant record ("+t+" back).");return this.undoing=!0,this.set(e)},n.prototype.hasHistory=function(){return!(!this.archive||!this.archive.get().length)},n.prototype.getHistory=function(){return this.archive?this.archive.get():[]},n.prototype.clearHistory=function(){return this.archive=null,this},n.prototype.release=function(){this.tree.off("update",this.updateHandler),this.hash&&delete this.tree._cursors[this.hash],delete this.tree,delete this.path,delete this.solvedPath,delete this.archive,this.kill()},n.prototype.toJSON=function(){return this.get()},n.prototype.toString=function(){return this._identity},e.exports=n},{"../defaults.js":2,"./helpers.js":7,"./type.js":9,emmett:3}],6:[function(t,e,r){function n(t,e,r){function u(e,r,o,s,u){if(e||f){p=!1;var c=r;if(e&&(c=r.apply(this,u)),!s(c))throw Error("baobab.Facet: incorrect "+o+" mapping.");l[o]={},Object.keys(c).forEach(function(e){if("cursors"===o){if(c[e]instanceof i)return void(l.cursors[e]=c[e]);if(a.Path(c[e]))return void(l.cursors[e]=t.select(c[e]))}else{if(c[e]instanceof n)return void(l.facets[e]=c[e]);if("string"==typeof c[e]){if(l.facets[e]=t.facets[c[e]],!l.facets[e])throw Error('baobab.Facet: unkown "'+c[e]+'" facet in facets mapping.');return}}})}}function c(t){return Object.keys(t).map(function(e){return t[e].solvedPath})}function h(t){var e=Object.keys(t).map(function(e){return c(t[e].cursors)});return[].concat.apply([],e)}var l=this,f=!0,p=!1,d=e.get,y=null;o.call(this),this.tree=t,this.cursors={},this.facets={};var g=e.cursors,v=e.facets,b="function"==typeof e.cursors,m="function"==typeof e.facets;this.refresh=function(t){if(t=t||[],!a.Array(t))throw Error("baobab.Facet.refresh: first argument should be an array.");g&&u(b,g,"cursors",a.FacetCursors,t),v&&u(m,v,"facets",a.FacetFacets,t)},this.get=function(){if(p)return y;var t,e={};for(t in l.facets)e[t]=l.facets[t].get();for(t in l.cursors)e[t]=l.cursors[t].get();return e="function"==typeof d?d.call(null,e):e,p=!0,y=e},this.updateHandler=function(t){var e=c(l.cursors).concat(h(l.facets));s.solveUpdate(t.data.log,e)&&(p=!1,l.emit("update"))},this.refresh(r),this.tree.on("update",this.updateHandler),f=!1}var o=t("emmett"),i=t("./cursor.js"),s=t("./helpers.js"),a=t("./type.js");s.inherits(n,o),n.prototype.release=function(){this.tree.off("update",this.updateHandler),this.tree=null,this.cursors=null,this.facets=null,this.kill()},e.exports=n},{"./cursor.js":5,"./helpers.js":7,"./type.js":9,emmett:3}],7:[function(t,e,r){(function(r){function n(t){return Array.prototype.slice.call(t)}function o(t,e){return function(){t(),e.apply(null,arguments)}}function i(t,e,r){var o=n(arguments).slice(3);return t.slice(0,e).concat(o).concat(t.slice(e+r))}function s(t,e){var r,n={};for(r in t)n[r]=t[r];for(r in e)n[r]=e[r];return n}function a(t){var e=t.source,r="";return t.global&&(r+="g"),t.multiline&&(r+="m"),t.ignoreCase&&(r+="i"),t.sticky&&(r+="y"),t.unicode&&(r+="u"),new RegExp(e,r)}function u(t,e){if(!e||"object"!=typeof e||e instanceof Error||"ArrayBuffer"in r&&e instanceof ArrayBuffer)return e;if(w.Array(e)){if(t){var n,o,i=[];for(n=0,o=e.length;o>n;n++)i.push(P(e[n]));return i}return e.slice(0)}if(w.Date(e))return new Date(e.getTime());if(e instanceof RegExp)return a(e);if(w.Object(e)){var s,u={};e.constructor&&e.constructor!==Object&&(u=Object.create(e.constructor.prototype));for(s in e)e.hasOwnProperty(s)&&(u[s]=t?P(e[s]):e[s]);return u}return e}function c(t,e){return function(r){return e(t(r))}}function h(t,e){var r,n;for(r=0,n=t.length;n>r;r++)if(e(t[r]))return t[r]}function l(t,e){var r,n;for(r=0,n=t.length;n>r;r++)if(e(t[r]))return r;return-1}function f(t,e){var r,n=!0;if(!t)return!1;for(r in e)if(w.Object(e[r]))n=n&&f(t[r],e[r]);else if(w.Array(e[r]))n=n&&!!~e[r].indexOf(t[r]);else if(t[r]!==e[r])return!1;return n}function d(t,e){return h(t,function(t){return f(t,e)})}function y(t,e){return l(t,function(t){return f(t,e)})}function g(t,e,r){e=e||[];var n,o,i,s=t;for(o=0,i=e.length;i>o;o++){if(!s)return;if("function"==typeof e[o]){if(!w.Array(s))return;s=h(s,e[o])}else if("object"==typeof e[o])if(r&&"$cursor"in e[o]){if(!w.Path(e[o].$cursor))throw Error("baobab.getIn: $cursor path must be an array.");n=r.get(e[o].$cursor),s=s[n]}else{if(!w.Array(s))return;s=d(s,e[o])}else s=s[e[o]]}return s}function v(t,e,r){var n,o,i,s=[],a=t;for(o=0,i=e.length;i>o;o++){if(!a)return null;if("function"==typeof e[o]){if(!w.Array(a))return;n=l(a,e[o]),s.push(n),a=a[n]}else if("object"==typeof e[o])if(r&&"$cursor"in e[o]){if(!w.Path(e[o].$cursor))throw Error("baobab.getIn: $cursor path must be an array.");p=r.get(e[o].$cursor),s.push(p),a=a[p]}else{if(!w.Array(a))return;n=y(a,e[o]),s.push(n),a=a[n]}else s.push(e[o]),a=a[e[o]]||{}}return s}function b(t,e){var r,n,o,i,s,a,u,c,h;for(r=0,i=e.length;i>r;r++)for(u=e[r],n=0,s=t.length;s>n;n++)for(c=t[n],o=0,a=c.length;a>o&&(h=c[o],h==u[o]);o++)if(o+1===a||o+1===u.length)return!0;return!1}function m(t,e){var r,n=t.length,o={},i=o;for(n||(o=e),r=0;n>r;r++)i[t[r]]=r+1===n?e:{},i=i[t[r]];return o}function j(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function _(t){var e=[];return{add:function(r){e.unshift(r),e.length>t&&(e.length=t)},back:function(t){var r=e[t-1];return r&&(e=e.slice(t)),r},get:function(){return e}}}var w=t("./type.js"),$=u.bind(null,!1),P=u.bind(null,!0);e.exports={archive:_,arrayOf:n,before:o,deepClone:P,shallowClone:$,shallowMerge:s,compose:c,getIn:g,inherits:j,pathObject:m,solvePath:v,solveUpdate:b,splice:i}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./type.js":9}],8:[function(t,e,r){function n(t,e){var r={};return r[t]=e,r}function o(t,e){var r,u=i.shallowClone(t||{}),c=!1;if(a.forEach(function(t){t in e&&(u=n(t,e[t]),c=!0)}),e.$chain&&(u.$apply=u.$apply?i.compose(u.$apply,e.$chain):e.$chain,u=n("$apply",u.$apply),c=!0),e.$merge&&(u.$merge=i.shallowMerge(u.$merge||{},e.$merge),c=!0),(e.$splice||e.$splice)&&(u.$splice=[].concat(u.$splice||[]).concat(e.$splice||[]),c=!0),(e.$push||u.$push)&&(u.$push=[].concat(u.$push||[]).concat(e.$push||[]),c=!0),(e.$unshift||u.$unshift)&&(u.$unshift=[].concat(e.$unshift||[]).concat(u.$unshift||[]),c=!0),c)return u;for(r in u)"$"===r.charAt(0)&&delete u[r];for(r in e)s.Object(e[r])&&(u[r]=o(u[r],e[r]));return u}var i=t("./helpers.js"),s=t("./type.js"),a=["$unset","$set","$apply"];e.exports=o},{"./helpers.js":7,"./type.js":9}],9:[function(t,e,r){function n(t,e){return e.some(function(e){return o[e](t)})}var o={};o.Array=function(t){return Array.isArray(t)},o.Object=function(t){return t&&"object"==typeof t&&!Array.isArray(t)&&!(t instanceof Function)},o.String=function(t){return"string"==typeof t},o.Number=function(t){return"number"==typeof t},o.PositiveInteger=function(t){return"number"==typeof t&&t>0&&t%1===0},o.Function=function(t){return"function"==typeof t},o.Primitive=function(t){return!t||"string"==typeof t||"number"==typeof t||"boolean"==typeof t},o.Date=function(t){return t instanceof Date},o.NonScalar=function(t){return o.Object(t)||o.Array(t)},o.Splicer=function(t){return o.Array(t)&&t.every(o.Array)},o.Path=function(t,e){return e=e||["String","Number","Function","Object"],o.Array(t)?t.every(function(t){return n(t,e)}):n(t,e)},o.ComplexPath=function(t){return t.some(function(t){return n(t,["Object","Function"])})},o.FacetCursors=function(e){return o.Object(e)?Object.keys(e).every(function(r){var n=e[r];return o.Path(n,["String","Number","Object"])||n instanceof t("./cursor.js")}):!1},o.FacetFacets=function(e){return o.Object(e)?Object.keys(e).every(function(r){var n=e[r];return"string"==typeof n||n instanceof t("./facet.js")}):!1},e.exports=o},{"./cursor.js":5,"./facet.js":6}],10:[function(t,e,r){function n(t,e){var r=new Error("baobab.update: "+e+" at path /"+t.slice(1).join("/"));return r.path=t,r}var o=t("./helpers.js"),i=t("./type.js");e.exports=function(t,e,r){r=r||{};var s={};t={root:o.shallowClone(t)};var a=function(t,e,r,u){r=r||["root"];var c,h,l,f,p,d=r.join("|λ|"),y=r[r.length-1],g=t[y];t[y]=i.Primitive(t[y])?{}:o.shallowClone(t[y]);var v=Object.keys(e).some(function(t){return"$"===t.charAt(0)});if(v){s[d]=!0;for(h in e){if("$unset"===h){var b=r[r.length-2];if(!i.Object(u[b]))throw n(r.slice(0,-1),"using command $unset on a non-object");u[b]=o.shallowClone(t),delete u[b][y];break}if("$set"===h)l=e.$set,t[y]=l;else if("$apply"===h||"$chain"===h){if(c=e.$apply||e.$chain,"function"!=typeof c)throw n(r,"using command $apply with a non function");t[y]=c.call(null,g)}else if("$merge"===h){if(l=e.$merge,!i.Object(t[y])||!i.Object(l))throw n(r,"using command $merge with a non object");t[y]=o.shallowMerge(t[y],l)}if("$splice"===h){if(l=e.$splice,!i.Array(t[y]))throw n(r,"using command $push to a non array");for(f=0,p=l.length;p>f;f++)t[y]=o.splice.apply(null,[t[y]].concat(l[f]))}if("$push"===h){if(l=e.$push,!i.Array(t[y]))throw n(r,"using command $push to a non array");t[y]=t[y].concat(l)}if("$unshift"===h){if(l=e.$unshift,!i.Array(t[y]))throw n(r,"using command $unshift to a non array");t[y]=[].concat(l).concat(t[y])}}}else for(h in e)a(t[y],e[h],r.concat(h),t)};return a(t,e),{data:t.root,log:Object.keys(s).map(function(t){return t.split("|λ|").slice(1)})}}},{"./helpers.js":7,"./type.js":9}]},{},[1])(1)}); \ No newline at end of file diff --git a/index.js b/index.js index 7eb9831..d7f5620 100644 --- a/index.js +++ b/index.js @@ -9,7 +9,7 @@ var Baobab = require('./src/baobab.js'), // Non-writable version Object.defineProperty(Baobab, 'version', { - value: '1.0.1' + value: '1.0.2' }); // Exposing helpers diff --git a/package.json b/package.json index 7b1131b..5a6752d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "baobab", - "version": "1.0.1", + "version": "1.0.2", "description": "JavaScript persistent data tree with cursors.", "main": "index.js", "dependencies": {