UNPKG

1.1 kBJavaScriptView Raw
1import * as is from './is';
2import Core from './core';
3import extension from './extension';
4import Stylesheet from './stylesheet';
5import version from './version';
6import { warnings } from './util';
7
8let cytoscape = function( options ){
9 // if no options specified, use default
10 if( options === undefined ){
11 options = {};
12 }
13
14 // create instance
15 if( is.plainObject( options ) ){
16 return new Core( options );
17 }
18
19 // allow for registration of extensions
20 else if( is.string( options ) ){
21 return extension.apply( extension, arguments );
22 }
23};
24
25// e.g. cytoscape.use( require('cytoscape-foo'), bar )
26cytoscape.use = function( ext ){
27 let args = Array.prototype.slice.call( arguments, 1 ); // args to pass to ext
28
29 args.unshift( cytoscape ); // cytoscape is first arg to ext
30
31 ext.apply( null, args );
32
33 return this;
34};
35
36cytoscape.warnings = function(bool){
37 return warnings(bool);
38};
39
40// replaced by build system
41cytoscape.version = version;
42
43// expose public apis (mostly for extensions)
44cytoscape.stylesheet = cytoscape.Stylesheet = Stylesheet;
45
46export default cytoscape;