summaryrefslogtreecommitdiff
path: root/scripts/lib/util.js
blob: c6836f72676d983330497e266bf702de3d39984c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
(function () {
  Object.defineProperties(util, { 
    "getBody" :  { 
      value :  function(f) {
        if (f !== null && f !== undefined && f instanceof Function) {
          var m = f.toString().match(/\{([\s\S]*)\}/m)[1];
          return m.replace(/^\s*\/\/.*$/mg,'');
        }
        return null;
      }
    }
  });
  Object.freeze(util);
  if (Object.prototype.forEach === undefined) {
    Object.defineProperty(Object.prototype, "forEach", { 
      value : function (callback) {
        var key;
        for (key in this) {
          callback(key, this[key], this); 
        }
      }
    });
  }
})();