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

Function objectProps

example/tests/gm_xhr_test.js:1957–1982  ·  view source on GitHub ↗
(o)

Source from the content-addressed store, hash-verified

1955 return line ? line.split(":").slice(1).join(":").trim() : "";
1956 }
1957 function objectProps(o) {
1958 if (!o || typeof o !== "object") return "not an object";
1959 let z, oD, zD;
1960 try {
1961 z = Object.assign({}, o);
1962 } catch {
1963 return "Object.assign failed";
1964 }
1965 // accept null / "" / undefined for normal/failed/fetch_normal/fetch_failed XHR
1966 // non-empty text (still primitive) can be also accepted. (common in xhr error case)
1967 if (typeof (z.response ?? "") !== "string") return "non-primitive response value exposed";
1968 if (typeof (z.responseText ?? "") !== "string") return "non-primitive responseText value exposed";
1969 if (typeof (z.responseXML ?? "") !== "string") return "non-primitive responseXML value exposed";
1970 try {
1971 oD = JSON.stringify(o);
1972 } catch {
1973 return "JSON.stringify failed";
1974 }
1975 try {
1976 zD = JSON.stringify(z);
1977 } catch {
1978 return "JSON.stringify failed";
1979 }
1980 if (oD !== zD) return "Object Props Failed";
1981 return "ok";
1982 }
1983
1984 // ---------- Runner ----------
1985 async function runAll() {

Callers 1

runFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected