Skip to content

A collection of Utilitys for JavaScript. Designed to allow for Debugging as well as allowing for Addins to script code and modding code .

License

Notifications You must be signed in to change notification settings

merlin2v/MODJS-Utils-Toolbox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MODJS Utils Toolbox

A collection of Utilitys for JavaScript. Designed to allow for Debugging as well as allowing for Addins to script code and modding code.

List of Classes:

  • WhenExists - runs code once something exists else it will check back by default every 1000ms.

    • Examples:
         var foo = {}; 
         setTimeout(()=>{foo.hello="world";},10000); 
         new WhenExists(foo.hello).then(()=>{console.log("hello "+foo.["hello"])}); 
  • Object detectors

    lets say you have:

       function unknownFunction(obj){
          var foo = obj.foo;
          var bar = foo.bar;
          var qux = bar.baz.qux;
          console.log("function done!!");
       }

    and you run:

        unknownFunction({})//throws "Uncaught TypeError: Cannot read property 'bar' of undefined"

    this is a list of difrent types of objects that can be used for mapping out coding functions

    • SquishyObject - for testing what a property does.

      • to find out what property calls bar you can use the SquishyObject
           unknownFunction(new SquishyObject())//no direct undefined problems and prints out: function done!!
        once you are able to do that you can then do:
            unknownFunction(new PockeyObject({foo:{}}))//throws "Uncaught Error: wants Property 'bar'"
        and continue this until you have filled in all the values
    • PokeyObject - throws an error whenever something undefined is called

      • to find out what property calls bar you can use the PokeyObject
           unknownFunction(new PockeyObject())//throws "Uncaught Error: wants Property 'foo'"
        once you are able to do that you can then do:
            unknownFunction(new PockeyObject({foo:{}}))//throws "Uncaught Error: wants Property 'bar'"
        and continue this until you have filled in all the values
    • MapperObject - if PockyObject is to slow for you then there is MapperObject which tests what a object wants and prints the trails of undefined vars to the console

      • Example:
           unknownFunction(new MapperObject("top"))
           /* prints out:
           'undefined' wants ' foo '
           'undefined' wants ' bar '
           'undefined' wants ' baz '
           'undefined' wants ' qux '
           function done!!
           */
        however you wont be able to use the base unless you use it like this
            unknownFunction(new MapperObject({foo:{bar:{baz:{qux:{}}}}}))//prints only: function done!!
    • CartographerObject - if you don't want to implement the entire thing then you can use CartographerObject which is for testing what a object wants and prints the undefined vars to the console unless logKnownProperties is specified(then it prints all vars out);

      • Example:
           unknownFunction(new CartographerObject("top"));
           /* prints out:
           'top' wants non-existent ' foo '       //as warning
           'foo' wants non-existent ' bar '       //as warning
           'bar' wants non-existent ' baz '       //as warning
           'baz' wants non-existent ' qux '       //as warning
           function done!!
           */
        if you have some of the variables defined and have logKnownProperties as true then it will log 'foo' wants ' bar '
    • Cartographer - CartographerObject is usefull however it can, at times, be disorientating. for that we have the Cartographer. this is for testing what a object wants and it can print all vars to the console in groups as well as a object representation.

      • Example:
           var c;
           unknownFunction((c = new Cartographer("top")));//prints out: function done!!
           c.__$printTree(); /* prints out:
           foo
              bar
                 baz
                    qux
                       
           {} //the object
           */
        if you have some of the variables defined and have logKnownProperties as true then it will log 'foo' wants ' bar '

    ##Importing

    to import you can use: https://rawgit.com/ to import code

About

A collection of Utilitys for JavaScript. Designed to allow for Debugging as well as allowing for Addins to script code and modding code .

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published