|
1 | | -(function(w,y){typeof exports=="object"&&typeof module<"u"?module.exports=y():typeof define=="function"&&define.amd?define(y):(w=typeof globalThis<"u"?globalThis:w||self,w.createGraph=y())})(this,(function(){"use strict";function w(t){A(t);const i=y(t);return t.on=i.on,t.off=i.off,t.fire=i.fire,t}function y(t){let i=Object.create(null);return{on:function(o,f,v){if(typeof f!="function")throw new Error("callback is expected to be a function");let s=i[o];return s||(s=i[o]=[]),s.push({callback:f,ctx:v}),t},off:function(o,f){if(typeof o>"u")return i=Object.create(null),t;if(i[o])if(typeof f!="function")delete i[o];else{const l=i[o];for(let p=0;p<l.length;++p)l[p].callback===f&&l.splice(p,1)}return t},fire:function(o){const f=i[o];if(!f)return t;let v;arguments.length>1&&(v=Array.prototype.slice.call(arguments,1));for(let s=0;s<f.length;++s){const l=f[s];l.callback.apply(l.ctx,v)}return t}}}function A(t){if(!t)throw new Error("Eventify cannot use falsy object as events subject");const i=["on","fire","off"];for(let o=0;o<i.length;++o)if(t.hasOwnProperty(i[o]))throw new Error("Subject cannot be eventified, since it already has property '"+i[o]+"'")}function F(t){if(t=t||{},"uniqueLinkId"in t&&(console.warn("ngraph.graph: Starting from version 0.14 `uniqueLinkId` is deprecated.\nUse `multigraph` option instead\n",` |
| 1 | +(function(w,y){typeof exports=="object"&&typeof module<"u"?module.exports=y():typeof define=="function"&&define.amd?define(y):(w=typeof globalThis<"u"?globalThis:w||self,w.createGraph=y())})(this,(function(){"use strict";function w(t){A(t);const i=y(t);return t.on=i.on,t.off=i.off,t.fire=i.fire,t}function y(t){let i=Object.create(null);return{on:function(o,f,v){if(typeof f!="function")throw new Error("callback is expected to be a function");let c=i[o];return c||(c=i[o]=[]),c.push({callback:f,ctx:v}),t},off:function(o,f){if(typeof o>"u")return i=Object.create(null),t;if(i[o])if(typeof f!="function")delete i[o];else{const s=i[o];for(let p=0;p<s.length;++p)s[p].callback===f&&s.splice(p,1)}return t},fire:function(o){const f=i[o];if(!f)return t;let v;arguments.length>1&&(v=Array.prototype.slice.call(arguments,1));for(let c=0;c<f.length;++c){const s=f[c];s.callback.apply(s.ctx,v)}return t}}}function A(t){if(!t)throw new Error("Eventify cannot use falsy object as events subject");const i=["on","fire","off"];for(let o=0;o<i.length;++o)if(t.hasOwnProperty(i[o]))throw new Error("Subject cannot be eventified, since it already has property '"+i[o]+"'")}function F(t){if(t=t||{},"uniqueLinkId"in t&&(console.warn("ngraph.graph: Starting from version 0.14 `uniqueLinkId` is deprecated.\nUse `multigraph` option instead\n",` |
2 | 2 | `,`Note: there is also change in default behavior: From now on each graph |
3 | | -is considered to be not a multigraph by default (each edge is unique).`),t.multigraph=t.uniqueLinkId),t.multigraph===void 0&&(t.multigraph=!1),typeof Map!="function")throw new Error("ngraph.graph requires `Map` to be defined. Please polyfill it before using ngraph");var i=new Map,o=new Map,f={},v=0,s=t.multigraph?Y:W,l=[],p=x,m=x,k=x,L=x,g={version:20,addNode:C,addLink:V,removeLink:D,removeNode:q,getNode:c,getNodeCount:O,getLinkCount:b,getEdgeCount:b,getLinksCount:b,getNodesCount:O,getLinks:B,forEachNode:U,forEachLinkedNode:K,forEachLink:J,beginUpdate:k,endUpdate:L,clear:H,hasLink:N,hasNode:c,getLink:N};return w(g),P(),g;function P(){var e=g.on;g.on=n;function n(){return g.beginUpdate=k=Z,g.endUpdate=L=_,p=z,m=G,g.on=e,e.apply(g,arguments)}}function z(e,n){l.push({link:e,changeType:n})}function G(e,n){l.push({node:e,changeType:n})}function C(e,n){if(e===void 0)throw new Error("Invalid node identifier");k();var r=c(e);return r?(r.data=n,m(r,"update")):(r=new R(e,n),m(r,"add")),i.set(e,r),L(),r}function c(e){return i.get(e)}function q(e){var n=c(e);if(!n)return!1;k();var r=n.links;return r&&(r.forEach(T),n.links=null),i.delete(e),m(n,"remove"),L(),!0}function V(e,n,r){k();var a=c(e)||C(e),d=c(n)||C(n),u=s(e,n,r),h=o.has(u.id);return o.set(u.id,u),S(a,u),e!==n&&S(d,u),p(u,h?"update":"add"),L(),u}function W(e,n,r){var a=E(e,n),d=o.get(a);return d?(d.data=r,d):new M(e,n,r,a)}function Y(e,n,r){var a=E(e,n),d=f.hasOwnProperty(a);if(d||N(e,n)){d||(f[a]=0);var u="@"+ ++f[a];a=E(e+u,n+u)}return new M(e,n,r,a)}function O(){return i.size}function b(){return o.size}function B(e){var n=c(e);return n?n.links:null}function D(e,n){return n!==void 0&&(e=N(e,n)),T(e)}function T(e){if(!e||!o.get(e.id))return!1;k(),o.delete(e.id);var n=c(e.fromId),r=c(e.toId);return n&&n.links.delete(e),r&&r.links.delete(e),p(e,"remove"),L(),!0}function N(e,n){if(!(e===void 0||n===void 0))return o.get(E(e,n))}function H(){k(),U(function(e){q(e.id)}),L()}function J(e){if(typeof e=="function")for(var n=o.values(),r=n.next();!r.done;){if(e(r.value))return!0;r=n.next()}}function K(e,n,r){var a=c(e);if(a&&a.links&&typeof n=="function")return r?X(a.links,e,n):Q(a.links,e,n)}function Q(e,n,r){for(var a,d=e.values(),u=d.next();!u.done;){var h=u.value,$=h.fromId===n?h.toId:h.fromId;if(a=r(i.get($),h),a)return!0;u=d.next()}}function X(e,n,r){for(var a,d=e.values(),u=d.next();!u.done;){var h=u.value;if(h.fromId===n&&(a=r(i.get(h.toId),h),a))return!0;u=d.next()}}function x(){}function Z(){v+=1}function _(){v-=1,v===0&&l.length>0&&(g.fire("changed",l),l.length=0)}function U(e){if(typeof e!="function")throw new Error("Function is expected to iterate over graph nodes. You passed "+e);for(var n=i.values(),r=n.next();!r.done;){if(e(r.value))return!0;r=n.next()}}}function R(t,i){this.id=t,this.links=null,this.data=i}function S(t,i){t.links?t.links.add(i):t.links=new Set([i])}function M(t,i,o,f){this.fromId=t,this.toId=i,this.data=o,this.id=f}function E(t,i){return t.toString()+"👉 "+i.toString()}return F})); |
| 3 | +is considered to be not a multigraph by default (each edge is unique).`),t.multigraph=t.uniqueLinkId),t.multigraph===void 0&&(t.multigraph=!1),typeof Map!="function")throw new Error("ngraph.graph requires `Map` to be defined. Please polyfill it before using ngraph");var i=new Map,o=new Map,f={},v=0,c=t.multigraph?W:V,s=[],p=x,m=x,k=x,L=x,g={version:20,addNode:C,addLink:G,removeLink:D,removeNode:q,getNode:l,getNodeCount:O,getLinkCount:b,getEdgeCount:b,getLinksCount:b,getNodesCount:O,getLinks:Y,forEachNode:U,forEachLinkedNode:Q,forEachLink:K,beginUpdate:k,endUpdate:L,clear:J,hasLink:N,hasNode:l,getLink:N,getLinkById:H};return w(g),P(),g;function P(){var e=g.on;g.on=n;function n(){return g.beginUpdate=k=_,g.endUpdate=L=$,p=z,m=B,g.on=e,e.apply(g,arguments)}}function z(e,n){s.push({link:e,changeType:n})}function B(e,n){s.push({node:e,changeType:n})}function C(e,n){if(e===void 0)throw new Error("Invalid node identifier");k();var r=l(e);return r?(r.data=n,m(r,"update")):(r=new R(e,n),m(r,"add")),i.set(e,r),L(),r}function l(e){return i.get(e)}function q(e){var n=l(e);if(!n)return!1;k();var r=n.links;return r&&(r.forEach(T),n.links=null),i.delete(e),m(n,"remove"),L(),!0}function G(e,n,r){k();var a=l(e)||C(e),d=l(n)||C(n),u=c(e,n,r),h=o.has(u.id);return o.set(u.id,u),S(a,u),e!==n&&S(d,u),p(u,h?"update":"add"),L(),u}function V(e,n,r){var a=E(e,n),d=o.get(a);return d?(d.data=r,d):new M(e,n,r,a)}function W(e,n,r){var a=E(e,n),d=f.hasOwnProperty(a);if(d||N(e,n)){d||(f[a]=0);var u="@"+ ++f[a];a=E(e+u,n+u)}return new M(e,n,r,a)}function O(){return i.size}function b(){return o.size}function Y(e){var n=l(e);return n?n.links:null}function D(e,n){return n!==void 0&&(e=N(e,n)),T(e)}function T(e){if(!e||!o.get(e.id))return!1;k(),o.delete(e.id);var n=l(e.fromId),r=l(e.toId);return n&&n.links.delete(e),r&&r.links.delete(e),p(e,"remove"),L(),!0}function N(e,n){if(!(e===void 0||n===void 0))return o.get(E(e,n))}function H(e){if(e!==void 0)return o.get(e)}function J(){k(),U(function(e){q(e.id)}),L()}function K(e){if(typeof e=="function")for(var n=o.values(),r=n.next();!r.done;){if(e(r.value))return!0;r=n.next()}}function Q(e,n,r){var a=l(e);if(a&&a.links&&typeof n=="function")return r?Z(a.links,e,n):X(a.links,e,n)}function X(e,n,r){for(var a,d=e.values(),u=d.next();!u.done;){var h=u.value,I=h.fromId===n?h.toId:h.fromId;if(a=r(i.get(I),h),a)return!0;u=d.next()}}function Z(e,n,r){for(var a,d=e.values(),u=d.next();!u.done;){var h=u.value;if(h.fromId===n&&(a=r(i.get(h.toId),h),a))return!0;u=d.next()}}function x(){}function _(){v+=1}function $(){v-=1,v===0&&s.length>0&&(g.fire("changed",s),s.length=0)}function U(e){if(typeof e!="function")throw new Error("Function is expected to iterate over graph nodes. You passed "+e);for(var n=i.values(),r=n.next();!r.done;){if(e(r.value))return!0;r=n.next()}}}function R(t,i){this.id=t,this.links=null,this.data=i}function S(t,i){t.links?t.links.add(i):t.links=new Set([i])}function M(t,i,o,f){this.fromId=t,this.toId=i,this.data=o,this.id=f}function E(t,i){return t.toString()+"👉 "+i.toString()}return F})); |
4 | 4 | //# sourceMappingURL=ngraph.graph.umd.js.map |
0 commit comments