bbop-graph
Advanced tools
Comparing version 0.0.17 to 0.0.18
@@ -90,7 +90,7 @@ /** | ||
* | ||
* @param {any} value - (optional) new value for this property to take | ||
* @returns {any} value | ||
* @param {Object} value - (optional) new value for this property to take; only objects (not Arrays) | ||
* @returns {Object|null} value | ||
*/ | ||
node.prototype.metadata = function(value){ | ||
if( typeof(value) !== 'undefined' ){ | ||
if( us.isObject(value) && ! us.isArray(value) ){ | ||
this._metadata = value; | ||
@@ -235,14 +235,14 @@ } | ||
* Getter/setter for edge metadata. | ||
* | ||
* The metadata value does not necessarily have to be an atomic type. | ||
* | ||
* The metadata value does not necessarily have to be an atomic type. | ||
* | ||
* @param {any} value - (optional) new value for this property to take | ||
* @returns {any} value | ||
* @param {Object} value - (optional) new value for this property to take; only objects (not Arrays) | ||
* @returns {Object|null} value | ||
*/ | ||
edge.prototype.metadata = function(value){ | ||
if( typeof(value) !== 'undefined' ){ | ||
if( us.isObject(value) && ! us.isArray(value) ){ | ||
this._metadata = value; | ||
} | ||
return this._metadata; | ||
}; | ||
}; | ||
@@ -299,2 +299,3 @@ /** | ||
this._id = null; | ||
this._metadata = null; | ||
@@ -360,2 +361,17 @@ // A per-graph logger. | ||
/** | ||
* Getter/setter for graph metadata. | ||
* | ||
* The metadata value does not necessarily have to be an atomic type. | ||
* | ||
* @param {Object} value - (optional) new value for this property to take; only objects (not Arrays) | ||
* @returns {Object|null} value | ||
*/ | ||
graph.prototype.metadata = function(value){ | ||
if( us.isObject(value) && ! us.isArray(value) ){ | ||
this._metadata = value; | ||
} | ||
return this._metadata; | ||
}; | ||
/** | ||
* Create a clone of the graph. | ||
@@ -384,2 +400,5 @@ * | ||
// Meta. | ||
new_graph.metadata(bbop.clone(this.metadata())); | ||
return new_graph; | ||
@@ -1352,4 +1371,5 @@ }; | ||
* | ||
* TODO: a work in progress 'type' not currently imported (just as | ||
* not exported); actually, a lot not imported. | ||
* TODO: a work in progress 'type' not currently imported (just as not | ||
* exported); actually, a lot not imported. No graph metadata is | ||
* imported. | ||
* | ||
@@ -1396,3 +1416,3 @@ * This is meant to be an minimal importer for a minimal | ||
* TODO: a work in progress; 'type' not currently exported (just as | ||
* not imported) | ||
* not imported). No graph metadata is exported either. | ||
* | ||
@@ -1399,0 +1419,0 @@ * @returns {object} - an object that can be converted to a JSON string by dumping. |
{ | ||
"name": "bbop-graph", | ||
"version": "0.0.17", | ||
"version": "0.0.18", | ||
"license": "BSD-3-Clause", | ||
@@ -5,0 +5,0 @@ "description": "General purpose (mathematical) graph library in JavaScript.", |
@@ -589,2 +589,3 @@ //// | ||
g.default_predicate = 'pred'; | ||
g.metadata({foo: 'bar'}); | ||
g.add_node(n1); | ||
@@ -606,2 +607,6 @@ g.add_node(n2); | ||
'clone has dupe edges'); | ||
assert.deepEqual(g.metadata(), g_clone.metadata(), | ||
'clone has dupe metadata'); | ||
assert.deepEqual(g.metadata(), {foo: 'bar'}, | ||
'metadata is correct'); | ||
}); | ||
@@ -608,0 +613,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
6290872
50
25895