undirected-graph-typed
Advanced tools
Comparing version 1.47.8 to 1.47.9
@@ -446,2 +446,7 @@ import type { DijkstraResult, VertexKey } from '../../types'; | ||
getBridges(): EO[]; | ||
[Symbol.iterator](): Iterator<[VertexKey, V | undefined]>; | ||
forEach(callback: (entry: [VertexKey, V | undefined], index: number, map: Map<VertexKey, VO>) => void): void; | ||
filter(predicate: (entry: [VertexKey, V | undefined], index: number, map: Map<VertexKey, VO>) => boolean): [VertexKey, V | undefined][]; | ||
map<T>(callback: (entry: [VertexKey, V | undefined], index: number, map: Map<VertexKey, VO>) => T): T[]; | ||
reduce<T>(callback: (accumulator: T, entry: [VertexKey, V | undefined], index: number, map: Map<VertexKey, VO>) => T, initialValue: T): T; | ||
protected abstract _addEdgeOnly(edge: EO): boolean; | ||
@@ -448,0 +453,0 @@ protected _addVertexOnly(newVertex: VO): boolean; |
@@ -1031,2 +1031,43 @@ "use strict"; | ||
} | ||
*[Symbol.iterator]() { | ||
for (const vertex of this._vertices.values()) { | ||
yield [vertex.key, vertex.value]; | ||
} | ||
} | ||
forEach(callback) { | ||
let index = 0; | ||
for (const vertex of this) { | ||
callback(vertex, index, this._vertices); | ||
index++; | ||
} | ||
} | ||
filter(predicate) { | ||
const filtered = []; | ||
let index = 0; | ||
for (const entry of this) { | ||
if (predicate(entry, index, this._vertices)) { | ||
filtered.push(entry); | ||
} | ||
index++; | ||
} | ||
return filtered; | ||
} | ||
map(callback) { | ||
const mapped = []; | ||
let index = 0; | ||
for (const entry of this) { | ||
mapped.push(callback(entry, index, this._vertices)); | ||
index++; | ||
} | ||
return mapped; | ||
} | ||
reduce(callback, initialValue) { | ||
let accumulator = initialValue; | ||
let index = 0; | ||
for (const entry of this) { | ||
accumulator = callback(accumulator, entry, index, this._vertices); | ||
index++; | ||
} | ||
return accumulator; | ||
} | ||
_addVertexOnly(newVertex) { | ||
@@ -1033,0 +1074,0 @@ if (this.hasVertex(newVertex)) { |
@@ -74,3 +74,3 @@ "use strict"; | ||
createVertex(key, value) { | ||
return new DirectedVertex(key, value !== null && value !== void 0 ? value : key); | ||
return new DirectedVertex(key, value); | ||
} | ||
@@ -77,0 +77,0 @@ /** |
{ | ||
"name": "undirected-graph-typed", | ||
"version": "1.47.8", | ||
"version": "1.47.9", | ||
"description": "Undirected Graph. Javascript & Typescript Data Structure.", | ||
@@ -148,4 +148,4 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"data-structure-typed": "^1.47.8" | ||
"data-structure-typed": "^1.47.9" | ||
} | ||
} |
@@ -1162,2 +1162,48 @@ /** | ||
* [Symbol.iterator](): Iterator<[VertexKey, V | undefined]> { | ||
for (const vertex of this._vertices.values()) { | ||
yield [vertex.key, vertex.value]; | ||
} | ||
} | ||
forEach(callback: (entry: [VertexKey, V | undefined], index: number, map: Map<VertexKey, VO>) => void): void { | ||
let index = 0; | ||
for (const vertex of this) { | ||
callback(vertex, index, this._vertices); | ||
index++; | ||
} | ||
} | ||
filter(predicate: (entry: [VertexKey, V | undefined], index: number, map: Map<VertexKey, VO>) => boolean): [VertexKey, V | undefined][] { | ||
const filtered: [VertexKey, V | undefined][] = []; | ||
let index = 0; | ||
for (const entry of this) { | ||
if (predicate(entry, index, this._vertices)) { | ||
filtered.push(entry); | ||
} | ||
index++; | ||
} | ||
return filtered; | ||
} | ||
map<T>(callback: (entry: [VertexKey, V | undefined], index: number, map: Map<VertexKey, VO>) => T): T[] { | ||
const mapped: T[] = []; | ||
let index = 0; | ||
for (const entry of this) { | ||
mapped.push(callback(entry, index, this._vertices)); | ||
index++; | ||
} | ||
return mapped; | ||
} | ||
reduce<T>(callback: (accumulator: T, entry: [VertexKey, V | undefined], index: number, map: Map<VertexKey, VO>) => T, initialValue: T): T { | ||
let accumulator: T = initialValue; | ||
let index = 0; | ||
for (const entry of this) { | ||
accumulator = callback(accumulator, entry, index, this._vertices); | ||
index++; | ||
} | ||
return accumulator; | ||
} | ||
protected abstract _addEdgeOnly(edge: EO): boolean; | ||
@@ -1164,0 +1210,0 @@ |
@@ -90,3 +90,3 @@ /** | ||
createVertex(key: VertexKey, value?: V): VO { | ||
return new DirectedVertex(key, value ?? key) as VO; | ||
return new DirectedVertex(key, value) as VO; | ||
} | ||
@@ -93,0 +93,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1820356
34378
Updateddata-structure-typed@^1.47.9