Astalanumerator baby

I wanted to map all properties in javascript and inspect them regardless if they were objects or not. IE doesn’t support for(i in..) for native properties like constructor etc. So I decided to write a cross platform enumerator that could map everything. I decided to call it “Astalanumerator” as a silly reference to terminator combined with enumerator.

It works using a list of js properties stored within an array, you pass an object to it and it checks each of the properties using the array and attempts to navigate through it. Originally I had it enumerating until it reached null but this caused every browser to lock up as some objects went on forever, so I put some limits in place.

I use timeouts to prevent browser lockups and I use list elements to indent each of the objects, this is nice because I can delay the result and continue the loop while the object has finished enumerating. The third parameter of the inspect function handles this by storing the target element so each of the objects can be linked together.

Limits

The limits in place help stop browser crashes here is how they work:-
1. Number of properties to enum:
This is the limit of valid properties of the object, it will only evaluate 10 per object by default.
2. Number of inner properties to enum:
The inner properties limit is the amount of child properties to enumerate.
3. Only enum objects?:
This option allows you to enum all properties even numbers, by default it is restricted to objects only.

Astalanumerator demo

Comments are closed :( too much spam. If you want to contact me about any article please email or tweet me.