818
Du
dustymarkdown / files
dustymarkdown / node_modules / dust / vendor / ecma.js
1.2 KB
1if (!Array.prototype.forEach) { 2 Array.prototype.forEach = function(fun /*, thisp */) { 3 "use strict"; 4 5 if (this === void 0 || this === null) 6 throw new TypeError(); 7 8 var t = Object(this); 9 var len = t.length >>> 0; 10 if (typeof fun !== "function") 11 throw new TypeError(); 12 13 var thisp = arguments[1]; 14 for (var i = 0; i < len; i++) { 15 if (i in t) 16 fun.call(thisp, t[i], i, t); 17 } 18 }; 19} 20 21if (!Array.prototype.map) { 22 Array.prototype.map = function(fun /*, thisp */) { 23 "use strict"; 24 25 if (this === void 0 || this === null) 26 throw new TypeError(); 27 28 var t = Object(this); 29 var len = t.length >>> 0; 30 if (typeof fun !== "function") 31 throw new TypeError(); 32 33 var res = new Array(len); 34 var thisp = arguments[1]; 35 for (var i = 0; i < len; i++) { 36 if (i in t) 37 res[i] = fun.call(thisp, t[i], i, t); 38 } 39 40 return res; 41 }; 42} 43 44if (!String.prototype.trim) { 45 String.prototype.trim = function() { 46 return this.replace(/^\s+|\s+$/g,""); 47 } 48} 49 50if (!String.prototype.trimLeft) { 51 String.prototype.trimLeft = function() { 52 return this.replace(/^\s+/,""); 53 } 54} 55 56if (!String.prototype.trimRight) { 57 String.prototype.trimRight = function() { 58 return this.replace(/\s+$/,""); 59 } 60}