7fife-backend/node_modules/underscore/modules/before.js

13 lines
300 B
JavaScript
Raw Normal View History

2024-03-07 13:01:44 +00:00
// Returns a function that will only be executed up to (but not including) the
// Nth call.
export default function before(times, func) {
var memo;
return function() {
if (--times > 0) {
memo = func.apply(this, arguments);
}
if (times <= 1) func = null;
return memo;
};
}