tracker.reset([fn])
fn
<Function> 要重置的跟踪功能。
重置呼叫跟踪器的调用。 如果跟踪函数作为参数传入,则调用将被重置。 如果没有传入参数,所有被跟踪的函数都将被重置
import assert from 'node:assert';
const tracker = new assert.CallTracker();
function func() {}
const callsfunc = tracker.calls(func);
callsfunc();
// 跟踪器被调用一次
tracker.getCalls(callsfunc).length === 1;
tracker.reset(callsfunc);
tracker.getCalls(callsfunc).length === 0;
const assert = require('node:assert');
function func() {}
const callsfunc = tracker.calls(func);
callsfunc();
// 跟踪器被调用一次
tracker.getCalls(callsfunc).length === 1;
tracker.reset(callsfunc);
tracker.getCalls(callsfunc).length === 0;
fn
<Function> a tracked function to reset.
reset calls of the call tracker. if a tracked function is passed as an argument, the calls will be reset for it. if no arguments are passed, all tracked functions will be reset
import assert from 'node:assert';
const tracker = new assert.CallTracker();
function func() {}
const callsfunc = tracker.calls(func);
callsfunc();
// Tracker was called once
tracker.getCalls(callsfunc).length === 1;
tracker.reset(callsfunc);
tracker.getCalls(callsfunc).length === 0;
const assert = require('node:assert');
function func() {}
const callsfunc = tracker.calls(func);
callsfunc();
// Tracker was called once
tracker.getCalls(callsfunc).length === 1;
tracker.reset(callsfunc);
tracker.getCalls(callsfunc).length === 0;