UnlimitJS allows for chaining with native JavaScript objects without extending objects' prototype s. It has a simply API and increases the readability of common code.

  1. for in loops are safe to use
  2. Chaining is super easy obj[fun]()[fun]()
  3. Unlimitjs is Javascript, no compiling

UnlimitJS intends to bring chaining and readability to Javascript.
Instead of writing: trim(' string ') you write ' string '[trim]()

var trim = function(){
  return this.replace(/^\s+|\s+$/g,'');
}[Unlimit]();

alert( ' string '[trim]() );

Here is another example

var yell = function(){
  alert(''+this);
  return this;
}[Unlimit]();

'Example string'[yell]()[yell]();

Examples

Unlimit isn't exactly intended for libraries to create tons of global functions like trim and yell. Unlimit is geared towards allowing methods to easily be chained without nested functions. The practicality and readability is demonstrated when you can change this jQuery snippet.

alert($.map($.trim($('input.name').val()).split(' '),function(str){
  return str.replace(/[-^&]/,'');
}).join(' '));

to

// one time set up
$.trim[Unlimit](true);
$.map[Unlimit](true);

alert(
     $('input.name').val()[$.trim]().split(' ')
     [$.map](function(str){
       return str.replace(/[-^&]/,'');
     }).join(' ')
);

underscore.js + Unlimit

// Unlimit underscore.js library
for(var i in _)_[i][Unlimit](true);

[0,1,2]
  // strip falsey values
  [_.compact]()
  [_.each](function(i){
    alert(i);
  })

underscore.js + Unlimit

var Mammal = function(){};
var Dog = function(){};

Dog.prototype = new Mammal();

_.extend[Unlimit](true);

Dog.prototype[_.extend]({
  method:function(){},
  method2:function(){}
};

API

Calling [Unlimit]() binds the this context to the object you are calling on.

var yell = function(){
  return alert(''+this);
}[Unlimit]();

'This string is bond to "this" in function.'[yell]()

Calling [Unlimit](true) tells the object your calling on to be passed as the first argument to the function.

var yell = function(obj){
  return alert(''+obj);
}[Unlimit](true);

'1st argument is bound to this string.'[yell]()

Calling object[Unlimit](function(){}) allows you to unlimit objects other then Function s.

var yell = {};
yell[Unlimit](function(){
  alert(''+this);
});

'This string is bond to the attached function.'[yell]()

Known Issues

  1. You can no longer decompile a function that has been Unlimit ed. In fact you shouldn't decompile a function period. It isn't cross browser and can cause bugs. If you have to do the following Function.prototype.toString.call(object);
  2. Unlimit doesn't work on Host Objects in IE<9. That basically means you can't expect to call Unlimit ed functions on NodeList s, or native DOM Element s. For example this will fail in IE<9.

    var toArray = function(){
      return Array.prototype.slice.call(this,0);
    }[Unlimit]();
    var body = document.getElementsByTagName('div')[toArray]();