bbop-graph
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -12,6 +12,9 @@ //// | ||
var bump = require('gulp-bump'); | ||
//var pandoc = require('gulp-pandoc'); | ||
var paths = { | ||
readme: ['./README.md'], | ||
tests: ['tests/*.test.js', 'tests/*.tests.js'], | ||
docable: ['lib/*.js'] | ||
docable: ['lib/*.js', './README.md'], | ||
transients:['./doc/*', '!./doc/README.org'] | ||
}; | ||
@@ -29,4 +32,26 @@ | ||
// Build docs directory with JSDoc. | ||
gulp.task('doc', function() { | ||
gulp.src(paths.docable) | ||
//gulp.task('doc', ['md-to-org', 'jsdoc']); | ||
gulp.task('doc', ['jsdoc']); | ||
// // Convert README.org to a README.md for JSDoc to use as an index. | ||
// // TODO: My pandoc does not support the org reader yet, so di it the other way | ||
// // for now | ||
// //gulp.task('org-to-md', function() { | ||
// gulp.task('md-to-org', function() { | ||
// gulp.src('./README.md') | ||
// //gulp.src('./README.org') | ||
// .pipe(pandoc({ | ||
// // from: 'orgmode', | ||
// // to: 'markdown', | ||
// from: 'markdown', | ||
// to: 'orgmode', | ||
// ext: '.org', | ||
// args: ['--smart'] | ||
// })) | ||
// .pipe(gulp.dest('./')); | ||
// }); | ||
// Build docs directory with JSDoc. | ||
gulp.task('jsdoc', function() { | ||
gulp.src(paths.docable, paths.readme) | ||
.pipe(jsdoc('./doc')); | ||
@@ -37,3 +62,3 @@ }); | ||
gulp.task('clean', function(cb) { | ||
del(['./doc/*', '!./doc/README.org']); | ||
del(paths.transients); | ||
}); | ||
@@ -83,2 +108,8 @@ | ||
// Rerun doc build when a file changes. | ||
gulp.task('watch-doc', function() { | ||
gulp.watch(paths.docable, ['doc']); | ||
gulp.watch(paths.readme, ['doc']); | ||
}); | ||
// The default task (called when you run `gulp` from cli) | ||
@@ -85,0 +116,0 @@ //gulp.task('default', ['watch', 'scripts', 'images']); |
234
lib/graph.js
@@ -36,3 +36,3 @@ /** | ||
/// | ||
/// Node sub-object. | ||
/// Node sub-object. | ||
/// | ||
@@ -43,8 +43,6 @@ | ||
* | ||
* @constructor node | ||
* | ||
* @param {} new_id - a unique id for the node | ||
* @param {} new_label - *[optional]* a user-friendly description of the node | ||
* | ||
* @returns {} bbop model node | ||
* @constructor | ||
* @param {string} new_id - a unique id for the node | ||
* @param {string} new_label - (optional) a user-friendly description of the node | ||
* @returns {node} new bbop model node | ||
*/ | ||
@@ -66,21 +64,16 @@ function node(new_id, new_label){ | ||
/** | ||
* Function: id | ||
* | ||
* Getter/setter for node id. | ||
* | ||
* @param {} value - *[optional]* new value for this property to take | ||
* | ||
* @returns {} string | ||
* @param {string} value - (optional) new value for this property to take | ||
* @returns {string} string | ||
*/ | ||
node.prototype.id = function(value){ | ||
if(value) this._id = value; return this._id; }; | ||
if(value) this._id = value; return this._id; | ||
}; | ||
/** | ||
* Function: type | ||
* | ||
* Getter/setter for node type. | ||
* | ||
* @param {} value - *[optional]* new value for this property to take | ||
* | ||
* @returns {} string | ||
* @param {string} value - (optional) new value for this property to take | ||
* @returns {string} string | ||
*/ | ||
@@ -91,16 +84,12 @@ node.prototype.type = function(value){ | ||
/** | ||
* Function: label | ||
* | ||
* Getter/setter for node label. | ||
* | ||
* @param {} value - *[optional]* new value for this property to take | ||
* | ||
* @returns {} string | ||
* @param {string} value - (optional) new value for this property to take | ||
* @returns {string} string | ||
*/ | ||
node.prototype.label = function(value){ | ||
if(value) this._label = value; return this._label; }; | ||
if(value) this._label = value; return this._label; | ||
}; | ||
/** | ||
* Function: metadata | ||
* | ||
* Getter/setter for node metadata. | ||
@@ -110,16 +99,14 @@ * | ||
* | ||
* @param {} value - *[optional]* new value for this property to take | ||
* | ||
* @returns {} value | ||
* @param {any} value - (optional) new value for this property to take | ||
* @returns {any} value | ||
*/ | ||
node.prototype.metadata = function(value){ | ||
if(value) this._metadata = value; return this._metadata; }; | ||
if(value) this._metadata = value; return this._metadata; | ||
}; | ||
/** | ||
* Function: clone | ||
* | ||
* Get a fresh new copy of the current node (using bbop.clone for | ||
* metadata object). | ||
* | ||
* @returns {} string | ||
* @returns {node} node | ||
*/ | ||
@@ -134,5 +121,4 @@ node.prototype.clone = function(){ | ||
/// | ||
/// Edge sub-object. | ||
/// Edge sub-object. | ||
/// | ||
@@ -146,9 +132,7 @@ | ||
* | ||
* @constructor edge | ||
* | ||
* @param {} subject - node id string or node | ||
* @param {} object - node id string or node | ||
* @param {} predicate - *[optional]* a user-friendly description of the node | ||
* | ||
* @returns {} bbop model edge | ||
* @constructor | ||
* @param {string} subject - node id string or node | ||
* @param {string} object - node id string or node | ||
* @param {string} predicate - (optional) a user-friendly description of the node | ||
* @returns {edge} bbop model edge | ||
*/ | ||
@@ -191,33 +175,23 @@ function edge(subject, object, predicate){ | ||
/** | ||
* Function: subject_id | ||
* | ||
* Getter/setter for edge subject id. | ||
* | ||
* @param {} value - *[optional]* new value for this property to take | ||
* | ||
* @returns {} string | ||
* @returns {string} string | ||
*/ | ||
edge.prototype.subject_id = function(){ | ||
return this._subject_id; }; | ||
return this._subject_id; | ||
}; | ||
/** | ||
* Function: object_id | ||
* | ||
* Getter/setter for edge object id. | ||
* | ||
* @param {} value - *[optional]* new value for this property to take | ||
* | ||
* @returns {} string | ||
* @returns {string} string | ||
*/ | ||
edge.prototype.object_id = function(){ | ||
return this._object_id; }; | ||
return this._object_id; | ||
}; | ||
/** | ||
* Function: predicate_id | ||
* | ||
* Getter/setter for edge predicate id. | ||
* | ||
* @param {} value - *[optional]* new value for this property to take | ||
* | ||
* @returns {} string | ||
* @returns {string} string | ||
*/ | ||
@@ -228,8 +202,5 @@ edge.prototype.predicate_id = function(){ | ||
/** | ||
* Function: type | ||
* | ||
* Getter/setter for edge type. | ||
* | ||
* @param {} value - *[optional]* new value for this property to take | ||
* | ||
* @param {} value - (optional) new value for this property to take | ||
* @returns {} string | ||
@@ -241,4 +212,2 @@ */ | ||
/** | ||
* Function: metadata | ||
* | ||
* Getter/setter for edge metadata. | ||
@@ -248,5 +217,4 @@ * | ||
* | ||
* @param {} value - *[optional]* new value for this property to take | ||
* | ||
* @returns {} value | ||
* @param {any} value - (optional) new value for this property to take | ||
* @returns {any} value | ||
*/ | ||
@@ -257,8 +225,6 @@ edge.prototype.metadata = function(value){ | ||
/** | ||
* Function: clone | ||
* | ||
* Get a fresh new copy of the current edge (using bbop.clone for | ||
* metadata object). | ||
* | ||
* @returns {} string | ||
* @returns {edge} - new copy of edge | ||
*/ | ||
@@ -275,3 +241,3 @@ edge.prototype.clone = function(){ | ||
/// | ||
/// Graph sub-object. | ||
/// Graph sub-object. | ||
/// | ||
@@ -284,5 +250,4 @@ | ||
* | ||
* @constructor graph | ||
* | ||
* @returns {} bbop model node | ||
* @constructor | ||
* @returns {graph} bbop model graph | ||
*/ | ||
@@ -329,11 +294,7 @@ function graph(){ | ||
/** | ||
* Function: id | ||
* | ||
* Getter/setter for the graph id. | ||
* | ||
* @param {} value - *[optional]* new value for this property to take | ||
* | ||
* @returns {} string | ||
* @param {string} value - (optional) new value for this property to take | ||
* @returns {string} string | ||
*/ | ||
@@ -345,4 +306,2 @@ graph.prototype.id = function(value){ | ||
/** | ||
* Function: add_node | ||
* | ||
* Add a node to the graph. | ||
@@ -380,4 +339,2 @@ * | ||
/** | ||
* Function: add_edge | ||
* | ||
* Add an edge to the graph. | ||
@@ -444,4 +401,2 @@ * | ||
/** | ||
* Function: all_nodes | ||
* | ||
* Returns an /original/ list of all added nodes. | ||
@@ -456,4 +411,2 @@ * | ||
/** | ||
* Function: all_edges | ||
* | ||
* Returns an /original/ list of all added edges. | ||
@@ -468,4 +421,2 @@ * | ||
/** | ||
* Function: all_predicates | ||
* | ||
* Returns an /original/ list of all added predicates. | ||
@@ -480,4 +431,2 @@ * | ||
/** | ||
* Function: all_dangling | ||
* | ||
* List all external nodes by referenced id. | ||
@@ -499,4 +448,2 @@ * | ||
/** | ||
* Function: is_complete | ||
* | ||
* Any bad parts in graph? Essentially, make sure that there are no | ||
@@ -516,9 +463,6 @@ * weird references and nothing is dangling. | ||
/** | ||
* Function: get_node | ||
* | ||
* Return a /copy/ of a node by id (not the original) if extant. | ||
* | ||
* @param {} nid - the id of the node we're looking for | ||
* | ||
* @returns {} <node> | ||
* @param {string} nid - the id of the node we're looking for | ||
* @returns {node} - copy of bbop model node | ||
*/ | ||
@@ -535,11 +479,9 @@ graph.prototype.get_node = function(nid){ | ||
/** | ||
* Function: get_edge | ||
* | ||
* Return a /copy/ of an edge by ids (not the original) if extant. | ||
* | ||
* @param {} sub_id - the subject_id of the edge we're looking for | ||
* @param {} obj_id - the object_id of the edge we're looking for | ||
* @param {} pred - *[optional]* the predicate of the edge we're looking for | ||
* @param {string} sub_id - the subject_id of the edge we're looking for | ||
* @param {string} obj_id - the object_id of the edge we're looking for | ||
* @param {string} pred - (optional) the predicate of the edge we're looking for | ||
* | ||
* @returns {} <edge> | ||
* @returns {edge} - copy of bbop model edge | ||
*/ | ||
@@ -561,10 +503,7 @@ graph.prototype.get_edge = function(sub_id, obj_id, pred){ | ||
/** | ||
* Function: get_edges | ||
* | ||
* Return all edges (copies) of given subject and object ids. Returns | ||
* entirely new edges. | ||
* | ||
* @param {} sub_id - the subject_id of the edge we're looking for | ||
* @param {} obj_id - the object_id of the edge we're looking for | ||
* | ||
* @param {string} sub_id - the subject_id of the edge we're looking for | ||
* @param {string} obj_id - the object_id of the edge we're looking for | ||
* @returns {} list of <edge> | ||
@@ -587,9 +526,6 @@ */ | ||
/** | ||
* Function: get_predicates | ||
* | ||
* Return all predicates of given subject and object ids. | ||
* | ||
* @param {} sub_id - the subject_id of the edge we're looking for | ||
* @param {} obj_id - the object_id of the edge we're looking for | ||
* | ||
* @param {string} sub_id - the subject_id of the edge we're looking for | ||
* @param {string} obj_id - the object_id of the edge we're looking for | ||
* @returns {} list of predicate ids (as strings) | ||
@@ -610,4 +546,2 @@ */ | ||
/** | ||
* Function: edges_to_nodes | ||
* | ||
* Translate an edge array into extant (node) bodies, switching on | ||
@@ -622,3 +556,2 @@ * either 'subject' or 'object'. | ||
* @param {} target - 'subject' or 'object' | ||
* | ||
* @returns {} array of <node> | ||
@@ -657,10 +590,7 @@ */ | ||
/** | ||
* Function: is_root_node | ||
* | ||
* Roots are defined as nodes who are the subject of nothing, | ||
* independent of predicate. | ||
* | ||
* @param {} nb_id - id of the node to check | ||
* | ||
* @returns {} boolean | ||
* @param {string} nb_id - id of the node to check | ||
* @returns {boolean} - boolean | ||
*/ | ||
@@ -678,4 +608,2 @@ graph.prototype.is_root_node = function(nb_id){ | ||
/** | ||
* Function: get_root_nodes | ||
* | ||
* Return a list of /copies/ of the root nodes. | ||
@@ -700,10 +628,7 @@ * | ||
/** | ||
* Function: is_leaf_node | ||
* | ||
* Leaves are defined as nodes who are the object of nothing, | ||
* independent of predicate. | ||
* | ||
* @param {} nb_id - id of the node to check | ||
* | ||
* @returns {} boolean | ||
* @param {string} nb_id - id of the node to check | ||
* @returns {boolean} - boolean | ||
*/ | ||
@@ -721,4 +646,2 @@ graph.prototype.is_leaf_node = function(nb_id){ | ||
/** | ||
* Function: get_leaf_nodes | ||
* | ||
* Return a list of /copies/ of the leaf nodes. | ||
@@ -742,4 +665,2 @@ * | ||
/** | ||
* Function: get_singleton_nodes | ||
* | ||
* Find nodes that are roots and leaves over all relations. This | ||
@@ -766,4 +687,2 @@ * returns the /original/ node. | ||
/** | ||
* Function: get_parent_edges | ||
* | ||
* Return all parent edges; the /originals/. If no predicate is given, | ||
@@ -775,4 +694,3 @@ * use the default one. | ||
* @param {} nb_id - the node to consider | ||
* @param {} in_pred - *[optional]* over this predicate | ||
* | ||
* @param {} in_pred - (optional) over this predicate | ||
* @returns {} array of <edge> | ||
@@ -813,4 +731,2 @@ */ | ||
/** | ||
* Function: get_parent_nodes | ||
* | ||
* Return all parent nodes; the /originals/. If no predicate is given, | ||
@@ -820,3 +736,3 @@ * use the default one. | ||
* @param {} nb_id - the node to consider | ||
* @param {} in_pred - *[optional]* over this predicate | ||
* @param {} in_pred - (optional) over this predicate | ||
* | ||
@@ -842,10 +758,7 @@ * @returns {} array of <node> | ||
/** | ||
* Function: get_child_nodes | ||
* | ||
* Return all child nodes; the /originals/. If no predicate is given, | ||
* use the default one. | ||
* | ||
* @param {} nb_id - the node to consider | ||
* @param {} in_pred - *[optional]* over this predicate | ||
* | ||
* @param {string} nb_id - the node to consider | ||
* @param {string} in_pred - (optional) over this predicate | ||
* @returns {} array of <node> | ||
@@ -890,11 +803,8 @@ */ | ||
/** | ||
* Function: get_ancestor_subgraph | ||
* | ||
* Return new ancestors subgraph. Single id or id list as first | ||
* argument. Predicate string/id as optional second. | ||
* | ||
* @param {} nb_id_or_list - the node id(s) to consider | ||
* @param {} pid - *[optional]* over this predicate | ||
* | ||
* @returns {} <graph> | ||
* @param {string|list} nb_id_or_list - the node id(s) to consider | ||
* @param {string} pid - (optional) over this predicate | ||
* @returns {graph} new bbop model graph | ||
*/ | ||
@@ -984,4 +894,2 @@ graph.prototype.get_ancestor_subgraph = function(nb_id_or_list, pid){ | ||
/** | ||
* Function: merge_in | ||
* | ||
* Add a graph to the current graph, without sharing any of the merged | ||
@@ -993,5 +901,4 @@ * in graph's structure. | ||
* | ||
* @param {} graph | ||
* | ||
* @returns {} true; side-effects: more graph | ||
* @param {graph} - graph | ||
* @returns {boolean} - true; side-effects: more graph | ||
*/ | ||
@@ -1018,4 +925,2 @@ graph.prototype.merge_in = function(in_graph){ | ||
/** | ||
* Function: load_json | ||
* | ||
* Load the graph from the specified JSON object (not string). | ||
@@ -1026,5 +931,4 @@ * | ||
* | ||
* @param {} JSON object | ||
* | ||
* @returns {} true; side-effects: creates the graph internally | ||
* @param {object} - JSON object | ||
* @returns {boolean} - true; side-effects: creates the graph internally | ||
*/ | ||
@@ -1061,4 +965,2 @@ graph.prototype.load_json = function(json_object){ | ||
/** | ||
* Function: to_json | ||
* | ||
* Dump out the graph into a JSON-able object. | ||
@@ -1069,3 +971,3 @@ * | ||
* | ||
* @returns {} An object that can be converted to a JSON string by dumping. | ||
* @returns {object} - an object that can be converted to a JSON string by dumping. | ||
*/ | ||
@@ -1072,0 +974,0 @@ graph.prototype.to_json = function(){ |
{ | ||
"name": "bbop-graph", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"license": "BSD-3-Clause", | ||
@@ -41,2 +41,3 @@ "description": "General purpose (mathematical) graph library in JavaScript.", | ||
"gulp-mocha": "^2.0.1", | ||
"gulp-pandoc": "^0.2.1", | ||
"gulp-rename": "^1.2.2", | ||
@@ -57,4 +58,4 @@ "gulp-uglify": "^1.2.0" | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "./node_modules/.bin/gulp test" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
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
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
6265987
12
1
4
10
25220