MCPcopy Index your code
hub / github.com/scriptscat/scriptcat / stripUndefined

Function stripUndefined

src/pkg/utils/utils.ts:544–554  ·  view source on GitHub ↗
(obj: K | T)

Source from the content-addressed store, hash-verified

542};
543
544export function stripUndefined<T extends Record<string, unknown>, K = T | undefined>(obj: K | T): K | T {
545 if (!obj || typeof obj !== "object") return obj;
546 const keys = Object.keys(obj);
547 if (!keys.length) return obj;
548 const result = {} as T;
549 for (const k of keys as (keyof T)[]) {
550 const v = (obj as T)[k];
551 if (v !== undefined) result[k] = v;
552 }
553 return result;
554}

Callers 3

utils.test.tsFile · 0.90
GM_cookieMethod · 0.90
buildDNRRuleMethod · 0.90

Calls 1

keysMethod · 0.80

Tested by

no test coverage detected