| 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; |