From 5af1bbfb3c3a43e24823a8be95230d93f70786c3 Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Sat, 5 Nov 2022 15:36:07 +0100 Subject: [PATCH] once: add debug --- src/once.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/once.js b/src/once.js index 190b0f369..ccbc666e1 100644 --- a/src/once.js +++ b/src/once.js @@ -2,10 +2,15 @@ exports = module.exports = once; +const debug = require('debug')('box:once'); + // https://github.com/isaacs/once/blob/main/LICENSE (ISC) function once (fn) { const f = function () { - if (f.called) return f.value; + if (f.called) { + debug(`${f.name} was already called, returning previous return value`); + return f.value; + } f.called = true; return f.value = fn.apply(this, arguments); };