EventTheory

EventTheory aims to be an easily extensible system that will give your own bespoke code an event messaging structure.

ArrayTheory

The JavaScript Array Object is something that I've always felt needed to be extended and improved upon. ArrayTheory attempts to do just this by providing a standard code base that works with Arrays.

a few examples:

var a, b;

/// useful indexOfSequence function

a = ArrayTheory([1,2,3,4,5,6,7]);

b = a.indexOfSequence([3,4]);

>>> b == 2
/// the flattern function - remove mutli-dimensions

a = ArrayTheory([1,2,[3,4],[5,[6,7]]]).flattern();

>>> a == [1,2,3,4,5,6,7]
/// the replaceRange function

a = ArrayTheory(['a','b','x','y','z','d','e']).replaceRange(2,5,'c');

b = ArrayTheory(['a','b','x','y','z','d','e']).replaceRange(2,5,'c',true);

>>> a == ['a','b','c','d','e']
>>> b == ['a','b','c','c','c','d','e']

ObjectTheory

One of the progenitors for the rest of the Theory code collection - I originally designed this in conjunction with the StringTheory object. It's main purpose is to allow easy navigation of object structures, but it has quite a few extra little functions that can be quite useful.

a few examples:

var a, obj;

obj = {
   'this': {
      'is': {
         'a': {
            'test': 123
         },
         'ab': {
            'test': 890
         },
         'not': {
            'a': {
               'test': 456
            }
         }
      }
   }
};
/// two lines that do the same thing - one from ObjectTheory perspective,
/// the other from StringTheory

a = ObjectTheory( obj ).find( '*/is/^a/test' );

a = ( '*/is/^a/test' ).travel( obj );

>>> a == [123,890]

StringTheory

StringTheory - unlike it's scientific namesake - has nothing to do with describing ultra-reallity, but everything to do with describing JavaScript Object structures. Initially designed as a short hand for navigating simple objects, I found that with added complexity I could create quite a powerful object description / conversion system. Perfect for creating your own sub-syntax with-in your code or for just manipulating objects and strings.

a few examples:

/// easy logging

('Output this to the console log or your chosen output').log();

/// session based storage

('my storage name').box('This is my thing to store');

('my storage name').unbox().alert();

/// one way of doing simple string selection & replacement

a = ('<div>  We have lots of white space   </div>')
      .selectRange('>','<',true)
      .trim()
      .clean()
      .apply('+have','=no longer have')

>>> a == '<div>We no longer have lots of white space</div>'