A collection of Utilitys for JavaScript. Designed to allow for Debugging as well as allowing for Addins to script code and modding code.
-
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"])});
-
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
once you are able to do that you can then do:unknownFunction(new SquishyObject())//no direct undefined problems and prints out: function done!!
and continue this until you have filled in all the valuesunknownFunction(new PockeyObject({foo:{}}))//throws "Uncaught Error: wants Property 'bar'"
- to find out what property calls bar you can use the
-
PokeyObject - throws an error whenever something undefined is called
- to find out what property calls bar you can use the
PokeyObject
once you are able to do that you can then do:unknownFunction(new PockeyObject())//throws "Uncaught Error: wants Property 'foo'"
and continue this until you have filled in all the valuesunknownFunction(new PockeyObject({foo:{}}))//throws "Uncaught Error: wants Property 'bar'"
- to find out what property calls bar you can use the
-
MapperObject - if
PockyObject
is to slow for you then there isMapperObject
which tests what a object wants and prints the trails of undefined vars to the console- Example:
however you wont be able to use the base unless you use it like this
unknownFunction(new MapperObject("top")) /* prints out: 'undefined' wants ' foo ' 'undefined' wants ' bar ' 'undefined' wants ' baz ' 'undefined' wants ' qux ' function done!! */
unknownFunction(new MapperObject({foo:{bar:{baz:{qux:{}}}}}))//prints only: function done!!
- Example:
-
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:
if you have some of the variables defined and have
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!! */
logKnownProperties
as true then it will log'foo' wants ' bar '
- Example:
-
Cartographer -
CartographerObject
is usefull however it can, at times, be disorientating. for that we have theCartographer
. 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:
if you have some of the variables defined and have
var c; unknownFunction((c = new Cartographer("top")));//prints out: function done!! c.__$printTree(); /* prints out: foo bar baz qux {} //the object */
logKnownProperties
as true then it will log'foo' wants ' bar '
- Example:
##Importing
to import you can use: https://rawgit.com/ to import code
-