New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

one

Package Overview
Dependencies
Maintainers
1
Versions
217
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

one - npm Package Compare versions

Comparing version 5.1.3 to 5.1.4

wallaby.js

2

dist/one.min.js

@@ -1,1 +0,1 @@

!function(e){function n(t){if(r[t])return r[t].exports;var i=r[t]={exports:{},id:t,loaded:!1};return e[t].call(i.exports,i,i.exports,n),i.loaded=!0,i.exports}var r={};return n.m=e,n.c=r,n.p="",n(0)}([function(e,n,r){"use strict";function t(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(n,"__esModule",{value:!0}),n.createCache=void 0;var i=r(1),o=t(i);!function(){(0,o["default"])()}(),n.createCache=o["default"]},function(e,n,r){"use strict";function t(e){if(e&&e.__esModule)return e;var n={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n["default"]=e,n}function i(e){return e&&e.__esModule?e:{"default":e}}function o(e){if(Array.isArray(e)){for(var n=0,r=Array(e.length);n<e.length;n++)r[n]=e[n];return r}return Array.from(e)}function u(){var e=arguments.length<=0||void 0===arguments[0]?!0:arguments[0],n=arguments.length<=1||void 0===arguments[1]?"One":arguments[1];return window?(void 0===window[n]&&(window[n]=f(e)),window[n]):f(e)}function f(){function e(){return c||(c=r(),c.current=-1,c.nodes=[]),c}function n(){var e=r();return e.id=s,s+=1,d.set(e.id,e),e}function r(){var e={};return Object.defineProperty(e,"length",{value:0,enumerable:!1,writable:!0}),e}function t(e,n){for(var r,t,i=0,o=e.length-1;o>=i;)if(r=(i+o)/2|0,t=e[r],n>t)i=r+1;else{if(!(t>n))return r;o=r-1}return-1}function i(){var e=c.nodes[c.current];return e>=0?u(e):void 0}function u(e){return d.get(e)}var f=arguments.length<=0||void 0===arguments[0]?!1:arguments[0],c=void 0,s=0,d=new Map,O=r(),h=r(),E=[],g=function(){O=r(),d.clear(),c=void 0,c=e(),s=0};g();for(var F=function(e){if(pe()>0)throw new Error("You may only configure an empty cache. Please clear the cache first and then configure.");l.config(e)},y=function(e){var n=arguments.length<=1||void 0===arguments[1]?!0:arguments[1];if((0,a.isArray)(e)||(0,a.isObject)(e)){var r=new Map,t=new Map;r.set(p.UPDATED_KEY,!1),w(e,r,null,t,n),S(r);var i=r.get(p.UPDATED_KEY);r["delete"](p.UPDATED_KEY);var u=!1;return r.size>0&&i&&(Ee(),$([].concat(o(r.values())),t),Te(),u=!0),le(u)}return le(!1)},R=function(e){function n(e,n){if((0,a.hasUid)(e)){var t=e[l.prop.uidName],i=O[t];!r&&i||!r&&N(t)||(T(t)||(O.length+=1),O[t]=e,n.push(t))}}var r=arguments.length<=1||void 0===arguments[1]?!1:arguments[1],t=[];(0,a.isArray)(e)?e.forEach(function(e){n(e,t)}):(0,a.isObject)(e)&&n(e,t);var i=t.length>0;return i&&Te(t),t.length},_=function(e){var n=ne(e);if(n)return O[n]?(O[n]=void 0,O.length>0&&(O.length-=1),!0):!1},b=function(e){var n=arguments.length<=1||void 0===arguments[1]?!1:arguments[1];if(O.length>0){var t=[];for(var i in O)O.hasOwnProperty(i)&&t.push(O[i]);var o=y(t,e,n);return o.success===!0&&(O=r()),o}return le(!1)},m=function(e){return e&&(0,a.hasUid)(e)?(h[e[l.prop.uidName]]=e,!0):!1},T=function(e){var n=ne(e);if(n)return O[n]},N=function(e){if(!e)throw new TypeError("One get(): requires a uid to retrieve an item from the cache.");return(0,a.isArray)(e)?e.map(function(e){return ee(e)}).filter(function(e){return null!==e&&void 0!==e}):ee(e)},M=function(e){var n=j(e);if(0==n.length)return!1;var r=X(),t=n.some(function(e){return r&&r.has(String(e))});if(!t)return!1;var i=new Map;r.forEach(function(e,n){i.set(n,e)}),Ee();var o=new Map,u=new Map;return n.forEach(function(e){Y(e,o,u),u.set(e,null),z(e,o)}),o.forEach(function(e,n){i.set(n,e)}),u.forEach(function(e,n){i["delete"](n)}),Fe(i),Te(),!0},j=function(e){var n=[];if((0,a.isArray)(e))e.forEach(function(e){(0,a.hasUid)(e)?n.push(String(e[l.prop.uidName])):"string"!=typeof e&&"number"!=typeof e||n.push(String(e))});else{var r=e;if((0,a.isObject)(e)&&(r=e[l.prop.uidName]),void 0===r)return n;n.push(String(r))}return n},S=function(e){e.forEach(function(n,r){if(r!==p.UPDATED_KEY){var t=n[p.REF_FROM];for(var i in t)if(t.hasOwnProperty(i)){var o=t[i],u=e.get(i);if(u||(u=ye(i)),u&&o.length>0){var f=o[0],c=v.get(u[p.ENTITY],f),s=c&&c!==n[p.ENTITY];s===!0&&(u=ue(u[p.ENTITY],e),u[p.ENTITY]=(0,a.deepClone)(u[p.ENTITY],n[p.ENTITY],!0))}}}})},w=function(e,n,r,t,i){(0,a.hasUid)(e)?P(e,n,r,t,i):((0,a.isArray)(e)?L(e,n,r,t,"",i):G(e,n,r,t,"",i),Object.freeze(e))},P=function(e,n,r,t,i){var o=String(e[l.prop.uidName]);Z(e)!==!0&&(i===!1&&ye(e[l.prop.uidName])||(n.has(o)?G(e,n,r,t,"",i):(ue(e,n),r=String(o),G(e,n,r,t,"",i),Object.isFrozen(e)||Object.freeze(e)),A(o,n,t)))},Y=function Ye(e,n,r){var t=ye(e);if(t){var i=t[p.REF_TO];for(var o in i)if(i.hasOwnProperty(o)){var u=I(o,n);u&&(q(u,e),0===u[p.REF_FROM].length?(Ye(o,n,r),r.set(o,u)):n.set(o,u))}}},z=function(e,n){var r=I(e,n);if(r){var t=r[p.REF_FROM];for(var i in t)if(t.hasOwnProperty(i)){var o=I(i,n);if(o){var u=H(o,e);u===!0&&n.set(i,o)}}}},I=function(e,n){if(e){e=String(e);var r=n.get(e);return r||(r=ye(e)),Object.isFrozen(r)&&(r=fe(r)),r}},A=function(e,n,r){var t=I(e,n);if(t){var i=t[p.REF_TO],o=function(o){if(i.hasOwnProperty(o)){var u=i[o],f=u.map(function(i){var u=v.get(t[p.ENTITY],i);if(u){var f=u[l.prop.uidName];if(f){var a=f==o;if(a===!0)return i}}U(e,o,i,n,r)}).filter(function(e){return null!==e&&void 0!==e});f.length>0?t[p.REF_TO][o]=f:(t[p.REF_TO][o]=void 0,delete t[p.REF_TO][o])}};for(var u in i)o(u)}},x=function(e){Object.freeze(e),Object.freeze(e[p.ENTITY]),Object.freeze(e[p.REF_TO]),Object.freeze(e[p.REF_FROM])},U=function(e,n,r,t,i){var o=I(n,t);o&&(o=Object.assign({},o),D(o,p.REF_FROM),o[p.REF_FROM].hasOwnProperty(e)&&(J(o,e,r),0===o[p.REF_FROM].length?(i.set(n,o),t["delete"](n)):(t.set(n,o),i["delete"](n))))},D=function(e,n){var t=e[n].length;e[n]=Object.assign(r(),e[n]),e[n].length=t},C=function(e,n,r){var t=e[p.REF_TO];e[p.REF_TO][n]||(e[p.REF_TO][n]=[],e[p.REF_TO].length+=1);var i=t[n];return i.indexOf(r)<0&&i.push(r),e},K=function(e,n,r){var t=e[p.REF_FROM];e[p.REF_FROM][n]||(e[p.REF_FROM][n]=[],e[p.REF_FROM].length+=1);var i=t[n];return i.indexOf(r)<0&&i.push(r),e},J=function(e,n,r){var t=e[p.REF_FROM][n],i=t.indexOf(r);t=t.slice(),t.splice(i,1),e[p.REF_FROM][n]=t,0==t.length&&(e[p.REF_FROM][n]=void 0,delete e[p.REF_FROM][n],e[p.REF_FROM].length-=1)},q=function(e,n){var r=e[p.REF_FROM][n];r&&(D(e,p.REF_FROM),e[p.REF_FROM][n]=void 0,delete e[p.REF_FROM][n],e[p.REF_FROM].length>0&&(e[p.REF_FROM].length-=1))},H=function(e,n){var r=e[p.ENTITY];Object.isFrozen(r)&&(r=re(r[l.prop.uidName]),e[p.ENTITY]=r);var t=e[p.REF_TO][n];return t.forEach(function(e){v.del(r,e)}),Object.isFrozen(r)||Object.freeze(r),e[p.ENTITY]=r,D(e,p.REF_TO),e[p.REF_TO][n]=void 0,delete e[p.REF_TO][n],e[p.REF_TO].length>0&&(e[p.REF_TO].length-=1),!0},Q=function(e){O[e]&&(O[e]=void 0,O.length>0&&(O.length-=1))},G=function(e,n,r,t){var i=arguments.length<=4||void 0===arguments[4]?"":arguments[4],o=arguments[5];for(var u in e){if(e.hasOwnProperty(u)){i=W(i,u);var f=e[u];if((0,a.isArray)(f))L(f,n,r,t,i,o);else if((0,a.isObject)(f)){if(o===!1&&ye(f[l.prop.uidName]))return;k(f,n,r,t,i,o)}Object.freeze(f)}i=""}},Z=function(e){var n=e[l.prop.uidName],r=ye(n);return r&&r[p.ENTITY]===e},k=function(e,n,r,t){var i=arguments.length<=4||void 0===arguments[4]?"":arguments[4],o=arguments[5];if((0,a.hasUid)(e)){if(o===!1&&ye(e[l.prop.uidName]))return;var u=ue(e,n);if(u){B(u,r,i,n);var f=Z(e);if(f===!0)return;u[p.ENTITY]=e,r=String(e[l.prop.uidName]),w(e,n,r,t,i,o)}}else G(e,n,r,t,i,o);Object.freeze(e)},B=function(e,n,r,t){var i=I(n,t);i&&r&&""!==r&&V(i,e,r)},L=function ze(e,n,r,t){var i=arguments.length<=4||void 0===arguments[4]?"":arguments[4],o=arguments[5],u=void 0;e.forEach(function(e,f){u=i+"."+f,(0,a.isArray)(e)?ze(e,n,r,t,u,o):(0,a.isObject)(e)&&k(e,n,r,t,u,o)}),Object.freeze(e)},V=function(e,n,r){var t=e[p.ENTITY][l.prop.uidName],i=n[p.ENTITY][l.prop.uidName];C(e,i,r),K(n,t,r)},W=function(e,n){return e=""===e?n:e+"."+n},X=function(){var e=i();return e?e.items:new Map},$=function(e,n){var r=new Map,t=X();t.forEach(function(e,n){r.set(n,e)}),e.forEach(function(e){var n=e[p.ENTITY][l.prop.uidName];x(e),r.set(String(n),e)}),n.size>0&&n.forEach(function(e,n){r["delete"](String(n))}),Fe(r)},ee=function(e){var n=ne(e);if(n){var r=ye(n);if(void 0!==r)return r[p.ENTITY];var t=O[n];if(t)return t}},ne=function(e){return"string"==typeof e?e:"number"==typeof e?String(e):(0,a.isObject)(e)&&(0,a.hasUid)(e)?e[l.prop.uidName]:void 0},re=function(e){return(0,a.isArray)(e)?e.map(function(e){return oe(e)}).filter(function(e){return null!==e&void 0!==e}):oe(e)},te=function(e){if((0,a.isNumber)(e)===!0){if(c.current!==e){if(!(e>=0&&e<Oe()))throw new TypeError("Index out of bounds");return c.current=e,Te(),!0}return!1}return c.current},ie=function(e){if("undefined"==typeof e){var n=i();return n?n.id:-1}if(!(0,a.isNumber)(e))throw new TypeError("The node id must be a number.");var r=u(e);return r?(c.current=t(c.nodes,e),le(!0)):le(!1)},oe=function(e){var n=ne(e);if(T(n))return O[n];var r=N(n);if(r)return(0,a.deepClone)(r,void 0,!1)},ue=function(e,n){var t=String(e[l.prop.uidName]),i=n.get(t);if(i)return i;i={};var o=ye(t);return i[p.ENTITY]=e,void 0!==o?(i=Object.assign(i,o),i[p.ENTITY]=e,i[p.REF_FROM]=Object.assign(r(),o[p.REF_FROM]),i[p.REF_FROM].length=o[p.REF_FROM].length,i[p.REF_TO]=Object.assign(r(),o[p.REF_TO]),i[p.REF_TO].length=o[p.REF_TO].length):(i[p.REF_FROM]=r(),i[p.REF_TO]=r()),n.set(t,i),n.set(p.UPDATED_KEY,!0),Q(t),i},fe=function(e){var n=Object.assign({},e);return D(n,p.REF_FROM),D(n,p.REF_TO),n},ae=function(e){return(0,a.hasUid)(e)?"undefined"!=typeof ye(e[l.prop.uidName]):!1},ce=function(){var e=!1;return ve()&&(c.current-=1,e=!0),le(e)},se=function(){var e=!1;return de()&&(c.current+=1,e=!0),le(e)},le=function(e){var n={};return n.success=e,n.index=te(),n.node=ie(),n.length=Oe(),n.hasPrev=n.index>0,n.hasNext=n.index<n.length-1,n},de=function(){return c.current<c.nodes.length-1},ve=function(){return c.current>0},pe=function(){var e=i();return e?e.items.size:0},Oe=function(){return c.nodes.length},he=function(){return{queue:O.length}},Ee=function(){if(c.current<c.nodes.length-1){var e=c.nodes.slice(c.current+1,c.nodes.length);c.nodes=c.nodes.slice(0,c.current+1),c.current=c.nodes.length-1,ge(e)}},ge=function(e){e.forEach(function(e){var n=d.get(e);n&&d["delete"](e)})},Fe=function(e,r){if(null!==e){Object.freeze(e);var t=n();t.items=e,c.nodes.indexOf(t.id)<0&&(c.nodes.push(t.id),c.current+=1)}},ye=function(e){var n=i();return n?n.items.get(String(e)):void 0},Re=function(){var e="",n=0,r=c.current;c.nodes.map(function(t){var i="",o=d.get(t),u=n+":"+i+"\n["+_e(o.items)+"],\n\n";n===r&&(u="-> "+u),e+=u,n++}),e=e.substring(0,e.length-2),n=0,console.log("\n------ One -------\nSTACK:\n"+e+"\n\nCONFIG:"+JSON.stringify(l,null,2)+"\n\nQUEUE:"+JSON.stringify(O,null,2)+"\n\nHISTORY:"+JSON.stringify(le(),null,2)+"\n\nREPO SIZE:"+d.size+"\n===================\n")},_e=function(e){var n="",r=[].concat(o(e.values()));return r.map(function(e){var r=void 0;r=JSON.stringify(e,null,2)+",\n",r.indexOf(p.REF_FROM)>=0&&e[p.REF_FROM]&&(r=r.replace('"'+p.REF_FROM+'": {}','"'+p.REF_FROM+'": '+JSON.stringify([].concat(o(e[p.REF_FROM]))))),r.indexOf(p.REF_TO)>=0&&e[p.REF_TO]&&(r=r.replace('"'+p.REF_TO+'": {}','"'+p.REF_TO+'": '+JSON.stringify(e[p.REF_TO]))),n+=r}),n.length>2&&(n=n.substring(0,n.length-2)),n},be=function(e){if(!(0,a.hasUid)(e))return!0;var n=e[l.prop.uidName],r=N(n);return r?r!==e:!0},me=function(e){E.push(e);var n=!0;return function(){if(n){n=!1;var r=E.indexOf(e);E.splice(r,1)}}},Te=function(e){E.slice().forEach(function(n){n(e)})},Ne=[],Me=0;256>Me;Me++)Ne[Me]=(16>Me?"0":"")+Me.toString(16);var je=function(){var e=4294967296*Math.random()|0,n=4294967296*Math.random()|0,r=4294967296*Math.random()|0,t=4294967296*Math.random()|0;return Ne[255&e]+Ne[e>>8&255]+Ne[e>>16&255]+Ne[e>>24&255]+"-"+Ne[255&n]+Ne[n>>8&255]+"-"+Ne[n>>16&15|64]+Ne[n>>24&255]+"-"+Ne[63&r|128]+Ne[r>>8&255]+"-"+Ne[r>>16&255]+Ne[r>>24&255]+Ne[255&t]+Ne[t>>8&255]+Ne[t>>16&255]+Ne[t>>24&255]},Se=function(e){var n=ye(e);return n[p.REF_FROM]},we=function(e){var n=ye(e);return n[p.REF_TO]},Pe={put:y,get:N,getEdit:re,evict:M,reset:g,queue:R,unQueue:_,queueEvict:m,getQueued:T,commit:b,undo:ce,redo:se,index:te,node:ie,getHistoryState:le,isDirty:be,uuid:je,contains:ae,config:F,subscribe:me};return f===!0&&(Pe.getCurrentNode=i,Pe.refFrom=Se,Pe.refTo=we,Pe.size=pe,Pe.length=Oe,Pe.pending=he,Pe.print=Re),Pe}Object.defineProperty(n,"__esModule",{value:!0}),n["default"]=u;var a=r(2),c=r(4),s=(i(c),r(3)),l=t(s),d=r(5),v=t(d),p=r(6)},function(e,n,r){"use strict";function t(e){if(e&&e.__esModule)return e;var n={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n["default"]=e,n}function i(e){return"number"==typeof e||"[object Number]"===toString(e)}function o(e){return"string"==typeof e||"[object String]"===toString(e)}function u(e){if(!e)return!0;if(l(e)&&0===e.length)return!0;if(!o(e)){for(var n in e)if(E.call(e,n))return!1;return!0}return!1}function f(e,n){var r=arguments.length<=2||void 0===arguments[2]?!0:arguments[2];if(!e||!s(e)&&!l(e))return e;if(r===!0&&n&&!Object.isFrozen(n)&&Object.freeze(n),n&&c(e)&&e[h.prop.uidName]===n[h.prop.uidName])return n;var t=Object.assign({},e);for(var i in t)if(t.hasOwnProperty(i)){var o=t[i];if(o)if(l(o))t[i]=a(o,n,r);else if(v(o)){var u=new Date(o.getTime());r===!0&&Object.freeze(u),t[i]=u}else s(o)&&(c(o)?(t[i]=o,n&&c(n)&&o!==n&&o.uid===n.uid&&o!==n&&(t[i]=n)):t[i]=f(o,n,r))}return r!==!0||Object.isFrozen(t)||Object.freeze(t),t}function a(e,n,r){return e.map(function(e){return l(e)?a(e,n,r):s(e)?c(e)?n&&e[h.prop.uidName]===n[h.prop.uidName]?n:e:f(e,n,r):e})}function c(e){if(!e)return!1;if(!s(e))return!1;if("undefined"==typeof e[h.prop.uidName])return!1;var n=e[h.prop.uidName];return 0!==n.length}function s(e){return"[object Array]"===Object.prototype.toString.call(e)?!1:null!==e&&"object"===("undefined"==typeof e?"undefined":p(e))}function l(e){return e&&null!==e?Array.isArray(e)||e&&"object"===("undefined"==typeof e?"undefined":p(e))&&"number"==typeof e.length&&"function"==typeof e.splice&&!e.propertyIsEnumerable("length"):!1}function d(e){return Object.prototype.toString.call(e)}function v(e){return s(e)&&"[object Date]"===d(e)}Object.defineProperty(n,"__esModule",{value:!0});var p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e};n.isNumber=i,n.isString=o,n.isEmpty=u,n.deepClone=f,n.hasUid=c,n.isObject=s,n.isArray=l,n.isDate=v;var O=r(3),h=t(O),E=Object.prototype.hasOwnProperty},function(e,n){"use strict";function r(e){for(var n in t)t.hasOwnProperty(n)&&e.hasOwnProperty(n)&&(t[n]=e[n])}Object.defineProperty(n,"__esModule",{value:!0}),n.config=r;var t=n.prop={uidName:"uid",maxHistoryStates:1e3}},function(e,n){"use strict";function r(e){return e?(Object.freeze(e),Object.getOwnPropertyNames(e).forEach(function(n){!e.hasOwnProperty(n)||null===e[n]||"object"!==t(e[n])&&"function"!=typeof e[n]||Object.isFrozen(e[n])||r(e[n])}),e):void 0}Object.defineProperty(n,"__esModule",{value:!0});var t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e};n["default"]=r},function(e,n,r){"use strict";function t(e){var n=parseInt(e);return n.toString()===e?n:e}function i(e,n){if((0,u.isNumber)(n)&&(n=[n]),!(0,u.isEmpty)(e)){if((0,u.isEmpty)(n))return e;if((0,u.isString)(n))return i(e,n.split("."));var r=t(n[0]),o=e[r];if(1===n.length)void 0!==o&&((0,u.isArray)(e)?e.splice(r,1):delete e[r]);else if(void 0!==e[r])return i(e[r],n.slice(1));return e}}function o(e,n,r){if((0,u.isNumber)(n)&&(n=[n]),(0,u.isEmpty)(n))return e;if((0,u.isEmpty)(e))return r;if((0,u.isString)(n))return o(e,n.split("."),r);var i=t(n[0]);return 1===n.length?void 0===e[i]?r:e[i]:o(e[i],n.slice(1),r)}Object.defineProperty(n,"__esModule",{value:!0}),n.del=i,n.get=o;var u=r(2)},function(e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});n.ENTITY="entity",n.REF_FROM="ref_from",n.REF_TO="ref_to",n.UPDATED_KEY="mapUpdatedKey"}]);
!function(e){function n(t){if(r[t])return r[t].exports;var i=r[t]={exports:{},id:t,loaded:!1};return e[t].call(i.exports,i,i.exports,n),i.loaded=!0,i.exports}var r={};return n.m=e,n.c=r,n.p="",n(0)}([function(e,n,r){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.getCache=void 0;var t=r(1);!function(){(0,t.getCache)()}(),n.getCache=t.getCache},function(e,n,r){"use strict";function t(e){if(e&&e.__esModule)return e;var n={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n["default"]=e,n}function i(e){return e&&e.__esModule?e:{"default":e}}function o(e){if(Array.isArray(e)){for(var n=0,r=Array(e.length);n<e.length;n++)r[n]=e[n];return r}return Array.from(e)}function u(){var e=arguments.length<=0||void 0===arguments[0]?!0:arguments[0],n=arguments.length<=1||void 0===arguments[1]?"One":arguments[1];return n||(n="one"),O[n]||(O[n]=f(e)),window&&void 0===window[n]&&(window[n]=O[n]),O[n]}function f(){function e(){return c||(c=r(),c.current=-1,c.nodes=[]),c}function n(){var e=r();return e.id=s,s+=1,d.set(e.id,e),e}function r(){var e={};return Object.defineProperty(e,"length",{value:0,enumerable:!1,writable:!0}),e}function t(e,n){for(var r,t,i=0,o=e.length-1;o>=i;)if(r=(i+o)/2|0,t=e[r],n>t)i=r+1;else{if(!(t>n))return r;o=r-1}return-1}function i(){var e=c.nodes[c.current];return e>=0?u(e):void 0}function u(e){return d.get(e)}var f=arguments.length<=0||void 0===arguments[0]?!1:arguments[0],c=void 0,s=0,d=new Map,O=r(),g=r(),h=[],E=function(){O=r(),d.clear(),c=void 0,c=e(),s=0};E();for(var F=function(e){if(Oe()>0)throw new Error("You may only configure an empty cache. Please clear the cache first and then configure.");l.config(e)},y=function(e){var n=arguments.length<=1||void 0===arguments[1]?!0:arguments[1];if((0,a.isArray)(e)||(0,a.isObject)(e)){var r=new Map,t=new Map;r.set(p.UPDATED_KEY,!1),P(e,r,null,t,n),w(r);var i=r.get(p.UPDATED_KEY);r["delete"](p.UPDATED_KEY);var u=!1;return r.size>0&&i&&(Ee(),ee([].concat(o(r.values())),t),Ne(),u=!0),de(u)}return de(!1)},R=function(e){function n(e,n){if((0,a.hasUid)(e)){var t=e[l.prop.uidName],i=O[t];!r&&i||!r&&N(t)||(T(t)||(O.length+=1),O[t]=e,n.push(t))}}var r=arguments.length<=1||void 0===arguments[1]?!1:arguments[1],t=[];(0,a.isArray)(e)?e.forEach(function(e){n(e,t)}):(0,a.isObject)(e)&&n(e,t);var i=t.length>0;return i&&Ne(t),t.length},_=function(e){var n=re(e);if(n)return O[n]?(O[n]=void 0,O.length>0&&(O.length-=1),!0):!1},b=function(e){var n=arguments.length<=1||void 0===arguments[1]?!1:arguments[1];if(O.length>0){var t=[];for(var i in O)O.hasOwnProperty(i)&&t.push(O[i]);var o=y(t,e,n);return o.success===!0&&(O=r()),o}return de(!1)},m=function(e){return e&&(0,a.hasUid)(e)?(g[e[l.prop.uidName]]=e,!0):!1},T=function(e){var n=re(e);if(n)return O[n]},N=function(e){if(!e)throw new TypeError("One get(): requires a uid to retrieve an item from the cache.");return(0,a.isArray)(e)?e.map(function(e){return ne(e)}).filter(function(e){return null!==e&&void 0!==e}):ne(e)},j=function(e){var n=S(e);if(0==n.length)return!1;var r=$(),t=n.some(function(e){return r&&r.has(String(e))});if(!t)return!1;var i=new Map;r.forEach(function(e,n){i.set(n,e)}),Ee();var o=new Map,u=new Map,f=[];return n.forEach(function(e){z(e,o,u),u.set(e,null),I(e,o,n,f)}),M(f,o),o.forEach(function(e,n){i.set(n,e)}),u.forEach(function(e,n){i["delete"](n)}),ye(i),Ne(),!0},M=function(e,n){e&&e.length>0&&Oe()>0&&(P(e,n,null,null,!1),w(n))},S=function(e){var n=[];if((0,a.isArray)(e))e.forEach(function(e){(0,a.hasUid)(e)?n.push(String(e[l.prop.uidName])):"string"!=typeof e&&"number"!=typeof e||n.push(String(e))});else{var r=e;if((0,a.isObject)(e)&&(r=e[l.prop.uidName]),void 0===r)return n;n.push(String(r))}return n},w=function(e){e.forEach(function(n,r){if(r!==p.UPDATED_KEY){var t=n[p.REF_FROM];for(var i in t)if(t.hasOwnProperty(i)){var o=t[i],u=e.get(i);if(u||(u=Re(i)),u&&o.length>0){var f=o[0],c=v.get(u[p.ENTITY],f),s=c&&c!==n[p.ENTITY];s===!0&&(u=fe(u[p.ENTITY],e),u[p.ENTITY]=(0,a.deepClone)(u[p.ENTITY],n[p.ENTITY],!0))}}}})},P=function(e,n,r,t,i){(0,a.hasUid)(e)?Y(e,n,r,t,i):((0,a.isArray)(e)?V(e,n,r,t,"",i):Z(e,n,r,t,"",i),Object.freeze(e))},Y=function(e,n,r,t,i){var o=String(e[l.prop.uidName]);k(e)!==!0&&(i===!1&&Re(e[l.prop.uidName])||(n.has(o)?Z(e,n,r,t,"",i):(fe(e,n),r=String(o),Z(e,n,r,t,"",i),Object.isFrozen(e)||Object.freeze(e)),x(o,n,t)))},z=function ze(e,n,r){var t=Re(e);if(t){var i=t[p.REF_TO];for(var o in i)if(i.hasOwnProperty(o)){var u=A(o,n);u&&(H(u,e),0===u[p.REF_FROM].length?(ze(o,n,r),r.set(o,u)):n.set(o,u))}}},I=function(e,n,r,t){var i=A(e,n);if(i){var o=i[p.REF_FROM];for(var u in o)if(o.hasOwnProperty(u)){var f=A(u,n);if(f){var a=Q(f,e);a===!0&&(n.set(u,f),r.indexOf(u)<0&&t.push(f))}}}},A=function(e,n){if(e){e=String(e);var r=n.get(e);return r||(r=Re(e)),Object.isFrozen(r)&&(r=ae(r)),r}},x=function(e,n,r){var t=A(e,n);if(t){var i=t[p.REF_TO],o=function(o){if(i.hasOwnProperty(o)){var u=i[o],f=u.map(function(i){var u=v.get(t[p.ENTITY],i);if(u){var f=u[l.prop.uidName];if(f){var a=f==o;if(a===!0)return i}}D(e,o,i,n,r)}).filter(function(e){return null!==e&&void 0!==e});f.length>0?t[p.REF_TO][o]=f:(t[p.REF_TO][o]=void 0,delete t[p.REF_TO][o])}};for(var u in i)o(u)}},U=function(e){Object.freeze(e),Object.freeze(e[p.ENTITY]),Object.freeze(e[p.REF_TO]),Object.freeze(e[p.REF_FROM])},D=function(e,n,r,t,i){var o=A(n,t);o&&(o=Object.assign({},o),C(o,p.REF_FROM),o[p.REF_FROM].hasOwnProperty(e)&&(q(o,e,r),0===o[p.REF_FROM].length?(i.set(n,o),t["delete"](n)):(t.set(n,o),i["delete"](n))))},C=function(e,n){var t=e[n].length;e[n]=Object.assign(r(),e[n]),e[n].length=t},K=function(e,n,r){var t=e[p.REF_TO];e[p.REF_TO][n]||(e[p.REF_TO][n]=[],e[p.REF_TO].length+=1);var i=t[n];return i.indexOf(r)<0&&i.push(r),e},J=function(e,n,r){var t=e[p.REF_FROM];e[p.REF_FROM][n]||(e[p.REF_FROM][n]=[],e[p.REF_FROM].length+=1);var i=t[n];return i.indexOf(r)<0&&i.push(r),e},q=function(e,n,r){var t=e[p.REF_FROM][n],i=t.indexOf(r);t=t.slice(),t.splice(i,1),e[p.REF_FROM][n]=t,0==t.length&&(e[p.REF_FROM][n]=void 0,delete e[p.REF_FROM][n],e[p.REF_FROM].length-=1)},H=function(e,n){var r=e[p.REF_FROM][n];r&&(C(e,p.REF_FROM),e[p.REF_FROM][n]=void 0,delete e[p.REF_FROM][n],e[p.REF_FROM].length>0&&(e[p.REF_FROM].length-=1))},Q=function(e,n){var r=e[p.ENTITY];Object.isFrozen(r)&&(r=te(r[l.prop.uidName]),e[p.ENTITY]=r);var t=e[p.REF_TO][n];return t.forEach(function(e){v.del(r,e)}),Object.isFrozen(r)||Object.freeze(r),e[p.ENTITY]=r,C(e,p.REF_TO),e[p.REF_TO][n]=void 0,delete e[p.REF_TO][n],e[p.REF_TO].length>0&&(e[p.REF_TO].length-=1),!0},G=function(e){O[e]&&(O[e]=void 0,O.length>0&&(O.length-=1))},Z=function(e,n,r,t){var i=arguments.length<=4||void 0===arguments[4]?"":arguments[4],o=arguments[5];for(var u in e){if(e.hasOwnProperty(u)){i=X(i,u);var f=e[u];if((0,a.isArray)(f))V(f,n,r,t,i,o);else if((0,a.isObject)(f)){if(o===!1&&Re(f[l.prop.uidName]))return;B(f,n,r,t,i,o)}Object.freeze(f)}i=""}},k=function(e){var n=e[l.prop.uidName],r=Re(n);return r&&r[p.ENTITY]===e},B=function(e,n,r,t){var i=arguments.length<=4||void 0===arguments[4]?"":arguments[4],o=arguments[5];if((0,a.hasUid)(e)){if(o===!1&&Re(e[l.prop.uidName]))return;var u=fe(e,n);if(u){L(u,r,i,n);var f=k(e);if(f===!0)return;u[p.ENTITY]=e,r=String(e[l.prop.uidName]),P(e,n,r,t,i,o)}}else Z(e,n,r,t,i,o);Object.freeze(e)},L=function(e,n,r,t){var i=A(n,t);i&&r&&""!==r&&W(i,e,r)},V=function Ie(e,n,r,t){var i=arguments.length<=4||void 0===arguments[4]?"":arguments[4],o=arguments[5],u=void 0;e.forEach(function(e,f){u=i+"."+f,(0,a.isArray)(e)?Ie(e,n,r,t,u,o):(0,a.isObject)(e)&&B(e,n,r,t,u,o)}),Object.freeze(e)},W=function(e,n,r){var t=e[p.ENTITY][l.prop.uidName],i=n[p.ENTITY][l.prop.uidName];K(e,i,r),J(n,t,r)},X=function(e,n){return e=""===e?n:e+"."+n},$=function(){var e=i();return e?e.items:new Map},ee=function(e,n){var r=new Map,t=$();t.forEach(function(e,n){r.set(n,e)}),e.forEach(function(e){var n=e[p.ENTITY][l.prop.uidName];U(e),r.set(String(n),e)}),n.size>0&&n.forEach(function(e,n){r["delete"](String(n))}),ye(r)},ne=function(e){var n=re(e);if(n){var r=Re(n);if(void 0!==r)return r[p.ENTITY];var t=O[n];if(t)return t}},re=function(e){return"string"==typeof e?e:"number"==typeof e?String(e):(0,a.isObject)(e)&&(0,a.hasUid)(e)?e[l.prop.uidName]:void 0},te=function(e){return(0,a.isArray)(e)?e.map(function(e){return ue(e)}).filter(function(e){return null!==e&void 0!==e}):ue(e)},ie=function(e){if((0,a.isNumber)(e)===!0){if(c.current!==e){if(!(e>=0&&e<ge()))throw new TypeError("Index out of bounds");return c.current=e,Ne(),!0}return!1}return c.current},oe=function(e){if("undefined"==typeof e){var n=i();return n?n.id:-1}if(!(0,a.isNumber)(e))throw new TypeError("The node id must be a number.");var r=u(e);return r?(c.current=t(c.nodes,e),de(!0)):de(!1)},ue=function(e){var n=re(e);if(T(n))return O[n];var r=N(n);if(r)return(0,a.deepClone)(r,void 0,!1)},fe=function(e,n){var t=String(e[l.prop.uidName]),i=n.get(t);if(i)return i;i={};var o=Re(t);return i[p.ENTITY]=e,void 0!==o?(i=Object.assign(i,o),i[p.ENTITY]=e,i[p.REF_FROM]=Object.assign(r(),o[p.REF_FROM]),i[p.REF_FROM].length=o[p.REF_FROM].length,i[p.REF_TO]=Object.assign(r(),o[p.REF_TO]),i[p.REF_TO].length=o[p.REF_TO].length):(i[p.REF_FROM]=r(),i[p.REF_TO]=r()),n.set(t,i),n.set(p.UPDATED_KEY,!0),G(t),i},ae=function(e){var n=Object.assign({},e);return C(n,p.REF_FROM),C(n,p.REF_TO),n},ce=function(e){return(0,a.hasUid)(e)?"undefined"!=typeof Re(e[l.prop.uidName]):!1},se=function(){var e=!1;return pe()&&(c.current-=1,e=!0),de(e)},le=function(){var e=!1;return ve()&&(c.current+=1,e=!0),de(e)},de=function(e){var n={};return n.success=e,n.index=ie(),n.node=oe(),n.length=ge(),n.hasPrev=n.index>0,n.hasNext=n.index<n.length-1,n},ve=function(){return c.current<c.nodes.length-1},pe=function(){return c.current>0},Oe=function(){var e=i();return e?e.items.size:0},ge=function(){return c.nodes.length},he=function(){return{queue:O.length}},Ee=function(){if(c.current<c.nodes.length-1){var e=c.nodes.slice(c.current+1,c.nodes.length);c.nodes=c.nodes.slice(0,c.current+1),c.current=c.nodes.length-1,Fe(e)}},Fe=function(e){e.forEach(function(e){var n=d.get(e);n&&d["delete"](e)})},ye=function(e,r){if(null!==e){Object.freeze(e);var t=n();t.items=e,c.nodes.indexOf(t.id)<0&&(c.nodes.push(t.id),c.current+=1)}},Re=function(e){var n=i();return n?n.items.get(String(e)):void 0},_e=function(){var e="",n=0,r=c.current;c.nodes.map(function(t){var i="",o=d.get(t),u=n+":"+i+"\n["+be(o.items)+"],\n\n";n===r&&(u="-> "+u),e+=u,n++}),e=e.substring(0,e.length-2),n=0,console.log("\n------ One -------\nSTACK:\n"+e+"\n\nCONFIG:"+JSON.stringify(l,null,2)+"\n\nQUEUE:"+JSON.stringify(O,null,2)+"\n\nHISTORY:"+JSON.stringify(de(),null,2)+"\n\nREPO SIZE:"+d.size+"\n===================\n")},be=function(e){var n="",r=[].concat(o(e.values()));return r.map(function(e){var r=void 0;r=JSON.stringify(e,null,2)+",\n",r.indexOf(p.REF_FROM)>=0&&e[p.REF_FROM]&&(r=r.replace('"'+p.REF_FROM+'": {}','"'+p.REF_FROM+'": '+JSON.stringify([].concat(o(e[p.REF_FROM]))))),r.indexOf(p.REF_TO)>=0&&e[p.REF_TO]&&(r=r.replace('"'+p.REF_TO+'": {}','"'+p.REF_TO+'": '+JSON.stringify(e[p.REF_TO]))),n+=r}),n.length>2&&(n=n.substring(0,n.length-2)),n},me=function(e){if(!(0,a.hasUid)(e))return!0;var n=e[l.prop.uidName],r=N(n);return r?r!==e:!0},Te=function(e){h.push(e);var n=!0;return function(){if(n){n=!1;var r=h.indexOf(e);h.splice(r,1)}}},Ne=function(e){h.slice().forEach(function(n){n(e)})},je=[],Me=0;256>Me;Me++)je[Me]=(16>Me?"0":"")+Me.toString(16);var Se=function(){var e=4294967296*Math.random()|0,n=4294967296*Math.random()|0,r=4294967296*Math.random()|0,t=4294967296*Math.random()|0;return je[255&e]+je[e>>8&255]+je[e>>16&255]+je[e>>24&255]+"-"+je[255&n]+je[n>>8&255]+"-"+je[n>>16&15|64]+je[n>>24&255]+"-"+je[63&r|128]+je[r>>8&255]+"-"+je[r>>16&255]+je[r>>24&255]+je[255&t]+je[t>>8&255]+je[t>>16&255]+je[t>>24&255]},we=function(e){var n=Re(e);return n[p.REF_FROM]},Pe=function(e){var n=Re(e);return n[p.REF_TO]},Ye={put:y,get:N,getEdit:te,evict:j,reset:E,queue:R,unQueue:_,queueEvict:m,getQueued:T,commit:b,undo:se,redo:le,index:ie,node:oe,getHistoryState:de,isDirty:me,uuid:Se,contains:ce,config:F,subscribe:Te};return f===!0&&(Ye.getCurrentNode=i,Ye.refFrom=we,Ye.refTo=Pe,Ye.size=Oe,Ye.length=ge,Ye.pending=he,Ye.print=_e),Ye}Object.defineProperty(n,"__esModule",{value:!0}),n.getCache=u;var a=r(2),c=r(4),s=(i(c),r(3)),l=t(s),d=r(5),v=t(d),p=r(6),O={}},function(e,n,r){"use strict";function t(e){if(e&&e.__esModule)return e;var n={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n["default"]=e,n}function i(e){return"number"==typeof e||"[object Number]"===toString(e)}function o(e){return"string"==typeof e||"[object String]"===toString(e)}function u(e){if(!e)return!0;if(l(e)&&0===e.length)return!0;if(!o(e)){for(var n in e)if(h.call(e,n))return!1;return!0}return!1}function f(e,n){var r=arguments.length<=2||void 0===arguments[2]?!0:arguments[2];if(!e||!s(e)&&!l(e))return e;if(r===!0&&n&&!Object.isFrozen(n)&&Object.freeze(n),n&&c(e)&&e[g.prop.uidName]===n[g.prop.uidName])return n;var t=Object.assign({},e);for(var i in t)if(t.hasOwnProperty(i)){var o=t[i];if(o)if(l(o))t[i]=a(o,n,r);else if(v(o)){var u=new Date(o.getTime());r===!0&&Object.freeze(u),t[i]=u}else s(o)&&(c(o)?(t[i]=o,n&&c(n)&&o!==n&&o.uid===n.uid&&o!==n&&(t[i]=n)):t[i]=f(o,n,r))}return r!==!0||Object.isFrozen(t)||Object.freeze(t),t}function a(e,n,r){return e.map(function(e){return l(e)?a(e,n,r):s(e)?c(e)?n&&e[g.prop.uidName]===n[g.prop.uidName]?n:e:f(e,n,r):e})}function c(e){if(!e)return!1;if(!s(e))return!1;if("undefined"==typeof e[g.prop.uidName])return!1;var n=e[g.prop.uidName];return 0!==n.length}function s(e){return"[object Array]"===Object.prototype.toString.call(e)?!1:null!==e&&"object"===("undefined"==typeof e?"undefined":p(e))}function l(e){return e&&null!==e?Array.isArray(e)||e&&"object"===("undefined"==typeof e?"undefined":p(e))&&"number"==typeof e.length&&"function"==typeof e.splice&&!e.propertyIsEnumerable("length"):!1}function d(e){return Object.prototype.toString.call(e)}function v(e){return s(e)&&"[object Date]"===d(e)}Object.defineProperty(n,"__esModule",{value:!0});var p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e};n.isNumber=i,n.isString=o,n.isEmpty=u,n.deepClone=f,n.hasUid=c,n.isObject=s,n.isArray=l,n.isDate=v;var O=r(3),g=t(O),h=Object.prototype.hasOwnProperty},function(e,n){"use strict";function r(e){for(var n in t)t.hasOwnProperty(n)&&e.hasOwnProperty(n)&&(t[n]=e[n])}Object.defineProperty(n,"__esModule",{value:!0}),n.config=r;var t=n.prop={uidName:"uid",maxHistoryStates:1e3}},function(e,n){"use strict";function r(e){return e?(Object.freeze(e),Object.getOwnPropertyNames(e).forEach(function(n){!e.hasOwnProperty(n)||null===e[n]||"object"!==t(e[n])&&"function"!=typeof e[n]||Object.isFrozen(e[n])||r(e[n])}),e):void 0}Object.defineProperty(n,"__esModule",{value:!0});var t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e};n["default"]=r},function(e,n,r){"use strict";function t(e){var n=parseInt(e);return n.toString()===e?n:e}function i(e,n){if((0,u.isNumber)(n)&&(n=[n]),!(0,u.isEmpty)(e)){if((0,u.isEmpty)(n))return e;if((0,u.isString)(n))return i(e,n.split("."));var r=t(n[0]),o=e[r];if(1===n.length)void 0!==o&&((0,u.isArray)(e)?e.splice(r,1):delete e[r]);else if(void 0!==e[r])return i(e[r],n.slice(1));return e}}function o(e,n,r){if((0,u.isNumber)(n)&&(n=[n]),(0,u.isEmpty)(n))return e;if((0,u.isEmpty)(e))return r;if((0,u.isString)(n))return o(e,n.split("."),r);var i=t(n[0]);return 1===n.length?void 0===e[i]?r:e[i]:o(e[i],n.slice(1),r)}Object.defineProperty(n,"__esModule",{value:!0}),n.del=i,n.get=o;var u=r(2)},function(e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});n.ENTITY="entity",n.REF_FROM="ref_from",n.REF_TO="ref_to",n.UPDATED_KEY="mapUpdatedKey"}]);
"use strict";
Object.defineProperty(exports, '__esModule', {
Object.defineProperty(exports, "__esModule", {
value: true
});
exports['default'] = createCache;
exports.getCache = getCache;
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
var _clone = require('./utils/clone');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var _deepFreeze = require('./utils/deepFreeze');
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; return arr2; } else { return Array.from(arr); } }
var _deepFreeze2 = _interopRequireDefault(_deepFreeze);
var _utilsClone = require('./utils/clone');
var _config = require('./utils/config');
var _utilsDeepFreeze = require('./utils/deepFreeze');
var config = _interopRequireWildcard(_config);
var _utilsDeepFreeze2 = _interopRequireDefault(_utilsDeepFreeze);
var _path = require('./utils/path');
var _utilsConfig = require('./utils/config');
var opath = _interopRequireWildcard(_path);
var config = _interopRequireWildcard(_utilsConfig);
var _constants = require('./utils/constants');
var _utilsPath = require('./utils/path');
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
var opath = _interopRequireWildcard(_utilsPath);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _utilsConstants = require('./utils/constants');
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }

@@ -57,24 +57,7 @@ // One's intent is to always return the same entity regardless of how many different references are to it from

// PERFORMANCE CONSIDERATIONS:
// There are 3 possible bottlenecks depending on the update strategy used (read optimized or write optimized).
// 1. PUT the entity first. This cost is incurred regardless of read or write optimization. In order to keep a
// map of all uid entities on the cache each entity added to the cache must be scanned for contained uid references.
// This is potentially expensive particularly when there is need for a fast UI update immediately after a cache write.
// OPTIMIZATION: use a 2 tiered write operation, queue - adds all entities from a list to a temporary map without
// a deep scanning of each entity. This permits a fast update of the UI but requires a subsequent manual commit()
// call in order to perform the deep put scan after the UI updates have been processed. You should manage the commit
// operations to execute at a time when you know there is no UI processing visible to the user such as to keep a smooth
// flow appearance.
// 2. WRITE OPTIMIZATION. Every time that a uid entity is updated all of its references must be updated. In order to
// optimize the write operation the methodology would be to only optimize the direct map reference at the uid key of
// the entity - single operation O(1). However each read would then have to scan each entity for its updated reference
// and replace it into the entity at the correct location. Fast writes, slow reads O(n). Since there are a lot more
// reads than writes in any application this is not the way it's implemented.
// 3. READ OPTIMIZATION. Have each entity updated on write and ready on every read. Still O(n) but each entity is
// READ OPTIMIZATION. Each entity is updated on write and ready on every read. Still O(n) but each entity is
// retrieved by key from its location on the map and with proper pagination this if very manageable. However this
// requires that all referencing parents are updated on write for each entity write. This is potentially slow but by
// updating a single entity at a time the cost is much lower than Write optimization. This is how One works.
// updating a single entity at a time the cost is much lower than Write optimization.
// Further OPTIMIZATION - when putting a list DO NOT update uid entities already existing in the cache. Instead replace

@@ -96,2 +79,4 @@ // the entity in the list with the existing cache entity thus avoiding a potentially expensive update pointers

var instances = {};
/**

@@ -103,15 +88,18 @@ *

*/
function createCache() {
function getCache() {
var debug = arguments.length <= 0 || arguments[0] === undefined ? true : arguments[0];
var libName = arguments.length <= 1 || arguments[1] === undefined ? "One" : arguments[1];
var instanceName = arguments.length <= 1 || arguments[1] === undefined ? "One" : arguments[1];
if (!instanceName) {
instanceName = "one";
}
if (!instances[instanceName]) {
instances[instanceName] = createCache(debug);
}
if (window) {
if (window[libName] === undefined) {
window[libName] = getCache(debug);
if (window[instanceName] === undefined) {
window[instanceName] = instances[instanceName];
}
return window[libName];
}
/* istanbul ignore next */
return getCache(debug);
return instances[instanceName];
}

@@ -127,10 +115,10 @@

*/
function getCache() {
"use strict";
function createCache() {
var debugParam = arguments.length <= 0 || arguments[0] === undefined ? false : arguments[0];
/**
* Contains all the information required to sequentially keep track of cache nodes.
*/
var debugParam = arguments.length <= 0 || arguments[0] === undefined ? false : arguments[0];
var mainThread = undefined;
var mainThread = void 0;

@@ -248,7 +236,7 @@ /**

// only mergeThread entities with uid
if ((0, _utilsClone.isArray)(entityOrArray) || (0, _utilsClone.isObject)(entityOrArray)) {
if ((0, _clone.isArray)(entityOrArray) || (0, _clone.isObject)(entityOrArray)) {
var flushMap = new Map();
// map of potential evicts in case of de-referencing
var evictMap = new Map();
flushMap.set(_utilsConstants.UPDATED_KEY, false); // track whether the map has changed updated
flushMap.set(_constants.UPDATED_KEY, false); // track whether the map has changed updated
buildFlushMap(entityOrArray, flushMap, null, evictMap, strong);

@@ -258,4 +246,4 @@ updatePointers(flushMap);

// track if data actually changed
var changed = flushMap.get(_utilsConstants.UPDATED_KEY);
flushMap['delete'](_utilsConstants.UPDATED_KEY);
var changed = flushMap.get(_constants.UPDATED_KEY);
flushMap.delete(_constants.UPDATED_KEY);

@@ -291,7 +279,7 @@ var success = false;

var modified = [];
if ((0, _utilsClone.isArray)(entityOrArray)) {
if ((0, _clone.isArray)(entityOrArray)) {
entityOrArray.forEach(function (entity) {
addToQueue(entity, modified);
});
} else if ((0, _utilsClone.isObject)(entityOrArray)) {
} else if ((0, _clone.isObject)(entityOrArray)) {
addToQueue(entityOrArray, modified);

@@ -301,3 +289,3 @@ }

function addToQueue(entity, modified) {
if ((0, _utilsClone.hasUid)(entity)) {
if ((0, _clone.hasUid)(entity)) {
var uid = entity[config.prop.uidName];

@@ -378,3 +366,3 @@ var existing = putQueue[uid];

var queueEvict = function queueEvict(uidEntity) {
if (!uidEntity || !(0, _utilsClone.hasUid)(uidEntity)) {
if (!uidEntity || !(0, _clone.hasUid)(uidEntity)) {
return false;

@@ -411,3 +399,3 @@ }

}
if ((0, _utilsClone.isArray)(uidOrEntityOrArray)) {
if ((0, _clone.isArray)(uidOrEntityOrArray)) {
return uidOrEntityOrArray.map(function (item) {

@@ -430,2 +418,3 @@ return getObject(item);

var uidArray = buildEvictUidArray(obj);
if (uidArray.length == 0) {

@@ -454,2 +443,4 @@ return false;

var parentsChanged = [];
uidArray.forEach(function (uid) {

@@ -461,5 +452,7 @@ // remove REF_FROM in item references metadata

// remove REF_TO in parent metadata
clearParentRefTos(uid, flushMap);
clearParentRefTos(uid, flushMap, uidArray, parentsChanged);
});
putParentsChanged(parentsChanged, flushMap);
// updates

@@ -472,3 +465,3 @@ flushMap.forEach(function (item, key) {

evictMap.forEach(function (item, key) {
tempState['delete'](key);
tempState.delete(key);
});

@@ -478,5 +471,13 @@

notify();
return true;
};
var putParentsChanged = function putParentsChanged(parentsChanged, flushMap) {
if (parentsChanged && parentsChanged.length > 0 && size() > 0) {
buildFlushMap(parentsChanged, flushMap, null, null, false);
updatePointers(flushMap);
}
};
/**

@@ -489,6 +490,6 @@ *

var uidArray = [];
if ((0, _utilsClone.isArray)(obj)) {
if ((0, _clone.isArray)(obj)) {
// array - check if we have uids or strings
obj.forEach(function (item) {
if ((0, _utilsClone.hasUid)(item)) {
if ((0, _clone.hasUid)(item)) {
uidArray.push(String(item[config.prop.uidName]));

@@ -503,11 +504,11 @@ } else {

} else {
var uid = obj;
if ((0, _utilsClone.isObject)(obj)) {
uid = obj[config.prop.uidName];
}
if (uid === undefined) {
return uidArray;
}
uidArray.push(String(uid));
var uid = obj;
if ((0, _clone.isObject)(obj)) {
uid = obj[config.prop.uidName];
}
if (uid === undefined) {
return uidArray;
}
uidArray.push(String(uid));
}
return uidArray;

@@ -524,6 +525,6 @@ };

flushMap.forEach(function (item, key) {
if (key !== _utilsConstants.UPDATED_KEY) {
if (key !== _constants.UPDATED_KEY) {
// do not modify flush map on its own iteration but ok to pass along for reference
var refsFrom = item[_utilsConstants.REF_FROM];
var refsFrom = item[_constants.REF_FROM];

@@ -545,8 +546,8 @@ // parentUid = uid of the item being targeted for ref update (ie the ref's parent)

var firstPath = paths[0];
var targetRef = opath.get(parentItem[_utilsConstants.ENTITY], firstPath);
var targetRef = opath.get(parentItem[_constants.ENTITY], firstPath);
// check for dirty
var dirty = targetRef && targetRef !== item[_utilsConstants.ENTITY];
var dirty = targetRef && targetRef !== item[_constants.ENTITY];
if (dirty === true) {
parentItem = ensureItem(parentItem[_utilsConstants.ENTITY], flushMap);
parentItem = ensureItem(parentItem[_constants.ENTITY], flushMap);

@@ -557,3 +558,3 @@ // TODO figure out a way to not clone the entity every time particularly if it is

// the entity is still frozen here - clone it to update and freeze it deeply
parentItem[_utilsConstants.ENTITY] = (0, _utilsClone.deepClone)(parentItem[_utilsConstants.ENTITY], item[_utilsConstants.ENTITY], true);
parentItem[_constants.ENTITY] = (0, _clone.deepClone)(parentItem[_constants.ENTITY], item[_constants.ENTITY], true);
}

@@ -578,6 +579,6 @@ }

var buildFlushMap = function buildFlushMap(entity, flushMap, parentUid, evictMap, strong) {
if ((0, _utilsClone.hasUid)(entity)) {
if ((0, _clone.hasUid)(entity)) {
buildFlushMap_uid(entity, flushMap, parentUid, evictMap, strong);
} else {
if ((0, _utilsClone.isArray)(entity)) {
if ((0, _clone.isArray)(entity)) {
cacheArrRefs(entity, flushMap, parentUid, evictMap, "", strong);

@@ -643,3 +644,3 @@ } else {

if (item) {
var _refTo = item[_utilsConstants.REF_TO];
var _refTo = item[_constants.REF_TO];
for (var refToUid in _refTo) {

@@ -650,3 +651,3 @@ if (_refTo.hasOwnProperty(refToUid)) {

clearRefFrom(refItem, entityUid);
if (refItem[_utilsConstants.REF_FROM].length === 0) {
if (refItem[_constants.REF_FROM].length === 0) {
clearTargetRefFroms(refToUid, flushMap, evictMap);

@@ -669,7 +670,7 @@ evictMap.set(refToUid, refItem);

*/
var clearParentRefTos = function clearParentRefTos(entityUid, flushMap) {
var clearParentRefTos = function clearParentRefTos(entityUid, flushMap, uidArray, parentsChanged) {
var item = getItemFlushOrAlive(entityUid, flushMap);
if (item) {
var _refFrom = item[_utilsConstants.REF_FROM];
var _refFrom = item[_constants.REF_FROM];
for (var parentUid in _refFrom) {

@@ -682,2 +683,5 @@ if (_refFrom.hasOwnProperty(parentUid)) {

flushMap.set(parentUid, parentItem);
if (uidArray.indexOf(parentUid) < 0) {
parentsChanged.push(parentItem);
}
}

@@ -715,3 +719,3 @@ }

if (item) {
var _refTo2 = item[_utilsConstants.REF_TO];
var _refTo2 = item[_constants.REF_TO];
// check the references for each referenced item. References are keyed by refToUid in the refTo object.

@@ -721,3 +725,3 @@ // Each refToUid value is an array containing a list of paths where the reference is located inside this

var _loop = function (refToUid) {
var _loop = function _loop(refToUid) {
if (_refTo2.hasOwnProperty(refToUid)) {

@@ -728,3 +732,3 @@ // get the list of paths

var updatedPaths = paths.map(function (path) {
var reference = opath.get(item[_utilsConstants.ENTITY], path);
var reference = opath.get(item[_constants.ENTITY], path);
if (reference) {

@@ -747,6 +751,6 @@ var targetUid = reference[config.prop.uidName];

if (updatedPaths.length > 0) {
item[_utilsConstants.REF_TO][refToUid] = updatedPaths;
item[_constants.REF_TO][refToUid] = updatedPaths;
} else {
item[_utilsConstants.REF_TO][refToUid] = undefined;
delete item[_utilsConstants.REF_TO][refToUid];
item[_constants.REF_TO][refToUid] = undefined;
delete item[_constants.REF_TO][refToUid];
}

@@ -764,5 +768,5 @@ }

Object.freeze(item);
Object.freeze(item[_utilsConstants.ENTITY]);
Object.freeze(item[_utilsConstants.REF_TO]);
Object.freeze(item[_utilsConstants.REF_FROM]);
Object.freeze(item[_constants.ENTITY]);
Object.freeze(item[_constants.REF_TO]);
Object.freeze(item[_constants.REF_FROM]);
};

@@ -786,15 +790,15 @@

refItem = Object.assign({}, refItem);
cloneRef(refItem, _utilsConstants.REF_FROM);
cloneRef(refItem, _constants.REF_FROM);
// remove the path from the refFrom
if (refItem[_utilsConstants.REF_FROM].hasOwnProperty(parentUid)) {
if (refItem[_constants.REF_FROM].hasOwnProperty(parentUid)) {
// get the array of refs
removeRefFrom(refItem, parentUid, path);
if (refItem[_utilsConstants.REF_FROM].length === 0) {
if (refItem[_constants.REF_FROM].length === 0) {
evictMap.set(refUid, refItem);
// just in case
flushMap['delete'](refUid);
flushMap.delete(refUid);
} else {
flushMap.set(refUid, refItem);
// just in case
evictMap['delete'](refUid);
evictMap.delete(refUid);
}

@@ -826,6 +830,6 @@ }

var addRefTo = function addRefTo(parentItem, refUid, path) {
var refTo = parentItem[_utilsConstants.REF_TO];
if (!parentItem[_utilsConstants.REF_TO][refUid]) {
parentItem[_utilsConstants.REF_TO][refUid] = [];
parentItem[_utilsConstants.REF_TO].length += 1;
var refTo = parentItem[_constants.REF_TO];
if (!parentItem[_constants.REF_TO][refUid]) {
parentItem[_constants.REF_TO][refUid] = [];
parentItem[_constants.REF_TO].length += 1;
}

@@ -847,6 +851,6 @@ var refArray = refTo[refUid];

var addRefFrom = function addRefFrom(refItem, parentUid, path) {
var refFrom = refItem[_utilsConstants.REF_FROM];
if (!refItem[_utilsConstants.REF_FROM][parentUid]) {
refItem[_utilsConstants.REF_FROM][parentUid] = [];
refItem[_utilsConstants.REF_FROM].length += 1;
var refFrom = refItem[_constants.REF_FROM];
if (!refItem[_constants.REF_FROM][parentUid]) {
refItem[_constants.REF_FROM][parentUid] = [];
refItem[_constants.REF_FROM].length += 1;
}

@@ -861,3 +865,3 @@ var fromArray = refFrom[parentUid];

var removeRefFrom = function removeRefFrom(item, parentUid, path) {
var refsArray = item[_utilsConstants.REF_FROM][parentUid];
var refsArray = item[_constants.REF_FROM][parentUid];

@@ -869,7 +873,7 @@ var index = refsArray.indexOf(path);

refsArray.splice(index, 1);
item[_utilsConstants.REF_FROM][parentUid] = refsArray;
item[_constants.REF_FROM][parentUid] = refsArray;
if (refsArray.length == 0) {
item[_utilsConstants.REF_FROM][parentUid] = undefined;
delete item[_utilsConstants.REF_FROM][parentUid];
item[_utilsConstants.REF_FROM].length -= 1;
item[_constants.REF_FROM][parentUid] = undefined;
delete item[_constants.REF_FROM][parentUid];
item[_constants.REF_FROM].length -= 1;
}

@@ -885,11 +889,11 @@ };

var clearRefFrom = function clearRefFrom(refItem, parentUid) {
var refsArray = refItem[_utilsConstants.REF_FROM][parentUid];
var refsArray = refItem[_constants.REF_FROM][parentUid];
if (!refsArray) {
return;
}
cloneRef(refItem, _utilsConstants.REF_FROM);
refItem[_utilsConstants.REF_FROM][parentUid] = undefined;
delete refItem[_utilsConstants.REF_FROM][parentUid]; // where it works
if (refItem[_utilsConstants.REF_FROM].length > 0) {
refItem[_utilsConstants.REF_FROM].length -= 1;
cloneRef(refItem, _constants.REF_FROM);
refItem[_constants.REF_FROM][parentUid] = undefined;
delete refItem[_constants.REF_FROM][parentUid]; // where it works
if (refItem[_constants.REF_FROM].length > 0) {
refItem[_constants.REF_FROM].length -= 1;
}

@@ -906,8 +910,8 @@ };

// first remove all instances of entity from the parent
var parent = parentItem[_utilsConstants.ENTITY];
var parent = parentItem[_constants.ENTITY];
if (Object.isFrozen(parent)) {
parent = getEdit(parent[config.prop.uidName]);
parentItem[_utilsConstants.ENTITY] = parent;
parentItem[_constants.ENTITY] = parent;
}
var refPaths = parentItem[_utilsConstants.REF_TO][refUid];
var refPaths = parentItem[_constants.REF_TO][refUid];
refPaths.forEach(function (path) {

@@ -919,11 +923,11 @@ opath.del(parent, path);

}
parentItem[_utilsConstants.ENTITY] = parent;
parentItem[_constants.ENTITY] = parent;
// then clear the metadata
cloneRef(parentItem, _utilsConstants.REF_TO);
parentItem[_utilsConstants.REF_TO][refUid] = undefined;
delete parentItem[_utilsConstants.REF_TO][refUid]; // where it works
cloneRef(parentItem, _constants.REF_TO);
parentItem[_constants.REF_TO][refUid] = undefined;
delete parentItem[_constants.REF_TO][refUid]; // where it works
if (parentItem[_utilsConstants.REF_TO].length > 0) {
parentItem[_utilsConstants.REF_TO].length -= 1;
if (parentItem[_constants.REF_TO].length > 0) {
parentItem[_constants.REF_TO].length -= 1;
}

@@ -958,4 +962,5 @@ return true;

*/
var cacheEntityRefs = function cacheEntityRefs(parentEntity, flushMap, parentUid, evictMap, refPath, strong) {
if (refPath === undefined) refPath = "";
var cacheEntityRefs = function cacheEntityRefs(parentEntity, flushMap, parentUid, evictMap) {
var refPath = arguments.length <= 4 || arguments[4] === undefined ? "" : arguments[4];
var strong = arguments[5];

@@ -967,5 +972,5 @@ for (var prop in parentEntity) {

if ((0, _utilsClone.isArray)(refEntity)) {
if ((0, _clone.isArray)(refEntity)) {
cacheArrRefs(refEntity, flushMap, parentUid, evictMap, refPath, strong);
} else if ((0, _utilsClone.isObject)(refEntity)) {
} else if ((0, _clone.isObject)(refEntity)) {
// abort on weak puts if item exists

@@ -995,3 +1000,3 @@ if (strong === false && getLiveItem(refEntity[config.prop.uidName])) {

var existingItem = getLiveItem(uid);
return existingItem && existingItem[_utilsConstants.ENTITY] === entity;
return existingItem && existingItem[_constants.ENTITY] === entity;
};

@@ -1008,6 +1013,7 @@

*/
var cacheObjRefs = function cacheObjRefs(refEntity, flushMap, parentUid, evictMap, refPath, strong) {
if (refPath === undefined) refPath = "";
var cacheObjRefs = function cacheObjRefs(refEntity, flushMap, parentUid, evictMap) {
var refPath = arguments.length <= 4 || arguments[4] === undefined ? "" : arguments[4];
var strong = arguments[5];
if ((0, _utilsClone.hasUid)(refEntity)) {
if ((0, _clone.hasUid)(refEntity)) {
// abort if weak and existing

@@ -1028,3 +1034,3 @@ if (strong === false && getLiveItem(refEntity[config.prop.uidName])) {

}
refItem[_utilsConstants.ENTITY] = refEntity;
refItem[_constants.ENTITY] = refEntity;
parentUid = String(refEntity[config.prop.uidName]);

@@ -1056,11 +1062,12 @@ buildFlushMap(refEntity, flushMap, parentUid, evictMap, refPath, strong);

*/
var cacheArrRefs = function cacheArrRefs(entity, flushMap, parentUid, evictMap, refPath, strong) {
if (refPath === undefined) refPath = "";
var cacheArrRefs = function cacheArrRefs(entity, flushMap, parentUid, evictMap) {
var refPath = arguments.length <= 4 || arguments[4] === undefined ? "" : arguments[4];
var strong = arguments[5];
var path = undefined;
var path = void 0;
entity.forEach(function (item, index) {
path = refPath + "." + index;
if ((0, _utilsClone.isArray)(item)) {
if ((0, _clone.isArray)(item)) {
cacheArrRefs(item, flushMap, parentUid, evictMap, path, strong);
} else if ((0, _utilsClone.isObject)(item)) {
} else if ((0, _clone.isObject)(item)) {
cacheObjRefs(item, flushMap, parentUid, evictMap, path, strong);

@@ -1085,4 +1092,4 @@ }

var assignRefs = function assignRefs(parentItem, refItem, refPath) {
var parentUid = parentItem[_utilsConstants.ENTITY][config.prop.uidName];
var refUid = refItem[_utilsConstants.ENTITY][config.prop.uidName];
var parentUid = parentItem[_constants.ENTITY][config.prop.uidName];
var refUid = refItem[_constants.ENTITY][config.prop.uidName];

@@ -1135,3 +1142,3 @@ // add parent reference to child

// track the uid of the item being changed and referencing the items.
var itemUid = item[_utilsConstants.ENTITY][config.prop.uidName];
var itemUid = item[_constants.ENTITY][config.prop.uidName];
freezeItem(item);

@@ -1143,3 +1150,3 @@ temp.set(String(itemUid), item);

evictMap.forEach(function (value, key) {
temp['delete'](String(key));
temp.delete(String(key));
});

@@ -1173,3 +1180,3 @@ }

}
return item[_utilsConstants.ENTITY];
return item[_constants.ENTITY];
};

@@ -1187,4 +1194,4 @@

return String(uidOrEntity);
} else if ((0, _utilsClone.isObject)(uidOrEntity)) {
if ((0, _utilsClone.hasUid)(uidOrEntity)) {
} else if ((0, _clone.isObject)(uidOrEntity)) {
if ((0, _clone.hasUid)(uidOrEntity)) {
return uidOrEntity[config.prop.uidName];

@@ -1200,3 +1207,3 @@ }

var getEdit = function getEdit(uidOrEntityOrArray) {
if ((0, _utilsClone.isArray)(uidOrEntityOrArray)) {
if ((0, _clone.isArray)(uidOrEntityOrArray)) {
return uidOrEntityOrArray.map(function (item) {

@@ -1221,3 +1228,3 @@ return getEditableObject(item);

// just in case
if ((0, _utilsClone.isNumber)(idx) === true) {
if ((0, _clone.isNumber)(idx) === true) {
if (mainThread.current !== idx) {

@@ -1254,3 +1261,3 @@ if (idx >= 0 && idx < length()) {

if (!(0, _utilsClone.isNumber)(nodeId)) {
if (!(0, _clone.isNumber)(nodeId)) {
throw new TypeError("The node id must be a number.");

@@ -1316,3 +1323,3 @@ }

}
return (0, _utilsClone.deepClone)(existing, undefined, false);
return (0, _clone.deepClone)(existing, undefined, false);
};

@@ -1337,20 +1344,20 @@

var live = getLiveItem(itemUid);
item[_utilsConstants.ENTITY] = entity;
item[_constants.ENTITY] = entity;
if (live !== undefined) {
item = Object.assign(item, live);
// must reset the entity here so it displays at the top but is not the old one
item[_utilsConstants.ENTITY] = entity;
item[_constants.ENTITY] = entity;
// each path is an array of strings so they get duplicated automatically
item[_utilsConstants.REF_FROM] = Object.assign(getNewLengthObj(), live[_utilsConstants.REF_FROM]);
item[_utilsConstants.REF_FROM].length = live[_utilsConstants.REF_FROM].length;
item[_constants.REF_FROM] = Object.assign(getNewLengthObj(), live[_constants.REF_FROM]);
item[_constants.REF_FROM].length = live[_constants.REF_FROM].length;
item[_utilsConstants.REF_TO] = Object.assign(getNewLengthObj(), live[_utilsConstants.REF_TO]);
item[_utilsConstants.REF_TO].length = live[_utilsConstants.REF_TO].length;
item[_constants.REF_TO] = Object.assign(getNewLengthObj(), live[_constants.REF_TO]);
item[_constants.REF_TO].length = live[_constants.REF_TO].length;
} else {
item[_utilsConstants.REF_FROM] = getNewLengthObj();
item[_utilsConstants.REF_TO] = getNewLengthObj();
item[_constants.REF_FROM] = getNewLengthObj();
item[_constants.REF_TO] = getNewLengthObj();
}
flushMap.set(itemUid, item);
flushMap.set(_utilsConstants.UPDATED_KEY, true);
flushMap.set(_constants.UPDATED_KEY, true);
removeFromQueue(itemUid);

@@ -1362,4 +1369,4 @@ return item;

var newItem = Object.assign({}, item);
cloneRef(newItem, _utilsConstants.REF_FROM);
cloneRef(newItem, _utilsConstants.REF_TO);
cloneRef(newItem, _constants.REF_FROM);
cloneRef(newItem, _constants.REF_TO);
return newItem;

@@ -1373,3 +1380,3 @@ };

var contains = function contains(obj) {
if (!(0, _utilsClone.hasUid)(obj)) {
if (!(0, _clone.hasUid)(obj)) {
// items are stored by uid

@@ -1489,3 +1496,3 @@ return false;

if (cacheNode) {
repo['delete'](cacheNodeId);
repo.delete(cacheNodeId);
}

@@ -1572,3 +1579,3 @@ });

arr.map(function (item) {
var itemResult = undefined;
var itemResult = void 0;
// this try catch is for cyclical data testing

@@ -1582,7 +1589,7 @@ // try {

if (itemResult.indexOf(_utilsConstants.REF_FROM) >= 0 && item[_utilsConstants.REF_FROM]) {
itemResult = itemResult.replace('"' + _utilsConstants.REF_FROM + '": {}', '"' + _utilsConstants.REF_FROM + '"' + ": " + JSON.stringify([].concat(_toConsumableArray(item[_utilsConstants.REF_FROM]))));
if (itemResult.indexOf(_constants.REF_FROM) >= 0 && item[_constants.REF_FROM]) {
itemResult = itemResult.replace('"' + _constants.REF_FROM + '": {}', '"' + _constants.REF_FROM + '"' + ": " + JSON.stringify([].concat(_toConsumableArray(item[_constants.REF_FROM]))));
}
if (itemResult.indexOf(_utilsConstants.REF_TO) >= 0 && item[_utilsConstants.REF_TO]) {
itemResult = itemResult.replace('"' + _utilsConstants.REF_TO + '": {}', '"' + _utilsConstants.REF_TO + '"' + ": " + JSON.stringify(item[_utilsConstants.REF_TO]));
if (itemResult.indexOf(_constants.REF_TO) >= 0 && item[_constants.REF_TO]) {
itemResult = itemResult.replace('"' + _constants.REF_TO + '": {}', '"' + _constants.REF_TO + '"' + ": " + JSON.stringify(item[_constants.REF_TO]));
}

@@ -1605,3 +1612,3 @@ result += itemResult;

var isDirty = function isDirty(uidEntity) {
if (!(0, _utilsClone.hasUid)(uidEntity)) {
if (!(0, _clone.hasUid)(uidEntity)) {
return true;

@@ -1658,3 +1665,3 @@ }

var item = getLiveItem(uid);
return item[_utilsConstants.REF_FROM];
return item[_constants.REF_FROM];
};

@@ -1664,3 +1671,3 @@

var item = getLiveItem(uid);
return item[_utilsConstants.REF_TO];
return item[_constants.REF_TO];
};

@@ -1713,3 +1720,2 @@

return base;
}
module.exports = exports['default'];
}
'use strict';
Object.defineProperty(exports, '__esModule', {
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getCache = undefined;
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var _cache = require('./cache');
var _cache2 = _interopRequireDefault(_cache);
(function () {
(0, _cache2['default'])();
})();
exports.createCache = _cache2['default'];
(0, _cache.getCache)();
})(); //import 'babel-polyfill';
exports.getCache = _cache.getCache;

@@ -1,9 +0,12 @@

/**
* Created by maierdesign on 1/19/16.
*/
'use strict';
Object.defineProperty(exports, '__esModule', {
Object.defineProperty(exports, "__esModule", {
value: true
});
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; /**
* Created by maierdesign on 1/19/16.
*/
exports.isNumber = isNumber;

@@ -18,4 +21,2 @@ exports.isString = isString;

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
var _config = require('./config');

@@ -25,2 +26,4 @@

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
var _hasOwnProperty = Object.prototype.hasOwnProperty;

@@ -61,3 +64,2 @@

*/
function deepClone(obj, uidReference) {

@@ -105,4 +107,4 @@ var freeze = arguments.length <= 2 || arguments[2] === undefined ? true : arguments[2];

} else {
result[propName] = deepClone(value, uidReference, freeze);
}
result[propName] = deepClone(value, uidReference, freeze);
}
}

@@ -151,6 +153,4 @@ }

return uid.length !== 0;
}
};
;
/**

@@ -161,3 +161,2 @@ * Checks if argument is an object

*/
function isObject(mixed_var) {

@@ -170,3 +169,3 @@ if (Object.prototype.toString.call(mixed_var) === '[object Array]') {

// if such property existed and was null on the incoming object
return mixed_var !== null && typeof mixed_var === 'object';
return mixed_var !== null && (typeof mixed_var === 'undefined' ? 'undefined' : _typeof(mixed_var)) === 'object';
}

@@ -177,3 +176,2 @@

*/
function isArray(value) {

@@ -186,3 +184,3 @@

// works across iFrames
return Array.isArray(value) || value && typeof value === 'object' && typeof value.length === 'number' && typeof value.splice === 'function' && !value.propertyIsEnumerable('length');
return Array.isArray(value) || value && (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && typeof value.length === 'number' && typeof value.splice === 'function' && !value.propertyIsEnumerable('length');
}

@@ -204,5 +202,4 @@

*/
function isDate(value) {
return isObject(value) && objToStr(value) === '[object Date]';
}

@@ -6,2 +6,3 @@ "use strict";

*/
Object.defineProperty(exports, "__esModule", {

@@ -11,3 +12,3 @@ value: true

exports.config = config;
var prop = {
var prop = exports.prop = {
uidName: "uid",

@@ -17,7 +18,5 @@ maxHistoryStates: 1000

exports.prop = prop;
/**
* @param conf Json object containing overrides for any of the configurable properties.
*/
function config(conf) {

@@ -24,0 +23,0 @@ for (var p in prop) {

@@ -0,1 +1,6 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
/**

@@ -16,10 +21,4 @@ * Created by maierdesign on 1/19/16.

// when printing the nodes these get replaced with their respective values. use distinct names - ie prefix with cuid_
"use strict";
var ENTITY = exports.ENTITY = "entity";
Object.defineProperty(exports, "__esModule", {
value: true
});
var ENTITY = "entity";
exports.ENTITY = ENTITY;
/**

@@ -29,5 +28,4 @@ * Keyes in the pointers on an item stored in the cache

*/
var REF_FROM = "ref_from";
var REF_FROM = exports.REF_FROM = "ref_from";
exports.REF_FROM = REF_FROM;
/**

@@ -39,5 +37,4 @@ * Keyes in the references inside an item stored in the cache. In order to avoid deeply iterating an object for its uid

*/
var REF_TO = "ref_to";
var REF_TO = exports.REF_TO = "ref_to";
exports.REF_TO = REF_TO;
/**

@@ -47,3 +44,2 @@ * Whether a temp map was updated as a result of a cache operation.

*/
var UPDATED_KEY = "mapUpdatedKey";
exports.UPDATED_KEY = UPDATED_KEY;
var UPDATED_KEY = exports.UPDATED_KEY = "mapUpdatedKey";

@@ -0,1 +1,10 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
exports.default = deepFreeze;
/**

@@ -9,9 +18,2 @@ * Created by maierdesign on 1/19/16.

*/
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = deepFreeze;
function deepFreeze(obj) {

@@ -25,3 +27,3 @@ if (!obj) {

Object.getOwnPropertyNames(obj).forEach(function (prop) {
if (obj.hasOwnProperty(prop) && obj[prop] !== null && (typeof obj[prop] === "object" || typeof obj[prop] === "function") && !Object.isFrozen(obj[prop])) {
if (obj.hasOwnProperty(prop) && obj[prop] !== null && (_typeof(obj[prop]) === "object" || typeof obj[prop] === "function") && !Object.isFrozen(obj[prop])) {
deepFreeze(obj[prop]);

@@ -32,5 +34,2 @@ }

return obj;
}
;
module.exports = exports["default"];
};

@@ -8,3 +8,3 @@ /**

Object.defineProperty(exports, '__esModule', {
Object.defineProperty(exports, "__esModule", {
value: true

@@ -25,95 +25,62 @@ });

function del(_x, _x2) {
var _again = true;
function del(obj, path) {
if ((0, _clone.isNumber)(path)) {
path = [path];
}
_function: while (_again) {
var obj = _x,
path = _x2;
_again = false;
if ((0, _clone.isEmpty)(obj)) {
return void 0;
}
if ((0, _clone.isNumber)(path)) {
path = [path];
}
if ((0, _clone.isEmpty)(path)) {
return obj;
}
if ((0, _clone.isString)(path)) {
return del(obj, path.split('.'));
}
if ((0, _clone.isEmpty)(obj)) {
return void 0;
}
var currentPath = getKey(path[0]);
var oldVal = obj[currentPath];
if ((0, _clone.isEmpty)(path)) {
return obj;
if (path.length === 1) {
if (oldVal !== void 0) {
if ((0, _clone.isArray)(obj)) {
obj.splice(currentPath, 1);
} else {
delete obj[currentPath];
}
}
if ((0, _clone.isString)(path)) {
_x = obj;
_x2 = path.split('.');
_again = true;
continue _function;
} else {
if (obj[currentPath] !== void 0) {
return del(obj[currentPath], path.slice(1));
}
}
var currentPath = getKey(path[0]);
var oldVal = obj[currentPath];
return obj;
}
if (path.length === 1) {
if (oldVal !== void 0) {
if ((0, _clone.isArray)(obj)) {
obj.splice(currentPath, 1);
} else {
delete obj[currentPath];
}
}
} else {
if (obj[currentPath] !== void 0) {
_x = obj[currentPath];
_x2 = path.slice(1);
_again = true;
currentPath = oldVal = undefined;
continue _function;
}
}
function get(obj, path, defaultValue) {
if ((0, _clone.isNumber)(path)) {
path = [path];
}
if ((0, _clone.isEmpty)(path)) {
return obj;
}
}
if ((0, _clone.isEmpty)(obj)) {
return defaultValue;
}
if ((0, _clone.isString)(path)) {
return get(obj, path.split('.'), defaultValue);
}
function get(_x3, _x4, _x5) {
var _again2 = true;
var currentPath = getKey(path[0]);
_function2: while (_again2) {
var obj = _x3,
path = _x4,
defaultValue = _x5;
_again2 = false;
if ((0, _clone.isNumber)(path)) {
path = [path];
}
if ((0, _clone.isEmpty)(path)) {
return obj;
}
if ((0, _clone.isEmpty)(obj)) {
if (path.length === 1) {
if (obj[currentPath] === void 0) {
return defaultValue;
}
if ((0, _clone.isString)(path)) {
_x3 = obj;
_x4 = path.split('.');
_x5 = defaultValue;
_again2 = true;
continue _function2;
}
return obj[currentPath];
}
var currentPath = getKey(path[0]);
if (path.length === 1) {
if (obj[currentPath] === void 0) {
return defaultValue;
}
return obj[currentPath];
}
_x3 = obj[currentPath];
_x4 = path.slice(1);
_x5 = defaultValue;
_again2 = true;
currentPath = undefined;
continue _function2;
}
return get(obj[currentPath], path.slice(1), defaultValue);
}
{
"name": "one",
"version": "5.1.3",
"version": "5.1.4",
"description": "Browser application cache. It guarantees entity uniqueness across the entire cache.",

@@ -35,4 +35,6 @@ "main": "lib/index.js",

"devDependencies": {
"babel-cli": "^6.16.0",
"babel-core": "^6.9.1",
"babel-loader": "^6.2.4",
"babel-loader": "^6.2.5",
"babel-polyfill": "^6.13.0",
"babel-preset-es2015": "^6.9.0",

@@ -45,3 +47,3 @@ "babel-register": "^6.9.0",

"mocha": "^2.3.4",
"mocha-babel": "^3.0.0",
"mocha-babel": "^3 .0.0",
"mocha-lcov-reporter": "^1.2.0",

@@ -53,2 +55,3 @@ "node-jsdom": "^3.1.5",

"strip-loader": "^0.1.1",
"wallaby-webpack": "0.0.22",
"webpack": "^1.12.9",

@@ -55,0 +58,0 @@ "webpack-merge": "^0.3.0"

@@ -1,3 +0,5 @@

# One
![One logo](https://lh3.googleusercontent.com/5CBS5xCZm0BQQ9GaE8SfDnomFNWkr5jU-ZPRi_Cdptj7__GSyRPCeQbQA1OBxt0OZ3LNs-a_eGiyBSCtOM4=s100 "One logo")
# **ONE** #
```One``` is a browser side application cache. It guarantees entity uniqueness across the entire cache.

@@ -17,11 +19,51 @@

```js
import * as cache from 'one';
let One = cache.createCache();
import * as One from 'one';
// get a hold of an instance
let one = One.getCache();
// or with debugging options
let One = cache.createCache(true);
let one = One.getCache(true);
// you can then use the instance
one.put(item);
// One.getCache() is a singleton so you can also do this
One.getCache().put(item);
```
Or simply put ```one.min.js``` on your page to access the ```One``` global variable from anywhere.
Or simply put ```one.min.js``` on your page to access the ```One``` global variable from anywhere. In this case the instance is created for you and you can access it directly (no need to call ```getCache()```).
```
#!javascript
One.put(item)
```
####A word about javascript versions compatibility
ES6 introduced Maps which are supposed to be up to 3 times more efficient than using Object for storing and retrieving keyed items.
```One``` uses Maps by default. However for older browsers that do not support the standard you will need to compile the library with the babel-polyfill. The caveat is that it bumps up the size of the minified lib from ~16kb go ~100kb.
To compile with polyfill:
1. Uncomment this line in index.js
```
#!javascript
//import 'babel-polyfill';
```
2. Run this line in terminal from the One folder:
```
#!javascript
npm run prepub
```
That's it. The compiled versions are added to the dist folder.
###Api

@@ -126,4 +168,2 @@ There are three significant operation types to be aware of:

* [Time travel](https://maierson.gitbooks.io/one/content/time_travel.html)
* [Release Notes](https://maierson.gitbooks.io/one/content/release_notes.html)
* [Release Notes](https://maierson.gitbooks.io/one/content/release_notes.html)

@@ -37,24 +37,7 @@ "use strict";

// PERFORMANCE CONSIDERATIONS:
// There are 3 possible bottlenecks depending on the update strategy used (read optimized or write optimized).
// 1. PUT the entity first. This cost is incurred regardless of read or write optimization. In order to keep a
// map of all uid entities on the cache each entity added to the cache must be scanned for contained uid references.
// This is potentially expensive particularly when there is need for a fast UI update immediately after a cache write.
// OPTIMIZATION: use a 2 tiered write operation, queue - adds all entities from a list to a temporary map without
// a deep scanning of each entity. This permits a fast update of the UI but requires a subsequent manual commit()
// call in order to perform the deep put scan after the UI updates have been processed. You should manage the commit
// operations to execute at a time when you know there is no UI processing visible to the user such as to keep a smooth
// flow appearance.
// 2. WRITE OPTIMIZATION. Every time that a uid entity is updated all of its references must be updated. In order to
// optimize the write operation the methodology would be to only optimize the direct map reference at the uid key of
// the entity - single operation O(1). However each read would then have to scan each entity for its updated reference
// and replace it into the entity at the correct location. Fast writes, slow reads O(n). Since there are a lot more
// reads than writes in any application this is not the way it's implemented.
// 3. READ OPTIMIZATION. Have each entity updated on write and ready on every read. Still O(n) but each entity is
// READ OPTIMIZATION. Each entity is updated on write and ready on every read. Still O(n) but each entity is
// retrieved by key from its location on the map and with proper pagination this if very manageable. However this
// requires that all referencing parents are updated on write for each entity write. This is potentially slow but by
// updating a single entity at a time the cost is much lower than Write optimization. This is how One works.
// updating a single entity at a time the cost is much lower than Write optimization.
// Further OPTIMIZATION - when putting a list DO NOT update uid entities already existing in the cache. Instead replace

@@ -76,2 +59,4 @@ // the entity in the list with the existing cache entity thus avoiding a potentially expensive update pointers

let instances = {};
/**

@@ -83,11 +68,15 @@ *

*/
export default function createCache(debug = true, libName = "One") {
if (window) {
if (window[libName] === undefined) {
window[libName] = getCache(debug);
export function getCache(debug = true, instanceName = "One") {
if(!instanceName){
instanceName = "one";
}
if(!instances[instanceName]){
instances[instanceName] = createCache(debug);
}
if(window){
if(window[instanceName] === undefined){
window[instanceName] = instances[instanceName];
}
return window[libName];
}
/* istanbul ignore next */
return getCache(debug);
return instances[instanceName];
}

@@ -103,4 +92,3 @@

*/
function getCache(debugParam = false) {
"use strict";
function createCache(debugParam = false) {

@@ -393,2 +381,3 @@ /**

let uidArray = buildEvictUidArray(obj);
if (uidArray.length == 0) {

@@ -417,2 +406,4 @@ return false;

let parentsChanged = [];
uidArray.forEach(uid => {

@@ -424,5 +415,7 @@ // remove REF_FROM in item references metadata

// remove REF_TO in parent metadata
clearParentRefTos(uid, flushMap);
clearParentRefTos(uid, flushMap, uidArray, parentsChanged);
});
putParentsChanged(parentsChanged, flushMap);
// updates

@@ -438,7 +431,17 @@ flushMap.forEach((item, key) => {

flush(tempState);
notify();
return true;
};
const putParentsChanged = (parentsChanged, flushMap) => {
if(parentsChanged && parentsChanged.length > 0 && size() > 0){
buildFlushMap(parentsChanged, flushMap, null, null, false);
updatePointers(flushMap);
}
};
/**

@@ -624,3 +627,3 @@ *

*/
const clearParentRefTos = (entityUid, flushMap) => {
const clearParentRefTos = (entityUid, flushMap, uidArray, parentsChanged) => {
let item = getItemFlushOrAlive(entityUid, flushMap);

@@ -637,2 +640,5 @@

flushMap.set(parentUid, parentItem);
if(uidArray.indexOf(parentUid) < 0){
parentsChanged.push(parentItem);
}
}

@@ -639,0 +645,0 @@ }

@@ -1,9 +0,10 @@

import createCache from './cache';
//import 'babel-polyfill';
import {getCache} from './cache';
(function () {
createCache();
getCache();
})();
export {
createCache
getCache
}
var path = require('path');
var webpack = require('webpack');
var merge = require('webpack-merge');
//var merge = require('webpack-merge');
var TARGET = process.env.npm_lifecycle_event;
process.env.BABEL_ENV = TARGET;
//var TARGET = process.env.npm_lifecycle_event;
//process.env.BABEL_ENV = TARGET;

@@ -23,3 +23,3 @@ const ROOT_PATH = path.resolve(__dirname);

root : path.resolve(APP_PATH),
extensions: ['', '.js', '.jsx']
extensions: ['', '.js']
},

@@ -29,4 +29,4 @@ module : {

{
test : /\.jsx?$/,
loaders: ['babel'],
test : /\.js?$/,
loaders: ['babel-loader'],
include: APP_PATH,

@@ -33,0 +33,0 @@ exclude: /node_modules/

var path = require('path');
var webpack = require('webpack');
var merge = require('webpack-merge');
var TARGET = process.env.npm_lifecycle_event;
process.env.BABEL_ENV = TARGET;
//var TARGET = process.env.npm_lifecycle_event;
//process.env.BABEL_ENV = TARGET;

@@ -23,3 +22,3 @@ const ROOT_PATH = path.resolve(__dirname);

root : path.resolve(APP_PATH),
extensions: ['', '.js', '.jsx']
extensions: ['', '.js']
},

@@ -29,4 +28,4 @@ module : {

{
test : /\.jsx?$/,
loaders: ['babel'],
test : /\.js?$/,
loaders: ['babel-loader'],
include: APP_PATH,

@@ -33,0 +32,0 @@ exclude: /node_modules/

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc