blob: b2d9c5b3bbc52ff6259afc7f7dd169066f3292e2 [file] [log] [blame]
import getArguments from 'argsarray';
function once(fun) {
var called = false;
return getArguments(function (args) {
/* istanbul ignore if */
if (called) {
// this is a smoke test and should never actually happen
throw new Error('once called more than once');
} else {
called = true;
fun.apply(this, args);
}
});
}
export default once;