1 var scout = (function () { 2 var tests = { }; 3 return { 4 addTest: function (moduleName, test) { 5 tests[moduleName] = test; 6 }, 7 fetch: function () { 8 var modulesToFetch = [ ]; 9 for (var moduleName in tests) { 10 if (tests[moduleName]()) { 11 modulesToFetch.push(moduleName); 12 } 13 } 14 return modulesToFetch.join(','); 15 } 16 }; 17 })(); 18 19 scout.addTest('json2', function () { 20 return typeof JSON === 'undefined'; 21 }); 22 scout.addTest('indexOf', function () { 23 return typeof Array.prototype.indexOf === 'undefined'; 24 }); 25 scout.addTest('forEach', function () { 26 return typeof Array.prototype.forEach === 'undefined'; 27 }); 28 scout.addTest('map', function () { 29 return typeof Array.prototype.map === 'undefined'; 30 }); 31 scout.addTest('every', function () { 32 return typeof Array.prototype.every === 'undefined'; 33 }); 34 scout.addTest('some', function () { 35 return typeof Array.prototype.some === 'undefined'; 36 }); 37 scout.addTest('filter', function () { 38 return typeof Array.prototype.filter === 'undefined'; 39 }); 40 scout.addTest('reduce', function () { 41 return typeof Array.prototype.reduce === 'undefined'; 42 }); 43 44 scout.fetch();