control-freak-ide/Code/client/build/dgrid/dstore/Memory.js
plastic-hub-dev-node-saturn 538369cff7 latest
2021-05-12 18:35:18 +02:00

7 lines
2.2 KiB
JavaScript

//>>built
define("dstore/Memory","dojo/_base/declare dojo/_base/array ./Store ./Promised ./SimpleQuery ./QueryResults".split(" "),function(m,r,n,p,q,l){return m([n,p,q],{constructor:function(){this.storage.version=0},postscript:function(){this.inherited(arguments);this.setData(this.data||[])},data:null,autoEmitEvents:!1,getSync:function(a){return this.storage.fullData[this.storage.index[a]]},putSync:function(a,b){b=b||{};var c=this.storage,g=c.index,h=c.fullData,e=this.Model;!e||a instanceof e||(a=this._restore(a));
var f=this.getIdentity(a);null==f&&(this._setIdentity(a,"id"in b?b.id:Math.random()),f=this.getIdentity(a));c.version++;var c=f in g?"update":"add",e={target:a},d;if("update"===c){if(!1===b.overwrite)throw Error("Object already exists");h.splice(d=g[f],1);f=d}else f=this.defaultNewToStart?0:h.length;if("beforeId"in b){var k=b.beforeId;null===k?b=h.length:(b=g[k],d<b&&--b);void 0!==b?e.beforeId=k:(console.error("options.beforeId was specified but no corresponding index was found"),b=f)}else b=f;h.splice(b,
0,a);d=isFinite(d)?Math.min(d,b):b;for(b=h.length;d<b;++d)g[this.getIdentity(h[d])]=d;this.emit(c,e);return a},addSync:function(a,b){(b=b||{}).overwrite=!1;return this.putSync(a,b)},removeSync:function(a){var b=this.storage,c=b.index,b=b.fullData;if(a in c)return c=b.splice(c[a],1)[0],this._reindex(),!0!==this._ignoreChangeEvents&&this.emit("delete",{id:a,target:c}),!0},setData:function(a){this.parse&&(a=this.parse(a));a.items&&(this.idProperty=a.identifier||this.idProperty,a=a.items);this.storage.fullData=
this.data=a;this._reindex()},_reindex:function(){for(var a=this.storage,b=a.index={},c=a.fullData,g=this.Model,h=Object.prototype,e=0,f=c.length;e<f;e++){var d=c[e];if(g&&!(d instanceof g)){var k=this._restore(d,d.__proto__===h);d!==k&&(c[e]=d=k)}b[this.getIdentity(d)]=e}a.version++},fetchSync:function(){var a=this.data;if(!a||a._version!==this.storage.version){for(var a=this.storage.fullData,b=this.queryLog,c=0,g=b.length;c<g;c++)a=b[c].querier(a);a._version=this.storage.version;this.data=a}return new l(a)},
fetchRangeSync:function(a){var b=this.fetchSync();return new l(b.slice(a.start,a.end),{totalLength:b.length})},_includePropertyInSubCollection:function(a){return"data"!==a&&this.inherited(arguments)}})});
//# sourceMappingURL=Memory.js.map