graphology-utils
Version:
Miscellaneous utils for graphology.
24 lines (22 loc) • 529 B
JavaScript
/**
* Graphology isGraph
* ===================
*
* Very simple function aiming at ensuring the given variable is a
* graphology instance.
*/
/**
* Checking the value is a graphology instance.
*
* @param {any} value - Target value.
* @return {boolean}
*/
module.exports = function isGraph(value) {
return (
value !== null &&
typeof value === 'object' &&
typeof value.addUndirectedEdgeWithKey === 'function' &&
typeof value.dropNode === 'function' &&
typeof value.multi === 'boolean'
);
};