temporally extend an object's capabilities.
JavaScript
Switch branches/tags
Nothing to show
Clone or download
carview.php?tsp= Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
carview.php?tsp= LICENSE
carview.php?tsp= README.md
carview.php?tsp= rig-test.html
carview.php?tsp= rig.js

README.md

rig.js

Temporally extend an object's capabilities.

synopsis

Create a rig

var $ = rig.builder({
   'string' : {
     capitalize: function () {
       return this.charAt(0).toUpperCase() + this.substr(1);
     }
   },
   'array' : {
     compact: function () {
       var result = [];
       for (var i = 0; i < this.length; i++) {
         if (this[i]) result.push(this[i]);
       }
       return result;
     }
   }
});

Apply it to a couple objects to use the new functionality

$("rig").capitalize();                   // "Rig"
$(["hello", "carview.php?tsp=", "world", "carview.php?tsp="]).compact(); // ["hello", "world"]