1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | 2 1 74928 74928 73410 2 73408 73408 2 | '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; |