graphology-gexf
Advanced tools
Comparing version 0.8.1 to 0.9.0
@@ -8,3 +8,6 @@ import Graph, {Attributes, GraphConstructor} from 'graphology-types'; | ||
GraphAttributes extends Attributes = Attributes | ||
>(Graph: GraphConstructor<NodeAttributes, EdgeAttributes, GraphAttributes>, source: string | Document): Graph<NodeAttributes, EdgeAttributes, GraphAttributes>; | ||
>( | ||
Graph: GraphConstructor<NodeAttributes, EdgeAttributes, GraphAttributes>, | ||
source: string | Document | ||
): Graph<NodeAttributes, EdgeAttributes, GraphAttributes>; | ||
@@ -18,3 +21,8 @@ export function write< | ||
graph: Graph<NodeAttributes, EdgeAttributes>, | ||
options?: GexfWriterOptions<NodeAttributes, EdgeAttributes, FormattedNodeAttributes, FormattedEdgeAttributes> | ||
options?: GexfWriterOptions< | ||
NodeAttributes, | ||
EdgeAttributes, | ||
FormattedNodeAttributes, | ||
FormattedEdgeAttributes | ||
> | ||
): string; |
@@ -15,6 +15,6 @@ /** | ||
*/ | ||
exports.cast = function(type, value) { | ||
exports.cast = function (type, value) { | ||
switch (type) { | ||
case 'boolean': | ||
value = (value === 'true'); | ||
value = value === 'true'; | ||
break; | ||
@@ -21,0 +21,0 @@ |
@@ -9,4 +9,4 @@ /* eslint no-self-compare: 0 */ | ||
var isGraphConstructor = require('graphology-utils/is-graph-constructor'), | ||
mergeEdge = require('graphology-utils/add-edge').mergeEdge, | ||
helpers = require('../common/helpers.js'); | ||
mergeEdge = require('graphology-utils/add-edge').mergeEdge, | ||
helpers = require('../common/helpers.js'); | ||
@@ -33,9 +33,9 @@ var cast = helpers.cast; | ||
var a = element.getAttribute('a'), | ||
r = element.getAttribute('r'), | ||
g = element.getAttribute('g'), | ||
b = element.getAttribute('b'); | ||
r = element.getAttribute('r'), | ||
g = element.getAttribute('g'), | ||
b = element.getAttribute('b'); | ||
return a ? | ||
('rgba(' + r + ',' + g + ',' + b + ',' + a + ')') : | ||
('rgb(' + r + ',' + g + ',' + b + ')'); | ||
return a | ||
? 'rgba(' + r + ',' + g + ',' + b + ',' + a + ')' | ||
: 'rgb(' + r + ',' + g + ',' + b + ')'; | ||
} | ||
@@ -54,7 +54,5 @@ | ||
if (!vizElement) | ||
vizElement = element.getElementsByTagNameNS('viz', name)[0]; | ||
if (!vizElement) vizElement = element.getElementsByTagNameNS('viz', name)[0]; | ||
if (!vizElement) | ||
vizElement = element.getElementsByTagName(name)[0]; | ||
if (!vizElement) vizElement = element.getElementsByTagName(name)[0]; | ||
@@ -72,4 +70,4 @@ return vizElement; | ||
var meta = {}, | ||
element, | ||
value; | ||
element, | ||
value; | ||
@@ -79,9 +77,7 @@ for (var i = 0, l = elements.length; i < l; i++) { | ||
if (element.nodeName === '#text') | ||
continue; | ||
if (element.nodeName === '#text') continue; | ||
value = element.textContent.trim(); | ||
if (value) | ||
meta[element.tagName.toLowerCase()] = element.textContent; | ||
if (value) meta[element.tagName.toLowerCase()] = element.textContent; | ||
} | ||
@@ -100,6 +96,6 @@ | ||
var model = {}, | ||
defaults = {}, | ||
element, | ||
defaultElement, | ||
id; | ||
defaults = {}, | ||
element, | ||
defaultElement, | ||
id; | ||
@@ -113,5 +109,3 @@ for (var i = 0, l = elements.length; i < l; i++) { | ||
type: element.getAttribute('type') || 'string', | ||
title: !isReallyNaN(+id) ? | ||
(element.getAttribute('title') || id) : | ||
id | ||
title: !isReallyNaN(+id) ? element.getAttribute('title') || id : id | ||
}; | ||
@@ -142,21 +136,16 @@ | ||
var data = {}, | ||
label = element.getAttribute('label'), | ||
weight = element.getAttribute('weight'); | ||
label = element.getAttribute('label'), | ||
weight = element.getAttribute('weight'); | ||
if (label) | ||
data.label = label; | ||
if (label) data.label = label; | ||
if (weight) | ||
data.weight = +weight; | ||
if (weight) data.weight = +weight; | ||
var valueElements = element.getElementsByTagName('attvalue'), | ||
valueElement, | ||
id; | ||
valueElement, | ||
id; | ||
for (var i = 0, l = valueElements.length; i < l; i++) { | ||
valueElement = valueElements[i]; | ||
id = ( | ||
valueElement.getAttribute('id') || | ||
valueElement.getAttribute('for') | ||
); | ||
id = valueElement.getAttribute('id') || valueElement.getAttribute('for'); | ||
@@ -173,4 +162,3 @@ data[model[id].title] = cast( | ||
for (k in defaults) { | ||
if (!(k in data)) | ||
data[k] = defaults[k]; | ||
if (!(k in data)) data[k] = defaults[k]; | ||
} | ||
@@ -185,4 +173,3 @@ | ||
if (vizElement) | ||
data.color = toRGBString(vizElement); | ||
if (vizElement) data.color = toRGBString(vizElement); | ||
@@ -192,4 +179,3 @@ //-- 2) Size | ||
if (vizElement) | ||
data.size = +vizElement.getAttribute('value'); | ||
if (vizElement) data.size = +vizElement.getAttribute('value'); | ||
@@ -206,8 +192,5 @@ //-- 3) Position | ||
if (x) | ||
data.x = +x; | ||
if (y) | ||
data.y = +y; | ||
if (z) | ||
data.z = +z; | ||
if (x) data.x = +x; | ||
if (y) data.y = +y; | ||
if (z) data.z = +z; | ||
} | ||
@@ -218,4 +201,3 @@ | ||
if (vizElement) | ||
data.shape = vizElement.getAttribute('value'); | ||
if (vizElement) data.shape = vizElement.getAttribute('value'); | ||
@@ -225,4 +207,3 @@ //-- 5) Thickness | ||
if (vizElement) | ||
data.thickness = +vizElement.getAttribute('value'); | ||
if (vizElement) data.thickness = +vizElement.getAttribute('value'); | ||
@@ -237,3 +218,2 @@ return data; | ||
module.exports = function createParserFunction(DOMParser, Document) { | ||
/** | ||
@@ -252,11 +232,3 @@ * Function taking either a string or a document and returning a | ||
var element, | ||
result, | ||
type, | ||
attributes, | ||
id, | ||
s, | ||
t, | ||
i, | ||
l; | ||
var element, result, type, attributes, id, s, t, i, l; | ||
@@ -268,16 +240,18 @@ if (!isGraphConstructor(Graph)) | ||
if (typeof source === 'string') | ||
xmlDoc = (new DOMParser()).parseFromString(source, 'application/xml'); | ||
xmlDoc = new DOMParser().parseFromString(source, 'application/xml'); | ||
if (!(xmlDoc instanceof Document)) | ||
throw new Error('graphology-gexf/parser: source should either be a XML document or a string.'); | ||
throw new Error( | ||
'graphology-gexf/parser: source should either be a XML document or a string.' | ||
); | ||
// Finding useful elements | ||
var GRAPH_ELEMENT = xmlDoc.getElementsByTagName('graph')[0], | ||
META_ELEMENT = xmlDoc.getElementsByTagName('meta')[0], | ||
META_ELEMENTS = (META_ELEMENT && META_ELEMENT.childNodes) || [], | ||
NODE_ELEMENTS = xmlDoc.getElementsByTagName('node'), | ||
EDGE_ELEMENTS = xmlDoc.getElementsByTagName('edge'), | ||
MODEL_ELEMENTS = xmlDoc.getElementsByTagName('attributes'), | ||
NODE_MODEL_ELEMENTS = [], | ||
EDGE_MODEL_ELEMENTS = []; | ||
META_ELEMENT = xmlDoc.getElementsByTagName('meta')[0], | ||
META_ELEMENTS = (META_ELEMENT && META_ELEMENT.childNodes) || [], | ||
NODE_ELEMENTS = xmlDoc.getElementsByTagName('node'), | ||
EDGE_ELEMENTS = xmlDoc.getElementsByTagName('edge'), | ||
MODEL_ELEMENTS = xmlDoc.getElementsByTagName('attributes'), | ||
NODE_MODEL_ELEMENTS = [], | ||
EDGE_MODEL_ELEMENTS = []; | ||
@@ -294,6 +268,6 @@ for (i = 0, l = MODEL_ELEMENTS.length; i < l; i++) { | ||
// Information | ||
var DEFAULT_EDGE_TYPE = GRAPH_ELEMENT.getAttribute('defaultedgetype') || 'undirected'; | ||
var DEFAULT_EDGE_TYPE = | ||
GRAPH_ELEMENT.getAttribute('defaultedgetype') || 'undirected'; | ||
if (DEFAULT_EDGE_TYPE === 'mutual') | ||
DEFAULT_EDGE_TYPE = 'undirected'; | ||
if (DEFAULT_EDGE_TYPE === 'mutual') DEFAULT_EDGE_TYPE = 'undirected'; | ||
@@ -304,3 +278,3 @@ // Computing models | ||
var NODE_MODEL = result[0], | ||
NODE_DEFAULT_ATTRIBUTES = result[1]; | ||
NODE_DEFAULT_ATTRIBUTES = result[1]; | ||
@@ -310,8 +284,8 @@ result = extractModel(EDGE_MODEL_ELEMENTS); | ||
var EDGE_MODEL = result[0], | ||
EDGE_DEFAULT_ATTRIBUTES = result[1]; | ||
EDGE_DEFAULT_ATTRIBUTES = result[1]; | ||
// Polling the first edge to guess the type of the edges | ||
var graphType = EDGE_ELEMENTS[0] ? | ||
(EDGE_ELEMENTS[0].getAttribute('type') || DEFAULT_EDGE_TYPE) : | ||
'mixed'; | ||
var graphType = EDGE_ELEMENTS[0] | ||
? EDGE_ELEMENTS[0].getAttribute('type') || DEFAULT_EDGE_TYPE | ||
: 'mixed'; | ||
@@ -325,3 +299,4 @@ // Instantiating our graph | ||
var meta = collectMeta(META_ELEMENTS), | ||
lastModifiedDate = META_ELEMENT && META_ELEMENT.getAttribute('lastmodifieddate'); | ||
lastModifiedDate = | ||
META_ELEMENT && META_ELEMENT.getAttribute('lastmodifieddate'); | ||
@@ -351,3 +326,7 @@ graph.replaceAttributes(meta); | ||
t = element.getAttribute('target'); | ||
attributes = collectAttributes(EDGE_MODEL, EDGE_DEFAULT_ATTRIBUTES, element); | ||
attributes = collectAttributes( | ||
EDGE_MODEL, | ||
EDGE_DEFAULT_ATTRIBUTES, | ||
element | ||
); | ||
@@ -362,6 +341,4 @@ // If we encountered an edge with a different type, we upgrade the graph | ||
!graph.multi && | ||
( | ||
(type === 'directed' && graph.hasDirectedEdge(s, t)) || | ||
(graph.hasUndirectedEdge(s, t)) | ||
) | ||
((type === 'directed' && graph.hasDirectedEdge(s, t)) || | ||
graph.hasUndirectedEdge(s, t)) | ||
) { | ||
@@ -371,10 +348,3 @@ graph.upgradeToMulti(); | ||
mergeEdge( | ||
graph, | ||
type !== 'directed', | ||
id || null, | ||
s, | ||
t, | ||
attributes | ||
); | ||
mergeEdge(graph, type !== 'directed', id || null, s, t, attributes); | ||
} | ||
@@ -381,0 +351,0 @@ |
import {Attributes} from 'graphology-types'; | ||
type RGBAColor = { | ||
r: number, | ||
g: number, | ||
b: number, | ||
a?: number | ||
r: number; | ||
g: number; | ||
b: number; | ||
a?: number; | ||
}; | ||
type VizRecord = { | ||
color?: RGBAColor | string, | ||
size?: number, | ||
x?: number, | ||
y?: number, | ||
z?: number, | ||
shape?: string, | ||
thickness?: number | ||
color?: RGBAColor | string; | ||
size?: number; | ||
x?: number; | ||
y?: number; | ||
z?: number; | ||
shape?: string; | ||
thickness?: number; | ||
}; | ||
type FormattedNode<FormattedAttributes> = { | ||
label?: string, | ||
viz?: VizRecord, | ||
attributes?: FormattedAttributes | ||
label?: string; | ||
viz?: VizRecord; | ||
attributes?: FormattedAttributes; | ||
}; | ||
type FormattedEdge<FormattedAttributes> = { | ||
label?: string, | ||
viz?: VizRecord, | ||
weight?: number, | ||
attributes?: FormattedAttributes | ||
label?: string; | ||
viz?: VizRecord; | ||
weight?: number; | ||
attributes?: FormattedAttributes; | ||
}; | ||
@@ -36,3 +36,6 @@ | ||
FormattedAttributes extends Attributes = Attributes | ||
> = (key: string, attributes: NodeAttributes) => FormattedNode<FormattedAttributes>; | ||
> = ( | ||
key: string, | ||
attributes: NodeAttributes | ||
) => FormattedNode<FormattedAttributes>; | ||
@@ -42,3 +45,6 @@ export type EdgeFormatter< | ||
FormattedAttributes extends Attributes = Attributes | ||
> = (key: string, attributes: EdgeAttributes) => FormattedEdge<FormattedAttributes>; | ||
> = ( | ||
key: string, | ||
attributes: EdgeAttributes | ||
) => FormattedEdge<FormattedAttributes>; | ||
@@ -51,6 +57,6 @@ export type GexfWriterOptions< | ||
> = { | ||
encoding?: string, | ||
pretty?: boolean, | ||
formatNode?: NodeFormatter<NodeAttributes, FormattedNodeAttributes>, | ||
formatEdge?: EdgeFormatter<EdgeAttributes, FormattedEdgeAttributes> | ||
encoding?: string; | ||
pretty?: boolean; | ||
formatNode?: NodeFormatter<NodeAttributes, FormattedNodeAttributes>; | ||
formatEdge?: EdgeFormatter<EdgeAttributes, FormattedEdgeAttributes>; | ||
}; |
@@ -9,5 +9,5 @@ /* eslint no-self-compare: 0 */ | ||
var isGraph = require('graphology-utils/is-graph'), | ||
inferType = require('graphology-utils/infer-type'), | ||
XMLWriter = require('xml-writer'), | ||
sanitizeTagName = require('./helpers.js').sanitizeTagName; | ||
inferType = require('graphology-utils/infer-type'), | ||
XMLWriter = require('xml-writer'), | ||
sanitizeTagName = require('./helpers.js').sanitizeTagName; | ||
@@ -20,3 +20,3 @@ // TODO: handle object in color, position with object for viz | ||
var GEXF_NAMESPACE = 'http://www.gexf.net/1.2draft', | ||
GEXF_VIZ_NAMESPACE = 'http:///www.gexf.net/1.1draft/viz'; | ||
GEXF_VIZ_NAMESPACE = 'http:///www.gexf.net/1.1draft/viz'; | ||
@@ -34,3 +34,4 @@ var VIZ_RESERVED_NAMES = new Set([ | ||
var RGBA_TEST = /^\s*rgba?\s*\(/i, | ||
RGBA_MATCH = /^\s*rgba?\s*\(\s*([0-9]*)\s*,\s*([0-9]*)\s*,\s*([0-9]*)\s*(?:,\s*([.0-9]*))?\)\s*$/; | ||
RGBA_MATCH = | ||
/^\s*rgba?\s*\(\s*([0-9]*)\s*,\s*([0-9]*)\s*,\s*([0-9]*)\s*(?:,\s*([.0-9]*))?\)\s*$/; | ||
@@ -44,4 +45,3 @@ /** | ||
function CSSColorToRGBA(value) { | ||
if (!value || typeof value !== 'string') | ||
return {}; | ||
if (!value || typeof value !== 'string') return {}; | ||
@@ -51,15 +51,14 @@ if (value[0] === '#') { | ||
return (value.length === 3) ? | ||
{ | ||
r: parseInt(value[0] + value[0], 16), | ||
g: parseInt(value[1] + value[1], 16), | ||
b: parseInt(value[2] + value[2], 16) | ||
} : | ||
{ | ||
r: parseInt(value[0] + value[1], 16), | ||
g: parseInt(value[2] + value[3], 16), | ||
b: parseInt(value[4] + value[5], 16) | ||
}; | ||
} | ||
else if (RGBA_TEST.test(value)) { | ||
return value.length === 3 | ||
? { | ||
r: parseInt(value[0] + value[0], 16), | ||
g: parseInt(value[1] + value[1], 16), | ||
b: parseInt(value[2] + value[2], 16) | ||
} | ||
: { | ||
r: parseInt(value[0] + value[1], 16), | ||
g: parseInt(value[2] + value[3], 16), | ||
b: parseInt(value[4] + value[5], 16) | ||
}; | ||
} else if (RGBA_TEST.test(value)) { | ||
var result = {}; | ||
@@ -72,4 +71,3 @@ | ||
if (value[4]) | ||
result.a = +value[4]; | ||
if (value[4]) result.a = +value[4]; | ||
@@ -93,3 +91,3 @@ return result; | ||
var output = {}, | ||
name; | ||
name; | ||
@@ -99,11 +97,8 @@ for (name in attributes) { | ||
output.label = attributes.label; | ||
} | ||
else if (type === 'edge' && name === 'weight') { | ||
} else if (type === 'edge' && name === 'weight') { | ||
output.weight = attributes.weight; | ||
} | ||
else if (VIZ_RESERVED_NAMES.has(name)) { | ||
} else if (VIZ_RESERVED_NAMES.has(name)) { | ||
output.viz = output.viz || {}; | ||
output.viz[name] = attributes[name]; | ||
} | ||
else { | ||
} else { | ||
output.attributes = output.attributes || {}; | ||
@@ -118,3 +113,3 @@ output.attributes[name] = attributes[name]; | ||
var DEFAULT_NODE_FORMATTER = DEFAULT_ELEMENT_FORMATTER.bind(null, 'node'), | ||
DEFAULT_EDGE_FORMATTER = DEFAULT_ELEMENT_FORMATTER.bind(null, 'edge'); | ||
DEFAULT_EDGE_FORMATTER = DEFAULT_ELEMENT_FORMATTER.bind(null, 'edge'); | ||
@@ -128,3 +123,3 @@ /** | ||
function is32BitInteger(number) { | ||
return number <= 0x7FFFFFFF && number >= -0x7FFFFFFF; | ||
return number <= 0x7fffffff && number >= -0x7fffffff; | ||
} | ||
@@ -154,21 +149,14 @@ | ||
function detectValueType(value) { | ||
if (isEmptyValue(value)) return 'empty'; | ||
if (isEmptyValue(value)) | ||
return 'empty'; | ||
if (Array.isArray(value)) return 'liststring'; | ||
if (Array.isArray(value)) | ||
return 'liststring'; | ||
if (typeof value === 'boolean') return 'boolean'; | ||
if (typeof value === 'boolean') | ||
return 'boolean'; | ||
if (typeof value === 'object') return 'string'; | ||
if (typeof value === 'object') | ||
return 'string'; | ||
// Numbers | ||
if (typeof value === 'number') { | ||
// Integer | ||
if (value === (value | 0)) { | ||
// Long (JavaScript integer can go up to 53 bit)? | ||
@@ -193,4 +181,3 @@ return is32BitInteger(value) ? 'integer' : 'long'; | ||
function cast(type, value) { | ||
if (type === 'liststring' && Array.isArray(value)) | ||
return value.join('|'); | ||
if (type === 'liststring' && Array.isArray(value)) return value.join('|'); | ||
return '' + value; | ||
@@ -210,3 +197,3 @@ } | ||
graph.forEachNode(function(node, attr) { | ||
graph.forEachNode(function (node, attr) { | ||
var data = format(node, attr); | ||
@@ -231,3 +218,11 @@ data.key = node; | ||
graph.forEachEdge(function(edge, attr, source, target, _sa, _ta, undirected) { | ||
graph.forEachEdge(function ( | ||
edge, | ||
attr, | ||
source, | ||
target, | ||
_sa, | ||
_ta, | ||
undirected | ||
) { | ||
var data = reducer(edge, attr); | ||
@@ -254,5 +249,5 @@ data.key = edge; | ||
var model = {}, | ||
attributes, | ||
type, | ||
k; | ||
attributes, | ||
type, | ||
k; | ||
@@ -263,4 +258,3 @@ // Testing every attributes | ||
if (!attributes) | ||
continue; | ||
if (!attributes) continue; | ||
@@ -270,12 +264,8 @@ for (k in attributes) { | ||
if (type === 'empty') | ||
continue; | ||
if (type === 'empty') continue; | ||
if (!model[k]) | ||
model[k] = type; | ||
if (!model[k]) model[k] = type; | ||
else { | ||
if (model[k] === 'integer' && type === 'long') | ||
model[k] = type; | ||
else if (model[k] !== type) | ||
model[k] = 'string'; | ||
if (model[k] === 'integer' && type === 'long') model[k] = type; | ||
else if (model[k] !== type) model[k] = 'string'; | ||
} | ||
@@ -299,4 +289,3 @@ } | ||
if (!Object.keys(model).length) | ||
return; | ||
if (!Object.keys(model).length) return; | ||
@@ -319,13 +308,13 @@ writer.startElement('attributes'); | ||
var emptyModel = !Object.keys(model).length, | ||
element, | ||
name, | ||
color, | ||
value, | ||
edgeType, | ||
attributes, | ||
weight, | ||
viz, | ||
k, | ||
i, | ||
l; | ||
element, | ||
name, | ||
color, | ||
value, | ||
edgeType, | ||
attributes, | ||
weight, | ||
viz, | ||
k, | ||
i, | ||
l; | ||
@@ -353,8 +342,10 @@ writer.startElement(type + 's'); | ||
if ((typeof weight === 'number' && !isNaN(weight)) || typeof weight === 'string') | ||
if ( | ||
(typeof weight === 'number' && !isNaN(weight)) || | ||
typeof weight === 'string' | ||
) | ||
writer.writeAttribute('weight', element.weight); | ||
} | ||
if (element.label) | ||
writer.writeAttribute('label', element.label); | ||
if (element.label) writer.writeAttribute('label', element.label); | ||
@@ -368,4 +359,3 @@ if (!emptyModel && attributes) { | ||
if (isEmptyValue(value)) | ||
continue; | ||
if (isEmptyValue(value)) continue; | ||
@@ -383,3 +373,2 @@ writer.startElement('attvalue'); | ||
if (viz) { | ||
//-- 1) Color | ||
@@ -391,4 +380,3 @@ if (viz.color) { | ||
for (k in color) | ||
writer.writeAttribute(k, color[k]); | ||
for (k in color) writer.writeAttribute(k, color[k]); | ||
@@ -409,10 +397,7 @@ writer.endElement(); | ||
if ('x' in viz) | ||
writer.writeAttribute('x', viz.x); | ||
if ('x' in viz) writer.writeAttribute('x', viz.x); | ||
if ('y' in viz) | ||
writer.writeAttribute('y', viz.y); | ||
if ('y' in viz) writer.writeAttribute('y', viz.y); | ||
if ('z' in viz) | ||
writer.writeAttribute('z', viz.z); | ||
if ('z' in viz) writer.writeAttribute('z', viz.z); | ||
@@ -473,3 +458,3 @@ writer.endElement(); | ||
var formatNode = options.formatNode || DEFAULTS.formatNode, | ||
formatEdge = options.formatEdge || DEFAULTS.formatEdge; | ||
formatEdge = options.formatEdge || DEFAULTS.formatEdge; | ||
@@ -496,9 +481,7 @@ var writer = new XMLWriter(indent); | ||
for (var k in graphAttributes) { | ||
if (k === 'lastModifiedDate') | ||
continue; | ||
if (k === 'lastModifiedDate') continue; | ||
metaTagName = sanitizeTagName(k); | ||
if (!metaTagName) | ||
continue; | ||
if (!metaTagName) continue; | ||
@@ -513,14 +496,9 @@ writer.writeElement(metaTagName, graphAttributes[k]); | ||
writer.defaultEdgeType = type === 'mixed' ? | ||
'directed' : | ||
type; | ||
writer.defaultEdgeType = type === 'mixed' ? 'directed' : type; | ||
writer.writeAttribute( | ||
'defaultedgetype', | ||
writer.defaultEdgeType | ||
); | ||
writer.writeAttribute('defaultedgetype', writer.defaultEdgeType); | ||
// Processing model | ||
var nodes = collectNodeData(graph, formatNode), | ||
edges = collectEdgeData(graph, formatEdge); | ||
edges = collectEdgeData(graph, formatEdge); | ||
@@ -527,0 +505,0 @@ var nodeModel = inferModel(nodes); |
@@ -8,3 +8,6 @@ import Graph, {Attributes, GraphConstructor} from 'graphology-types'; | ||
GraphAttributes extends Attributes = Attributes | ||
>(Graph: GraphConstructor<NodeAttributes, EdgeAttributes, GraphAttributes>, source: string | Document): Graph<NodeAttributes, EdgeAttributes, GraphAttributes>; | ||
>( | ||
Graph: GraphConstructor<NodeAttributes, EdgeAttributes, GraphAttributes>, | ||
source: string | Document | ||
): Graph<NodeAttributes, EdgeAttributes, GraphAttributes>; | ||
@@ -18,3 +21,8 @@ export function write< | ||
graph: Graph<NodeAttributes, EdgeAttributes>, | ||
options?: GexfWriterOptions<NodeAttributes, EdgeAttributes, FormattedNodeAttributes, FormattedEdgeAttributes> | ||
options?: GexfWriterOptions< | ||
NodeAttributes, | ||
EdgeAttributes, | ||
FormattedNodeAttributes, | ||
FormattedEdgeAttributes | ||
> | ||
): string; |
@@ -7,11 +7,8 @@ /** | ||
*/ | ||
var xmldom = require('xmldom'), | ||
createParserFunction = require('../common/parser.js'); | ||
var xmldom = require('@xmldom/xmldom'); | ||
var createParserFunction = require('../common/parser.js'); | ||
var doc = (new xmldom.DOMParser()).parseFromString('<t></t>', 'application/xml'); | ||
var doc = new xmldom.DOMParser().parseFromString('<t></t>', 'application/xml'); | ||
exports.parse = createParserFunction( | ||
xmldom.DOMParser, | ||
doc.constructor | ||
); | ||
exports.parse = createParserFunction(xmldom.DOMParser, doc.constructor); | ||
exports.write = require('../common/writer.js'); |
{ | ||
"name": "graphology-gexf", | ||
"version": "0.8.1", | ||
"version": "0.9.0", | ||
"description": "GEXF parser & writer for graphology.", | ||
@@ -15,4 +15,3 @@ "main": "index.js", | ||
"scripts": { | ||
"lint": "eslint ./**/*.js", | ||
"prepublishOnly": "npm run lint && npm test", | ||
"prepublishOnly": "npm test", | ||
"test:browser": "mocha ./test/browser/endpoint.js", | ||
@@ -23,3 +22,3 @@ "test": "npm run test:browser" | ||
"type": "git", | ||
"url": "git+https://github.com/graphology/graphology-gexf.git" | ||
"url": "git+https://github.com/graphology/graphology.git" | ||
}, | ||
@@ -37,5 +36,5 @@ "keywords": [ | ||
"bugs": { | ||
"url": "https://github.com/graphology/graphology-gexf/issues" | ||
"url": "https://github.com/graphology/graphology/issues" | ||
}, | ||
"homepage": "https://github.com/graphology/graphology-gexf#readme", | ||
"homepage": "https://github.com/graphology/graphology#readme", | ||
"peerDependencies": { | ||
@@ -47,7 +46,4 @@ "graphology-types": ">=0.20.0" | ||
"xml-writer": "^1.7.0", | ||
"xmldom": "^0.6.0" | ||
}, | ||
"eslintConfig": { | ||
"extends": "@yomguithereal/eslint-config" | ||
"@xmldom/xmldom": "^0.7.5" | ||
} | ||
} |
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
0
1
31062
836
+ Added@xmldom/xmldom@^0.7.5
+ Added@xmldom/xmldom@0.7.13(transitive)
- Removedxmldom@^0.6.0
- Removedxmldom@0.6.0(transitive)