00001 var toInteger = require('./toInteger'); 00002 00004 var FUNC_ERROR_TEXT = 'Expected a function'; 00005 00030 function after(n, func) { 00031 if (typeof func != 'function') { 00032 throw new TypeError(FUNC_ERROR_TEXT); 00033 } 00034 n = toInteger(n); 00035 return function() { 00036 if (--n < 1) { 00037 return func.apply(this, arguments); 00038 } 00039 }; 00040 } 00041 00042 module.exports = after;