Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ngraph.graph

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ngraph.graph - npm Package Compare versions

Comparing version 20.0.0 to 20.0.1

171

dist/ngraph.graph.js

@@ -53,9 +53,9 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.createGraph = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){

var nodes = new Map();
var links = [],
var nodes = new Map(); // nodeId => Node
var links = new Map(); // linkId => Link
// Hash of multi-edges. Used to track ids of edges between same nodes
multiEdges = {},
suspendEvents = 0,
var multiEdges = {};
var suspendEvents = 0;
createLink = options.multigraph ? createUniqueLink : createSingleLink,
var createLink = options.multigraph ? createUniqueLink : createSingleLink,

@@ -82,2 +82,8 @@ // Our graph API provides means to listen to graph changes. Users can subscribe

/**
* Sometimes duck typing could be slow. Giving clients a hint about data structure
* via explicit version number here:
*/
version: 20.0,
/**
* Adds node to the graph. If node with given id already exists in the graph

@@ -140,5 +146,3 @@ * its data is extended with whatever comes in 'data' argument.

*/
getNodesCount: function () {
return nodes.size;
},
getNodeCount: getNodeCount,

@@ -148,7 +152,20 @@ /**

*/
getLinksCount: function () {
return links.length;
},
getLinkCount: getLinkCount,
/**
* Gets total number of links in the graph.
*/
getEdgeCount: getLinkCount,
/**
* Synonym for `getLinkCount()`
*/
getLinksCount: getLinkCount,
/**
* Synonym for `getNodeCount()`
*/
getNodesCount: getNodeCount,
/**
* Gets all links (inbound and outbound) from the node with given id.

@@ -159,3 +176,3 @@ * If node with given id is not found null is returned.

*
* @return Array of links from and to requested node if such node exists;
* @return Set of links from and to requested node if such node exists;
* otherwise null is returned.

@@ -216,3 +233,3 @@ */

* Operation complexity is O(n) where n - number of links of a node.
* NOTE: this function is synonim for getLink()
* NOTE: this function is synonym for getLink()
*

@@ -227,3 +244,3 @@ * @returns link if there is one. null otherwise.

* Operation complexity is O(1)
* NOTE: this function is synonim for getNode()
* NOTE: this function is synonym for getNode()
*

@@ -241,3 +258,3 @@ * @returns node if there is one; Falsy value otherwise.

*
* @returns link if there is one. null otherwise.
* @returns link if there is one; undefined otherwise.
*/

@@ -325,9 +342,7 @@ getLink: getLink

if (prevLinks) {
prevLinks.forEach(removeLinkInstance);
node.links = null;
for(var i = 0; i < prevLinks.length; ++i) {
removeLink(prevLinks[i]);
}
}
nodes.delete(nodeId)
nodes.delete(nodeId);

@@ -349,4 +364,5 @@ recordNodeChange(node, 'remove');

var link = createLink(fromId, toId, data);
var isUpdate = links.has(link.id);
links.push(link);
links.set(link.id, link);

@@ -360,3 +376,3 @@ // TODO: this is not cool. On large graphs potentially would consume more memory.

recordLinkChange(link, 'add');
recordLinkChange(link, isUpdate ? 'update' : 'add');

@@ -370,2 +386,8 @@ exitModification();

var linkId = makeLinkId(fromId, toId);
var prevLink = links.get(linkId);
if (prevLink) {
prevLink.data = data;
return prevLink;
}
return new Link(fromId, toId, data, linkId);

@@ -375,3 +397,3 @@ }

function createUniqueLink(fromId, toId, data) {
// TODO: Get rid of this method.
// TODO: Find a better/faster way to store multigraphs
var linkId = makeLinkId(fromId, toId);

@@ -390,2 +412,10 @@ var isMultiEdge = multiEdges.hasOwnProperty(linkId);

function getNodeCount() {
return nodes.size;
}
function getLinkCount() {
return links.size;
}
function getLinks(nodeId) {

@@ -396,14 +426,18 @@ var node = getNode(nodeId);

function removeLink(link) {
function removeLink(link, otherId) {
if (otherId !== undefined) {
link = getLink(link, otherId);
}
return removeLinkInstance(link);
}
function removeLinkInstance(link) {
if (!link) {
return false;
}
var idx = indexOfElementInArray(link, links);
if (idx < 0) {
return false;
}
if (!links.get(link.id)) return false;
enterModification();
links.splice(idx, 1);
links.delete(link.id);

@@ -414,13 +448,7 @@ var fromNode = getNode(link.fromId);

if (fromNode) {
idx = indexOfElementInArray(link, fromNode.links);
if (idx >= 0) {
fromNode.links.splice(idx, 1);
}
fromNode.links.delete(link);
}
if (toNode) {
idx = indexOfElementInArray(link, toNode.links);
if (idx >= 0) {
toNode.links.splice(idx, 1);
}
toNode.links.delete(link);
}

@@ -436,17 +464,4 @@

function getLink(fromNodeId, toNodeId) {
// TODO: Use sorted links to speed this up
var node = getNode(fromNodeId),
i;
if (!node || !node.links) {
return null;
}
for (i = 0; i < node.links.length; ++i) {
var link = node.links[i];
if (link.fromId === fromNodeId && link.toId === toNodeId) {
return link;
}
}
return null; // no link.
if (fromNodeId === undefined || toNodeId === undefined) return undefined;
return links.get(makeLinkId(fromNodeId, toNodeId));
}

@@ -463,6 +478,10 @@

function forEachLink(callback) {
var i, length;
if (typeof callback === 'function') {
for (i = 0, length = links.length; i < length; ++i) {
callback(links[i]);
var valuesIterator = links.values();
var nextValue = valuesIterator.next();
while (!nextValue.done) {
if (callback(nextValue.value)) {
return true; // client doesn't want to proceed. Return.
}
nextValue = valuesIterator.next();
}

@@ -484,8 +503,11 @@ }

// eslint-disable-next-line no-shadow
function forEachNonOrientedLink(links, nodeId, callback) {
var quitFast;
for (var i = 0; i < links.length; ++i) {
var link = links[i];
var valuesIterator = links.values();
var nextValue = valuesIterator.next();
while (!nextValue.done) {
var link = nextValue.value;
var linkedNodeId = link.fromId === nodeId ? link.toId : link.fromId;
quitFast = callback(nodes.get(linkedNodeId), link);

@@ -495,11 +517,15 @@ if (quitFast) {

}
nextValue = valuesIterator.next();
}
}
// eslint-disable-next-line no-shadow
function forEachOrientedLink(links, nodeId, callback) {
var quitFast;
for (var i = 0; i < links.length; ++i) {
var link = links[i];
var valuesIterator = links.values();
var nextValue = valuesIterator.next();
while (!nextValue.done) {
var link = nextValue.value;
if (link.fromId === nodeId) {
quitFast = callback(nodes.get(link.toId), link)
quitFast = callback(nodes.get(link.toId), link);
if (quitFast) {

@@ -509,2 +535,3 @@ return true; // Client does not need more iterations. Break now.

}
nextValue = valuesIterator.next();
}

@@ -546,22 +573,2 @@ }

// need this for old browsers. Should this be a separate module?
function indexOfElementInArray(element, array) {
if (!array) return -1;
if (array.indexOf) {
return array.indexOf(element);
}
var len = array.length,
i;
for (i = 0; i < len; i += 1) {
if (array[i] === element) {
return i;
}
}
return -1;
}
/**

@@ -578,5 +585,5 @@ * Internal structure to represent node;

if (node.links) {
node.links.push(link);
node.links.add(link);
} else {
node.links = [link];
node.links = new Set([link]);
}

@@ -583,0 +590,0 @@ }

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

(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.createGraph=f()}})(function(){var define,module,exports;return function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r}()({1:[function(require,module,exports){module.exports=createGraph;var eventify=require("ngraph.events");function createGraph(options){options=options||{};if("uniqueLinkId"in options){console.warn("ngraph.graph: Starting from version 0.14 `uniqueLinkId` is deprecated.\n"+"Use `multigraph` option instead\n","\n","Note: there is also change in default behavior: From now on each graph\n"+"is considered to be not a multigraph by default (each edge is unique).");options.multigraph=options.uniqueLinkId}if(options.multigraph===undefined)options.multigraph=false;if(typeof Map!=="function"){throw new Error("ngraph.graph requires `Map` to be defined. Please polyfill it before using ngraph")}var nodes=new Map;var links=[],multiEdges={},suspendEvents=0,createLink=options.multigraph?createUniqueLink:createSingleLink,changes=[],recordLinkChange=noop,recordNodeChange=noop,enterModification=noop,exitModification=noop;var graphPart={addNode:addNode,addLink:addLink,removeLink:removeLink,removeNode:removeNode,getNode:getNode,getNodesCount:function(){return nodes.size},getLinksCount:function(){return links.length},getLinks:getLinks,forEachNode:forEachNode,forEachLinkedNode:forEachLinkedNode,forEachLink:forEachLink,beginUpdate:enterModification,endUpdate:exitModification,clear:clear,hasLink:getLink,hasNode:getNode,getLink:getLink};eventify(graphPart);monitorSubscribers();return graphPart;function monitorSubscribers(){var realOn=graphPart.on;graphPart.on=on;function on(){graphPart.beginUpdate=enterModification=enterModificationReal;graphPart.endUpdate=exitModification=exitModificationReal;recordLinkChange=recordLinkChangeReal;recordNodeChange=recordNodeChangeReal;graphPart.on=realOn;return realOn.apply(graphPart,arguments)}}function recordLinkChangeReal(link,changeType){changes.push({link:link,changeType:changeType})}function recordNodeChangeReal(node,changeType){changes.push({node:node,changeType:changeType})}function addNode(nodeId,data){if(nodeId===undefined){throw new Error("Invalid node identifier")}enterModification();var node=getNode(nodeId);if(!node){node=new Node(nodeId,data);recordNodeChange(node,"add")}else{node.data=data;recordNodeChange(node,"update")}nodes.set(nodeId,node);exitModification();return node}function getNode(nodeId){return nodes.get(nodeId)}function removeNode(nodeId){var node=getNode(nodeId);if(!node){return false}enterModification();var prevLinks=node.links;if(prevLinks){node.links=null;for(var i=0;i<prevLinks.length;++i){removeLink(prevLinks[i])}}nodes.delete(nodeId);recordNodeChange(node,"remove");exitModification();return true}function addLink(fromId,toId,data){enterModification();var fromNode=getNode(fromId)||addNode(fromId);var toNode=getNode(toId)||addNode(toId);var link=createLink(fromId,toId,data);links.push(link);addLinkToNode(fromNode,link);if(fromId!==toId){addLinkToNode(toNode,link)}recordLinkChange(link,"add");exitModification();return link}function createSingleLink(fromId,toId,data){var linkId=makeLinkId(fromId,toId);return new Link(fromId,toId,data,linkId)}function createUniqueLink(fromId,toId,data){var linkId=makeLinkId(fromId,toId);var isMultiEdge=multiEdges.hasOwnProperty(linkId);if(isMultiEdge||getLink(fromId,toId)){if(!isMultiEdge){multiEdges[linkId]=0}var suffix="@"+ ++multiEdges[linkId];linkId=makeLinkId(fromId+suffix,toId+suffix)}return new Link(fromId,toId,data,linkId)}function getLinks(nodeId){var node=getNode(nodeId);return node?node.links:null}function removeLink(link){if(!link){return false}var idx=indexOfElementInArray(link,links);if(idx<0){return false}enterModification();links.splice(idx,1);var fromNode=getNode(link.fromId);var toNode=getNode(link.toId);if(fromNode){idx=indexOfElementInArray(link,fromNode.links);if(idx>=0){fromNode.links.splice(idx,1)}}if(toNode){idx=indexOfElementInArray(link,toNode.links);if(idx>=0){toNode.links.splice(idx,1)}}recordLinkChange(link,"remove");exitModification();return true}function getLink(fromNodeId,toNodeId){var node=getNode(fromNodeId),i;if(!node||!node.links){return null}for(i=0;i<node.links.length;++i){var link=node.links[i];if(link.fromId===fromNodeId&&link.toId===toNodeId){return link}}return null}function clear(){enterModification();forEachNode(function(node){removeNode(node.id)});exitModification()}function forEachLink(callback){var i,length;if(typeof callback==="function"){for(i=0,length=links.length;i<length;++i){callback(links[i])}}}function forEachLinkedNode(nodeId,callback,oriented){var node=getNode(nodeId);if(node&&node.links&&typeof callback==="function"){if(oriented){return forEachOrientedLink(node.links,nodeId,callback)}else{return forEachNonOrientedLink(node.links,nodeId,callback)}}}function forEachNonOrientedLink(links,nodeId,callback){var quitFast;for(var i=0;i<links.length;++i){var link=links[i];var linkedNodeId=link.fromId===nodeId?link.toId:link.fromId;quitFast=callback(nodes.get(linkedNodeId),link);if(quitFast){return true}}}function forEachOrientedLink(links,nodeId,callback){var quitFast;for(var i=0;i<links.length;++i){var link=links[i];if(link.fromId===nodeId){quitFast=callback(nodes.get(link.toId),link);if(quitFast){return true}}}}function noop(){}function enterModificationReal(){suspendEvents+=1}function exitModificationReal(){suspendEvents-=1;if(suspendEvents===0&&changes.length>0){graphPart.fire("changed",changes);changes.length=0}}function forEachNode(callback){if(typeof callback!=="function"){throw new Error("Function is expected to iterate over graph nodes. You passed "+callback)}var valuesIterator=nodes.values();var nextValue=valuesIterator.next();while(!nextValue.done){if(callback(nextValue.value)){return true}nextValue=valuesIterator.next()}}}function indexOfElementInArray(element,array){if(!array)return-1;if(array.indexOf){return array.indexOf(element)}var len=array.length,i;for(i=0;i<len;i+=1){if(array[i]===element){return i}}return-1}function Node(id,data){this.id=id;this.links=null;this.data=data}function addLinkToNode(node,link){if(node.links){node.links.push(link)}else{node.links=[link]}}function Link(fromId,toId,data,id){this.fromId=fromId;this.toId=toId;this.data=data;this.id=id}function makeLinkId(fromId,toId){return fromId.toString()+"👉 "+toId.toString()}},{"ngraph.events":2}],2:[function(require,module,exports){module.exports=function eventify(subject){validateSubject(subject);var eventsStorage=createEventsStorage(subject);subject.on=eventsStorage.on;subject.off=eventsStorage.off;subject.fire=eventsStorage.fire;return subject};function createEventsStorage(subject){var registeredEvents=Object.create(null);return{on:function(eventName,callback,ctx){if(typeof callback!=="function"){throw new Error("callback is expected to be a function")}var handlers=registeredEvents[eventName];if(!handlers){handlers=registeredEvents[eventName]=[]}handlers.push({callback:callback,ctx:ctx});return subject},off:function(eventName,callback){var wantToRemoveAll=typeof eventName==="undefined";if(wantToRemoveAll){registeredEvents=Object.create(null);return subject}if(registeredEvents[eventName]){var deleteAllCallbacksForEvent=typeof callback!=="function";if(deleteAllCallbacksForEvent){delete registeredEvents[eventName]}else{var callbacks=registeredEvents[eventName];for(var i=0;i<callbacks.length;++i){if(callbacks[i].callback===callback){callbacks.splice(i,1)}}}}return subject},fire:function(eventName){var callbacks=registeredEvents[eventName];if(!callbacks){return subject}var fireArguments;if(arguments.length>1){fireArguments=Array.prototype.splice.call(arguments,1)}for(var i=0;i<callbacks.length;++i){var callbackInfo=callbacks[i];callbackInfo.callback.apply(callbackInfo.ctx,fireArguments)}return subject}}}function validateSubject(subject){if(!subject){throw new Error("Eventify cannot use falsy object as events subject")}var reservedWords=["on","fire","off"];for(var i=0;i<reservedWords.length;++i){if(subject.hasOwnProperty(reservedWords[i])){throw new Error("Subject cannot be eventified, since it already has property '"+reservedWords[i]+"'")}}}},{}]},{},[1])(1)});
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.createGraph=f()}})(function(){var define,module,exports;return function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r}()({1:[function(require,module,exports){module.exports=createGraph;var eventify=require("ngraph.events");function createGraph(options){options=options||{};if("uniqueLinkId"in options){console.warn("ngraph.graph: Starting from version 0.14 `uniqueLinkId` is deprecated.\n"+"Use `multigraph` option instead\n","\n","Note: there is also change in default behavior: From now on each graph\n"+"is considered to be not a multigraph by default (each edge is unique).");options.multigraph=options.uniqueLinkId}if(options.multigraph===undefined)options.multigraph=false;if(typeof Map!=="function"){throw new Error("ngraph.graph requires `Map` to be defined. Please polyfill it before using ngraph")}var nodes=new Map;var links=new Map;var multiEdges={};var suspendEvents=0;var createLink=options.multigraph?createUniqueLink:createSingleLink,changes=[],recordLinkChange=noop,recordNodeChange=noop,enterModification=noop,exitModification=noop;var graphPart={version:20,addNode:addNode,addLink:addLink,removeLink:removeLink,removeNode:removeNode,getNode:getNode,getNodeCount:getNodeCount,getLinkCount:getLinkCount,getEdgeCount:getLinkCount,getLinksCount:getLinkCount,getNodesCount:getNodeCount,getLinks:getLinks,forEachNode:forEachNode,forEachLinkedNode:forEachLinkedNode,forEachLink:forEachLink,beginUpdate:enterModification,endUpdate:exitModification,clear:clear,hasLink:getLink,hasNode:getNode,getLink:getLink};eventify(graphPart);monitorSubscribers();return graphPart;function monitorSubscribers(){var realOn=graphPart.on;graphPart.on=on;function on(){graphPart.beginUpdate=enterModification=enterModificationReal;graphPart.endUpdate=exitModification=exitModificationReal;recordLinkChange=recordLinkChangeReal;recordNodeChange=recordNodeChangeReal;graphPart.on=realOn;return realOn.apply(graphPart,arguments)}}function recordLinkChangeReal(link,changeType){changes.push({link:link,changeType:changeType})}function recordNodeChangeReal(node,changeType){changes.push({node:node,changeType:changeType})}function addNode(nodeId,data){if(nodeId===undefined){throw new Error("Invalid node identifier")}enterModification();var node=getNode(nodeId);if(!node){node=new Node(nodeId,data);recordNodeChange(node,"add")}else{node.data=data;recordNodeChange(node,"update")}nodes.set(nodeId,node);exitModification();return node}function getNode(nodeId){return nodes.get(nodeId)}function removeNode(nodeId){var node=getNode(nodeId);if(!node){return false}enterModification();var prevLinks=node.links;if(prevLinks){prevLinks.forEach(removeLinkInstance);node.links=null}nodes.delete(nodeId);recordNodeChange(node,"remove");exitModification();return true}function addLink(fromId,toId,data){enterModification();var fromNode=getNode(fromId)||addNode(fromId);var toNode=getNode(toId)||addNode(toId);var link=createLink(fromId,toId,data);var isUpdate=links.has(link.id);links.set(link.id,link);addLinkToNode(fromNode,link);if(fromId!==toId){addLinkToNode(toNode,link)}recordLinkChange(link,isUpdate?"update":"add");exitModification();return link}function createSingleLink(fromId,toId,data){var linkId=makeLinkId(fromId,toId);var prevLink=links.get(linkId);if(prevLink){prevLink.data=data;return prevLink}return new Link(fromId,toId,data,linkId)}function createUniqueLink(fromId,toId,data){var linkId=makeLinkId(fromId,toId);var isMultiEdge=multiEdges.hasOwnProperty(linkId);if(isMultiEdge||getLink(fromId,toId)){if(!isMultiEdge){multiEdges[linkId]=0}var suffix="@"+ ++multiEdges[linkId];linkId=makeLinkId(fromId+suffix,toId+suffix)}return new Link(fromId,toId,data,linkId)}function getNodeCount(){return nodes.size}function getLinkCount(){return links.size}function getLinks(nodeId){var node=getNode(nodeId);return node?node.links:null}function removeLink(link,otherId){if(otherId!==undefined){link=getLink(link,otherId)}return removeLinkInstance(link)}function removeLinkInstance(link){if(!link){return false}if(!links.get(link.id))return false;enterModification();links.delete(link.id);var fromNode=getNode(link.fromId);var toNode=getNode(link.toId);if(fromNode){fromNode.links.delete(link)}if(toNode){toNode.links.delete(link)}recordLinkChange(link,"remove");exitModification();return true}function getLink(fromNodeId,toNodeId){if(fromNodeId===undefined||toNodeId===undefined)return undefined;return links.get(makeLinkId(fromNodeId,toNodeId))}function clear(){enterModification();forEachNode(function(node){removeNode(node.id)});exitModification()}function forEachLink(callback){if(typeof callback==="function"){var valuesIterator=links.values();var nextValue=valuesIterator.next();while(!nextValue.done){if(callback(nextValue.value)){return true}nextValue=valuesIterator.next()}}}function forEachLinkedNode(nodeId,callback,oriented){var node=getNode(nodeId);if(node&&node.links&&typeof callback==="function"){if(oriented){return forEachOrientedLink(node.links,nodeId,callback)}else{return forEachNonOrientedLink(node.links,nodeId,callback)}}}function forEachNonOrientedLink(links,nodeId,callback){var quitFast;var valuesIterator=links.values();var nextValue=valuesIterator.next();while(!nextValue.done){var link=nextValue.value;var linkedNodeId=link.fromId===nodeId?link.toId:link.fromId;quitFast=callback(nodes.get(linkedNodeId),link);if(quitFast){return true}nextValue=valuesIterator.next()}}function forEachOrientedLink(links,nodeId,callback){var quitFast;var valuesIterator=links.values();var nextValue=valuesIterator.next();while(!nextValue.done){var link=nextValue.value;if(link.fromId===nodeId){quitFast=callback(nodes.get(link.toId),link);if(quitFast){return true}}nextValue=valuesIterator.next()}}function noop(){}function enterModificationReal(){suspendEvents+=1}function exitModificationReal(){suspendEvents-=1;if(suspendEvents===0&&changes.length>0){graphPart.fire("changed",changes);changes.length=0}}function forEachNode(callback){if(typeof callback!=="function"){throw new Error("Function is expected to iterate over graph nodes. You passed "+callback)}var valuesIterator=nodes.values();var nextValue=valuesIterator.next();while(!nextValue.done){if(callback(nextValue.value)){return true}nextValue=valuesIterator.next()}}}function Node(id,data){this.id=id;this.links=null;this.data=data}function addLinkToNode(node,link){if(node.links){node.links.add(link)}else{node.links=new Set([link])}}function Link(fromId,toId,data,id){this.fromId=fromId;this.toId=toId;this.data=data;this.id=id}function makeLinkId(fromId,toId){return fromId.toString()+"👉 "+toId.toString()}},{"ngraph.events":2}],2:[function(require,module,exports){module.exports=function eventify(subject){validateSubject(subject);var eventsStorage=createEventsStorage(subject);subject.on=eventsStorage.on;subject.off=eventsStorage.off;subject.fire=eventsStorage.fire;return subject};function createEventsStorage(subject){var registeredEvents=Object.create(null);return{on:function(eventName,callback,ctx){if(typeof callback!=="function"){throw new Error("callback is expected to be a function")}var handlers=registeredEvents[eventName];if(!handlers){handlers=registeredEvents[eventName]=[]}handlers.push({callback:callback,ctx:ctx});return subject},off:function(eventName,callback){var wantToRemoveAll=typeof eventName==="undefined";if(wantToRemoveAll){registeredEvents=Object.create(null);return subject}if(registeredEvents[eventName]){var deleteAllCallbacksForEvent=typeof callback!=="function";if(deleteAllCallbacksForEvent){delete registeredEvents[eventName]}else{var callbacks=registeredEvents[eventName];for(var i=0;i<callbacks.length;++i){if(callbacks[i].callback===callback){callbacks.splice(i,1)}}}}return subject},fire:function(eventName){var callbacks=registeredEvents[eventName];if(!callbacks){return subject}var fireArguments;if(arguments.length>1){fireArguments=Array.prototype.splice.call(arguments,1)}for(var i=0;i<callbacks.length;++i){var callbackInfo=callbacks[i];callbackInfo.callback.apply(callbackInfo.ctx,fireArguments)}return subject}}}function validateSubject(subject){if(!subject){throw new Error("Eventify cannot use falsy object as events subject")}var reservedWords=["on","fire","off"];for(var i=0;i<reservedWords.length;++i){if(subject.hasOwnProperty(reservedWords[i])){throw new Error("Subject cannot be eventified, since it already has property '"+reservedWords[i]+"'")}}}},{}]},{},[1])(1)});

@@ -25,3 +25,3 @@ // Type definitions for ngraph.graph v20.0.0

/**
* Node identifer where this links starts
* Node identifier where this links starts
*/

@@ -31,3 +31,3 @@ fromId: NodeId,

/**
* Node identifer where this link points to
* Node identifier where this link points to
*/

@@ -34,0 +34,0 @@ toId: NodeId,

{
"name": "ngraph.graph",
"version": "20.0.0",
"version": "20.0.1",
"description": "graph data structure",

@@ -39,3 +39,3 @@ "main": "index.js",

"ngraph.random": "^1.1.0",
"tap": "^15.0.9",
"tap": "^16.0.1",
"uglify-js": "^3.13.5"

@@ -42,0 +42,0 @@ },

@@ -21,3 +21,3 @@ ngraph.graph

``` html
<script src='https://unpkg.com/ngraph.graph@19.0.0/dist/ngraph.graph.min.js'></script>
<script src='https://unpkg.com/ngraph.graph@20.0.1/dist/ngraph.graph.min.js'></script>
```

@@ -24,0 +24,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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