@vercel/sdk
Version:
<p align="center"> <a href="https://vercel.com"> <img src="https://assets.vercel.com/image/upload/v1588805858/repositories/vercel/logo.png" height="96"> <h3 align="center">Vercel</h3> </a> <p align="center">Develop. Preview. Ship.</p> </p>
36 lines (31 loc) • 1.02 kB
text/typescript
/*
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
*/
declare const __brand: unique symbol;
export type Unrecognized<T> = T & { [__brand]: "unrecognized" };
function unrecognized<T>(value: T): Unrecognized<T> {
globalCount++;
return value as Unrecognized<T>;
}
let globalCount = 0;
let refCount = 0;
export function startCountingUnrecognized() {
refCount++;
const start = globalCount;
return {
/**
* Ends counting and returns the delta.
* @param delta - If provided, only this amount is added to the parent counter
* (used for nested unions where we only want to record the winning option's count).
* If not provided, records all counts since start().
*/
end: (delta?: number) => {
const count = globalCount - start;
// Reset globalCount back to start, then add only the specified delta
globalCount = start + (delta ?? count);
if (--refCount === 0) globalCount = 0;
return count;
},
};
}
export { unrecognized };