all files / lib/deps/ once.js

100% Statements 14/14
83.33% Branches 5/6
100% Functions 3/3
100% Lines 13/13
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28                78886× 78886×   72202×     72200× 72200×        
'use strict';
 
Object.defineProperty(exports, "__esModule", {
  value: true
});
 
var _argsarray = require('argsarray');
 
var _argsarray2 = _interopRequireDefault(_argsarray);
 
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
 
function once(fun) {
  var called = false;
  return (0, _argsarray2.default)(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);
    }
  });
}
 
exports.default = once;
module.exports = exports['default'];