GoScrobble/web/node_modules/@hapi/hoek/lib/once.js

24 lines
345 B
JavaScript
Raw Permalink Normal View History

2022-04-25 02:47:15 +00:00
'use strict';
const internals = {};
module.exports = function (method) {
if (method._hoekOnce) {
return method;
}
let once = false;
const wrapped = function (...args) {
if (!once) {
once = true;
method(...args);
}
};
wrapped._hoekOnce = true;
return wrapped;
};