_.before(n, func)
创建一个调用func的函数,通过this绑定和创建函数的参数调用func,调用次数不超过 n 次。 之后再调用这个函数,将返回一次最后调用func的结果。
const_=require('lodash'); varsaves= ['profile', 'settings']; vardone=_.before(saves.length, function () { console.log('start before!'); }); _.forEach(saves, function (type) { console.log(type) done(); });
