Files
cloudron-box/src/once.js
Girish Ramakrishnan 7f89dfd261 add once.js
2022-04-15 19:01:35 -05:00

15 lines
316 B
JavaScript

'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;
}