MCPcopy Index your code
hub / github.com/nodejs/node-addon-api / _mustCallInner

Function _mustCallInner

test/common/index.js:92–121  ·  view source on GitHub ↗
(fn, criteria, field)

Source from the content-addressed store, hash-verified

90};
91
92function _mustCallInner (fn, criteria, field) {
93 if (typeof fn === 'number') {
94 criteria = fn;
95 fn = noop;
96 } else if (fn === undefined) {
97 fn = noop;
98 }
99 if (criteria === undefined) {
100 criteria = 1;
101 }
102
103 if (typeof criteria !== 'number') { throw new TypeError(`Invalid ${field} value: ${criteria}`); }
104
105 const context = {
106 [field]: criteria,
107 actual: 0,
108 stack: (new Error()).stack,
109 name: fn.name || '<anonymous>'
110 };
111
112 // add the exit listener only once to avoid listener leak warnings
113 if (mustCallChecks.length === 0) process.on('exit', runCallChecks);
114
115 mustCallChecks.push(context);
116
117 return function () {
118 context.actual++;
119 return fn.apply(this, arguments);
120 };
121}
122
123exports.mustNotCall = function (msg) {
124 return function mustNotCall () {

Callers 1

index.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected