javascript - How can I create a constructor for a static library -


i'm using introjs library.

see original code here.

i want able write var = new introjs() rather call start() method.

how can achieve that?

why not wrap factory introjs provides , call start on in wrapper?

you can externally (untested):

var introjswrapper = function(targetelm) {     var ijs = introjs(targetelm);     ijs.start();     return ijs; }; 

or can inside fork of introjs code exposing property of main function, e.g.:

var introjs = function (targetelm) {     if (typeof (targetelm) === 'object') {     // ... } introjs.autostart = function(targetelm) {     var ijs = introjs(targetelm);     ijs.start();     return ijs; }; 

note in introjs, main function thin parameter-testing/changing wrapper around internal constructor. calling indirectly invokes constructor. there no need access internal constructor function directly, far can see.


Comments

Popular posts from this blog

Java sticky instances of class com.mysql.jdbc.Field aggregating -