blob: f64ed70e5df2aa883f5d4be4ab6991d4863a9469 [file] [log] [blame]
'use strict';
var getArguments = require('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);
}
});
}
module.exports = once;