once.js 198 B

123456789101112
  1. 'use strict';
  2. module.exports = function once(fn) {
  3. let called = false;
  4. return function() {
  5. if (called) {
  6. return;
  7. }
  8. called = true;
  9. return fn.apply(null, arguments);
  10. };
  11. };