10 lines
219 B
JavaScript
10 lines
219 B
JavaScript
|
'use strict';
|
||
|
|
||
|
module.exports = function only_once(fn) {
|
||
|
return function() {
|
||
|
if (fn === null) throw new Error('Callback was already called.');
|
||
|
fn.apply(this, arguments);
|
||
|
fn = null;
|
||
|
};
|
||
|
};
|