Files
cloudron-box/src/once.js

15 lines
316 B
JavaScript
Raw Normal View History

2022-04-15 19:01:35 -05:00
'use strict';
exports = module.exports = once;
// https://github.com/isaacs/once/blob/main/LICENSE (ISC)
function once (fn) {
const f = function () {
if (f.called) return f.value;
f.called = true;
return f.value = fn.apply(this, arguments);
};
f.called = false;
return f;
}