cytoscape
Version:
Graph theory (a.k.a. network) library for analysis and visualisation
47 lines (35 loc) • 1.1 kB
JavaScript
import * as is from './is';
import Core from './core';
import extension from './extension';
import Stylesheet from './stylesheet';
import version from './version';
import { warnings } from './util';
let cytoscape = function( options ){
// if no options specified, use default
if( options === undefined ){
options = {};
}
// create instance
if( is.plainObject( options ) ){
return new Core( options );
}
// allow for registration of extensions
else if( is.string( options ) ){
return extension.apply( extension, arguments );
}
};
// e.g. cytoscape.use( require('cytoscape-foo'), bar )
cytoscape.use = function( ext ){
let args = Array.prototype.slice.call( arguments, 1 ); // args to pass to ext
args.unshift( cytoscape ); // cytoscape is first arg to ext
ext.apply( null, args );
return this;
};
cytoscape.warnings = function(bool){
return warnings(bool);
};
// replaced by build system
cytoscape.version = version;
// expose public apis (mostly for extensions)
cytoscape.stylesheet = cytoscape.Stylesheet = Stylesheet;
export default cytoscape;