Socket
Socket
Sign inDemoInstall

typescript-generic-datastructures

Package Overview
Dependencies
0
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.2.3 to 1.3.0

README.md

8

dist/types/data-structures/Graph/GraphEdge.d.ts
import { GraphVertex } from './GraphVertex';
export declare type EdgeKeyExtractor<T> = (edge: T) => string | number;
export declare class GraphEdge<TVertex, TEdge> {

@@ -6,6 +7,7 @@ startVertex: GraphVertex<TVertex, TEdge>;

value: TEdge;
constructor(startVertex: GraphVertex<TVertex, TEdge>, endVertex: GraphVertex<TVertex, TEdge>, value: TEdge);
getKey(): string;
private keyExtractor?;
constructor(startVertex: GraphVertex<TVertex, TEdge>, endVertex: GraphVertex<TVertex, TEdge>, value: TEdge, keyExtractor?: EdgeKeyExtractor<GraphEdge<TVertex, TEdge>> | undefined);
getKey(): string | number;
reverse(): this;
toString(): string;
toString(): string | number;
}

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

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["typescript-generic-datastructures"]=t():e["typescript-generic-datastructures"]=t()}(this,(function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function a(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}r.r(t);var u=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];n(this,e),this.isDirected=t,a(this,"vertices",void 0),a(this,"edges",void 0),this.vertices={},this.edges={}}var t,r,u;return t=e,(r=[{key:"addVertex",value:function(e){return this.vertices[e.getKey()]=e,this}},{key:"getVertexByKey",value:function(e){return this.vertices[e]}},{key:"getNeighbors",value:function(e){return e.getNeighbors()}},{key:"getAllVertices",value:function(){return Object.values(this.vertices)}},{key:"getAllEdges",value:function(){return Object.values(this.edges)}},{key:"addEdge",value:function(e){var t=this.getVertexByKey(e.startVertex.getKey()),r=this.getVertexByKey(e.endVertex.getKey());if(t||(this.addVertex(e.startVertex),t=this.getVertexByKey(e.startVertex.getKey())),r||(this.addVertex(e.endVertex),r=this.getVertexByKey(e.endVertex.getKey())),this.edges[e.getKey()])throw new Error("Edge has already been added before");return this.edges[e.getKey()]=e,this.isDirected?t.addEdge(e):(t.addEdge(e),r.addEdge(e)),this}},{key:"deleteEdge",value:function(e){if(!this.edges[e.getKey()])throw new Error("Edge not found in graph");delete this.edges[e.getKey()];var t=this.getVertexByKey(e.startVertex.getKey()),r=this.getVertexByKey(e.endVertex.getKey());t.deleteEdge(e),r.deleteEdge(e)}},{key:"findEdge",value:function(e,t){var r=this.getVertexByKey(e.getKey());return r?r.findEdge(t):null}},{key:"reverse",value:function(){var e=this;return this.getAllEdges().forEach((function(t){e.deleteEdge(t),t.reverse(),e.addEdge(t)})),this}},{key:"getVerticesIndices",value:function(){var e={};return this.getAllVertices().forEach((function(t,r){e[t.getKey()]=r})),e}},{key:"getAdjacencyMatrix",value:function(){var e=this,t=this.getAllVertices(),r=this.getVerticesIndices(),n=Array(t.length).fill(null).map((function(){return Array(t.length).fill(1/0)}));return t.forEach((function(t,i){t.getNeighbors().forEach((function(a){var u,o=r[a.getKey()];n[i][o]=null===(u=e.findEdge(t,a))||void 0===u?void 0:u.value}))})),n}},{key:"toString",value:function(){return Object.keys(this.vertices).toString()}}])&&i(t.prototype,r),u&&i(t,u),e}();function o(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var l=function(){function e(t,r,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.startVertex=t,this.endVertex=r,this.value=n}var t,r,n;return t=e,(r=[{key:"getKey",value:function(){var e=this.startVertex.getKey(),t=this.endVertex.getKey();return"".concat(e,"_").concat(t)}},{key:"reverse",value:function(){var e=this.startVertex;return this.startVertex=this.endVertex,this.endVertex=e,this}},{key:"toString",value:function(){return this.getKey()}}])&&o(t.prototype,r),n&&o(t,n),e}();function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function h(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var f=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;s(this,e),h(this,"value",void 0),h(this,"next",void 0),this.value=t,this.next=r}var t,r,n;return t=e,(r=[{key:"toString",value:function(e){return e?e(this.value):"".concat(this.value)}}])&&c(t.prototype,r),n&&c(t,n),e}();function d(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var v=function(){function e(t){var r,n,i,a=t.compareFunction,u=t.keyExtractor;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),i=void 0,(n="compare")in(r=this)?Object.defineProperty(r,n,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[n]=i,a)this.compare=a;else{if(!u)throw new Error("Either compareFunction or keyExtractor parameter should be defined");this.compare=e.defaultCompareFunction(u)}}var t,r,n;return t=e,n=[{key:"defaultCompareFunction",value:function(e){return function(t,r){var n=e(t),i=e(r);return n===i?0:n<i?-1:1}}}],(r=[{key:"equal",value:function(e,t){return 0===this.compare(e,t)}},{key:"lessThan",value:function(e,t){return this.compare(e,t)<0}},{key:"greaterThan",value:function(e,t){return this.compare(e,t)>0}},{key:"lessThanOrEqual",value:function(e,t){return this.lessThan(e,t)||this.equal(e,t)}},{key:"greaterThanOrEqual",value:function(e,t){return this.greaterThan(e,t)||this.equal(e,t)}},{key:"reverse",value:function(){var e=this.compare;this.compare=function(t,r){return e(r,t)}}}])&&d(t.prototype,r),n&&d(t,n),e}();function y(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function g(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var p=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),g(this,"head",void 0),g(this,"tail",void 0),g(this,"compare",void 0),this.head=null,this.tail=null,this.compare=new v(t)}var t,r,n;return t=e,(r=[{key:"prepend",value:function(e){var t=new f(e,this.head);return this.head=t,this.tail||(this.tail=t),this}},{key:"append",value:function(e){var t,r=new f(e);return this.head?((null===(t=this.tail)||void 0===t?void 0:t.next)&&(this.tail.next=r),this.tail=r,this):(this.head=r,this.tail=r,this)}},{key:"delete",value:function(e){if(!this.head)return null;for(var t=null;this.head&&this.compare.equal(this.head.value,e);)t=this.head,this.head=this.head.next;var r=this.head;if(null!==r)for(;r.next;)this.compare.equal(r.next.value,e)?(t=r.next,r.next=r.next.next):r=r.next;return this.tail&&this.compare.equal(this.tail.value,e)&&(this.tail=r),t}},{key:"find",value:function(e){var t=e.value,r=void 0===t?void 0:t,n=e.callback,i=void 0===n?void 0:n;if(!this.head)return null;for(var a=this.head;a;){if(i&&i(a.value))return a;if(void 0!==r&&this.compare.equal(a.value,r))return a;a=a.next}return null}},{key:"deleteTail",value:function(){var e=this.tail;if(this.head===this.tail)return this.head=null,this.tail=null,e;for(var t=this.head;null===(r=t)||void 0===r?void 0:r.next;){var r;t.next.next?t=t.next:t.next=null}return this.tail=t,e}},{key:"deleteHead",value:function(){if(!this.head)return null;var e=this.head;return this.head.next?this.head=this.head.next:(this.head=null,this.tail=null),e}},{key:"fromArray",value:function(e){var t=this;return e.forEach((function(e){return t.append(e)})),this}},{key:"toArray",value:function(){for(var e=[],t=this.head;t;)e.push(t),t=t.next;return e}},{key:"toString",value:function(e){return this.toArray().map((function(t){return t.toString(e)})).toString()}},{key:"reverse",value:function(){for(var e=this.head,t=null,r=null;e;)r=e.next,e.next=t,t=e,e=r;return this.tail=this.head,this.head=t,this}}])&&y(t.prototype,r),n&&y(t,n),e}();function b(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function x(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var k=function(){function e(t,r){if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.keyExtractor=r,x(this,"value",void 0),x(this,"edges",void 0),void 0===t)throw new Error("Graph vertex must have a value");this.value=t,this.edges=new p({compareFunction:function(e,t){return e.getKey()===t.getKey()?0:e.getKey()<t.getKey()?-1:1}})}var t,r,n;return t=e,(r=[{key:"addEdge",value:function(e){return this.edges.append(e),this}},{key:"deleteEdge",value:function(e){this.edges.delete(e)}},{key:"getNeighbors",value:function(){var e=this;return this.edges.toArray().map((function(t){return t.value.startVertex===e?t.value.endVertex:t.value.startVertex}))}},{key:"getEdges",value:function(){return this.edges.toArray().map((function(e){return e.value}))}},{key:"getDegree",value:function(){return this.edges.toArray().length}},{key:"hasEdge",value:function(e){return!!this.edges.find({callback:function(t){return t===e}})}},{key:"hasNeighbor",value:function(e){return!!this.edges.find({callback:function(t){return t.startVertex===e||t.endVertex===e}})}},{key:"findEdge",value:function(e){var t=this.edges.find({callback:function(t){return t.startVertex===e||t.endVertex===e}});return t?t.value:null}},{key:"getKey",value:function(){return this.keyExtractor(this.value)}},{key:"deleteAllEdges",value:function(){var e=this;return this.getEdges().forEach((function(t){return e.deleteEdge(t)})),this}},{key:"toString",value:function(e){return e?e(this.value):"".concat(this.value)}}])&&b(t.prototype,r),n&&b(t,n),e}();r.d(t,"Graph",(function(){return u})),r.d(t,"GraphEdge",(function(){return l})),r.d(t,"GraphVertex",(function(){return k})),r.d(t,"LinkedList",(function(){return p})),r.d(t,"LinkedListNode",(function(){return f}))}])}));
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["typescript-generic-datastructures"]=t():e["typescript-generic-datastructures"]=t()}(this,(function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function a(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}r.r(t);var u=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];n(this,e),this.isDirected=t,a(this,"vertices",void 0),a(this,"edges",void 0),this.vertices={},this.edges={}}var t,r,u;return t=e,(r=[{key:"addVertex",value:function(e){return this.vertices[e.getKey()]=e,this}},{key:"getVertexByKey",value:function(e){return this.vertices[e]}},{key:"getNeighbors",value:function(e){return e.getNeighbors()}},{key:"getAllVertices",value:function(){return Object.values(this.vertices)}},{key:"getAllEdges",value:function(){return Object.values(this.edges)}},{key:"addEdge",value:function(e){var t=this.getVertexByKey(e.startVertex.getKey()),r=this.getVertexByKey(e.endVertex.getKey());if(t||(this.addVertex(e.startVertex),t=this.getVertexByKey(e.startVertex.getKey())),r||(this.addVertex(e.endVertex),r=this.getVertexByKey(e.endVertex.getKey())),this.edges[e.getKey()])throw new Error("Edge has already been added before");return this.edges[e.getKey()]=e,this.isDirected?t.addEdge(e):(t.addEdge(e),r.addEdge(e)),this}},{key:"deleteEdge",value:function(e){if(!this.edges[e.getKey()])throw new Error("Edge not found in graph");delete this.edges[e.getKey()];var t=this.getVertexByKey(e.startVertex.getKey()),r=this.getVertexByKey(e.endVertex.getKey());t.deleteEdge(e),r.deleteEdge(e)}},{key:"findEdge",value:function(e,t){var r=this.getVertexByKey(e.getKey());return r?r.findEdge(t):null}},{key:"reverse",value:function(){var e=this;return this.getAllEdges().forEach((function(t){e.deleteEdge(t),t.reverse(),e.addEdge(t)})),this}},{key:"getVerticesIndices",value:function(){var e={};return this.getAllVertices().forEach((function(t,r){e[t.getKey()]=r})),e}},{key:"getAdjacencyMatrix",value:function(){var e=this,t=this.getAllVertices(),r=this.getVerticesIndices(),n=Array(t.length).fill(null).map((function(){return Array(t.length).fill(1/0)}));return t.forEach((function(t,i){t.getNeighbors().forEach((function(a){var u,o=r[a.getKey()];n[i][o]=null===(u=e.findEdge(t,a))||void 0===u?void 0:u.value}))})),n}},{key:"toString",value:function(){return Object.keys(this.vertices).toString()}}])&&i(t.prototype,r),u&&i(t,u),e}();function o(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var l=function(){function e(t,r,n,i){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.startVertex=t,this.endVertex=r,this.value=n,this.keyExtractor=i}var t,r,n;return t=e,(r=[{key:"getKey",value:function(){if(this.keyExtractor)return this.keyExtractor(this);var e=this.startVertex.getKey(),t=this.endVertex.getKey();return"".concat(e,"_").concat(t)}},{key:"reverse",value:function(){var e=this.startVertex;return this.startVertex=this.endVertex,this.endVertex=e,this}},{key:"toString",value:function(){return this.getKey()}}])&&o(t.prototype,r),n&&o(t,n),e}();function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function h(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var f=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;s(this,e),h(this,"value",void 0),h(this,"next",void 0),this.value=t,this.next=r}var t,r,n;return t=e,(r=[{key:"toString",value:function(e){return e?e(this.value):"".concat(this.value)}}])&&c(t.prototype,r),n&&c(t,n),e}();function d(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var v=function(){function e(t){var r,n,i,a=t.compareFunction,u=t.keyExtractor;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),i=void 0,(n="compare")in(r=this)?Object.defineProperty(r,n,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[n]=i,a)this.compare=a;else{if(!u)throw new Error("Either compareFunction or keyExtractor parameter should be defined");this.compare=e.defaultCompareFunction(u)}}var t,r,n;return t=e,n=[{key:"defaultCompareFunction",value:function(e){return function(t,r){var n=e(t),i=e(r);return n===i?0:n<i?-1:1}}}],(r=[{key:"equal",value:function(e,t){return 0===this.compare(e,t)}},{key:"lessThan",value:function(e,t){return this.compare(e,t)<0}},{key:"greaterThan",value:function(e,t){return this.compare(e,t)>0}},{key:"lessThanOrEqual",value:function(e,t){return this.lessThan(e,t)||this.equal(e,t)}},{key:"greaterThanOrEqual",value:function(e,t){return this.greaterThan(e,t)||this.equal(e,t)}},{key:"reverse",value:function(){var e=this.compare;this.compare=function(t,r){return e(r,t)}}}])&&d(t.prototype,r),n&&d(t,n),e}();function y(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function g(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var p=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),g(this,"head",void 0),g(this,"tail",void 0),g(this,"compare",void 0),this.head=null,this.tail=null,this.compare=new v(t)}var t,r,n;return t=e,(r=[{key:"prepend",value:function(e){var t=new f(e,this.head);return this.head=t,this.tail||(this.tail=t),this}},{key:"append",value:function(e){var t,r=new f(e);return this.head?((null===(t=this.tail)||void 0===t?void 0:t.next)&&(this.tail.next=r),this.tail=r,this):(this.head=r,this.tail=r,this)}},{key:"delete",value:function(e){if(!this.head)return null;for(var t=null;this.head&&this.compare.equal(this.head.value,e);)t=this.head,this.head=this.head.next;var r=this.head;if(null!==r)for(;r.next;)this.compare.equal(r.next.value,e)?(t=r.next,r.next=r.next.next):r=r.next;return this.tail&&this.compare.equal(this.tail.value,e)&&(this.tail=r),t}},{key:"find",value:function(e){var t=e.value,r=void 0===t?void 0:t,n=e.callback,i=void 0===n?void 0:n;if(!this.head)return null;for(var a=this.head;a;){if(i&&i(a.value))return a;if(void 0!==r&&this.compare.equal(a.value,r))return a;a=a.next}return null}},{key:"deleteTail",value:function(){var e=this.tail;if(this.head===this.tail)return this.head=null,this.tail=null,e;for(var t=this.head;null===(r=t)||void 0===r?void 0:r.next;){var r;t.next.next?t=t.next:t.next=null}return this.tail=t,e}},{key:"deleteHead",value:function(){if(!this.head)return null;var e=this.head;return this.head.next?this.head=this.head.next:(this.head=null,this.tail=null),e}},{key:"fromArray",value:function(e){var t=this;return e.forEach((function(e){return t.append(e)})),this}},{key:"toArray",value:function(){for(var e=[],t=this.head;t;)e.push(t),t=t.next;return e}},{key:"toString",value:function(e){return this.toArray().map((function(t){return t.toString(e)})).toString()}},{key:"reverse",value:function(){for(var e=this.head,t=null,r=null;e;)r=e.next,e.next=t,t=e,e=r;return this.tail=this.head,this.head=t,this}}])&&y(t.prototype,r),n&&y(t,n),e}();function b(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function x(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var k=function(){function e(t,r){if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.keyExtractor=r,x(this,"value",void 0),x(this,"edges",void 0),void 0===t)throw new Error("Graph vertex must have a value");this.value=t,this.edges=new p({compareFunction:function(e,t){return e.getKey()===t.getKey()?0:e.getKey()<t.getKey()?-1:1}})}var t,r,n;return t=e,(r=[{key:"addEdge",value:function(e){return this.edges.append(e),this}},{key:"deleteEdge",value:function(e){this.edges.delete(e)}},{key:"getNeighbors",value:function(){var e=this;return this.edges.toArray().map((function(t){return t.value.startVertex===e?t.value.endVertex:t.value.startVertex}))}},{key:"getEdges",value:function(){return this.edges.toArray().map((function(e){return e.value}))}},{key:"getDegree",value:function(){return this.edges.toArray().length}},{key:"hasEdge",value:function(e){return!!this.edges.find({callback:function(t){return t===e}})}},{key:"hasNeighbor",value:function(e){return!!this.edges.find({callback:function(t){return t.startVertex===e||t.endVertex===e}})}},{key:"findEdge",value:function(e){var t=this.edges.find({callback:function(t){return t.startVertex===e||t.endVertex===e}});return t?t.value:null}},{key:"getKey",value:function(){return this.keyExtractor(this.value)}},{key:"deleteAllEdges",value:function(){var e=this;return this.getEdges().forEach((function(t){return e.deleteEdge(t)})),this}},{key:"toString",value:function(e){return e?e(this.value):"".concat(this.value)}}])&&b(t.prototype,r),n&&b(t,n),e}();r.d(t,"Graph",(function(){return u})),r.d(t,"GraphEdge",(function(){return l})),r.d(t,"GraphVertex",(function(){return k})),r.d(t,"LinkedList",(function(){return p})),r.d(t,"LinkedListNode",(function(){return f}))}])}));
//# sourceMappingURL=typescript-generic-datastructures.map
{
"name": "typescript-generic-datastructures",
"version": "1.2.3",
"version": "1.3.0",
"description": "",
"repository": "emyann/typescript-generic-datastructures",
"main": "./dist/typescript-generic-datastructures.js",

@@ -6,0 +7,0 @@ "types": "./dist/types/index.d.ts",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc