New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@scalar/snippetz

Package Overview
Dependencies
Maintainers
8
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@scalar/snippetz - npm Package Compare versions

Comparing version 0.1.5 to 0.1.6

216

dist/index.js

@@ -1,33 +0,33 @@

function u(s) {
return s.reduce((t, e) => (t[e.name] = e.value, t), {});
function u(n) {
return n.reduce((t, e) => (t[e.name] = e.value, t), {});
}
function p(s) {
return /\s|-/.test(s);
function p(n) {
return /\s|-/.test(n);
}
function h(s, t = 0) {
let e = [], n = " ".repeat(t), o = " ".repeat(t + 2);
for (const [c, a] of Object.entries(s)) {
let d = p(c) ? `'${c}'` : c;
if (Array.isArray(a)) {
const i = a.map((r) => typeof r == "string" ? `'${r}'` : r && typeof r == "object" ? h(r, t + 2) : r).join(`, ${o}`);
e.push(`${o}${d}: [${i}]`);
} else if (a && typeof a == "object")
function c(n, t = 0) {
let e = [], a = " ".repeat(t), s = " ".repeat(t + 2);
for (const [h, i] of Object.entries(n)) {
let d = p(h) ? `'${h}'` : h;
if (Array.isArray(i)) {
const r = i.map((o) => typeof o == "string" ? `'${o}'` : o && typeof o == "object" ? c(o, t + 2) : o).join(`, ${s}`);
e.push(`${s}${d}: [${r}]`);
} else if (i && typeof i == "object")
e.push(
`${o}${d}: ${h(
a,
`${s}${d}: ${c(
i,
t + 2
)}`
);
else if (typeof a == "string") {
let i = `${a}`;
if (a.startsWith("JSON.stringify")) {
const r = a.split(`
else if (typeof i == "string") {
let r = `${i}`;
if (i.startsWith("JSON.stringify")) {
const o = i.split(`
`);
r.length > 1 && (i = r.map((f, l) => l === 0 ? f : `${o}${f}`).join(`
o.length > 1 && (r = o.map((f, l) => l === 0 ? f : `${s}${f}`).join(`
`));
} else
i = `'${a}'`;
e.push(`${o}${d}: ${i}`);
r = `'${i}'`;
e.push(`${s}${d}: ${r}`);
} else
e.push(`${o}${d}: ${a}`);
e.push(`${s}${d}: ${i}`);
}

@@ -37,9 +37,9 @@ return `{

`)}
${n}}`;
${a}}`;
}
function $(s) {
var d, i;
function m(n) {
var d, r;
const t = {
method: "GET",
...s
...n
};

@@ -49,13 +49,13 @@ t.method = t.method.toUpperCase();

method: t.method === "GET" ? void 0 : t.method
}, n = new URLSearchParams(
}, a = new URLSearchParams(
t.queryString ? u(t.queryString) : void 0
), o = n.size ? `?${n.toString()}` : "";
(d = t.headers) != null && d.length && (e.headers = {}, t.headers.forEach((r) => {
e.headers[r.name] = r.value;
})), (i = t.cookies) != null && i.length && (e.headers = e.headers || {}, t.cookies.forEach((r) => {
e.headers["Set-Cookie"] = e.headers["Set-Cookie"] ? `${e.headers["Set-Cookie"]}; ${r.name}=${r.value}` : `${r.name}=${r.value}`;
})), Object.keys(e).forEach((r) => {
e[r] === void 0 && delete e[r];
}), t.postData && (e.body = t.postData.text, t.postData.mimeType === "application/json" && (e.body = `JSON.stringify(${h(JSON.parse(e.body))})`));
const c = Object.keys(e).length ? `, ${h(e)}` : "";
), s = a.size ? `?${a.toString()}` : "";
(d = t.headers) != null && d.length && (e.headers = {}, t.headers.forEach((o) => {
e.headers[o.name] = o.value;
})), (r = t.cookies) != null && r.length && (e.headers = e.headers || {}, t.cookies.forEach((o) => {
e.headers["Set-Cookie"] = e.headers["Set-Cookie"] ? `${e.headers["Set-Cookie"]}; ${o.name}=${o.value}` : `${o.name}=${o.value}`;
})), Object.keys(e).forEach((o) => {
e[o] === void 0 && delete e[o];
}), t.postData && (e.body = t.postData.text, t.postData.mimeType === "application/json" && (e.body = `JSON.stringify(${c(JSON.parse(e.body))})`));
const h = Object.keys(e).length ? `, ${c(e)}` : "";
return {

@@ -66,10 +66,10 @@ target: "node",

const { statusCode, body } = await request('${t.url}${o}'${c})`
const { statusCode, body } = await request('${t.url}${s}'${h})`
};
}
function g(s) {
var d, i;
function $(n) {
var d, r;
const t = {
method: "GET",
...s
...n
};

@@ -79,26 +79,26 @@ t.method = t.method.toUpperCase();

method: t.method === "GET" ? void 0 : t.method
}, n = new URLSearchParams(
}, a = new URLSearchParams(
t.queryString ? u(t.queryString) : void 0
), o = n.size ? `?${n.toString()}` : "";
(d = t.headers) != null && d.length && (e.headers = {}, t.headers.forEach((r) => {
e.headers[r.name] = r.value;
})), (i = t.cookies) != null && i.length && (e.headers = e.headers || {}, t.cookies.forEach((r) => {
e.headers["Set-Cookie"] = e.headers["Set-Cookie"] ? `${e.headers["Set-Cookie"]}; ${r.name}=${r.value}` : `${r.name}=${r.value}`;
})), Object.keys(e).forEach((r) => {
e[r] === void 0 && delete e[r];
}), t.postData && (e.body = t.postData.text, t.postData.mimeType === "application/json" && (e.body = `JSON.stringify(${h(
), s = a.size ? `?${a.toString()}` : "";
(d = t.headers) != null && d.length && (e.headers = {}, t.headers.forEach((o) => {
e.headers[o.name] = o.value;
})), (r = t.cookies) != null && r.length && (e.headers = e.headers || {}, t.cookies.forEach((o) => {
e.headers["Set-Cookie"] = e.headers["Set-Cookie"] ? `${e.headers["Set-Cookie"]}; ${o.name}=${o.value}` : `${o.name}=${o.value}`;
})), Object.keys(e).forEach((o) => {
e[o] === void 0 && delete e[o];
}), t.postData && (e.body = t.postData.text, t.postData.mimeType === "application/json" && (e.body = `JSON.stringify(${c(
JSON.parse(e.body)
)})`));
const c = Object.keys(e).length ? `, ${h(e)}` : "";
const h = Object.keys(e).length ? `, ${c(e)}` : "";
return {
target: "node",
client: "fetch",
code: `fetch('${t.url}${o}'${c})`
code: `fetch('${t.url}${s}'${h})`
};
}
function m(s) {
var d, i;
function g(n) {
var d, r;
const t = {
method: "GET",
...s
...n
};

@@ -108,41 +108,97 @@ t.method = t.method.toUpperCase();

method: t.method === "GET" ? void 0 : t.method
}, n = new URLSearchParams(
}, a = new URLSearchParams(
t.queryString ? u(t.queryString) : void 0
), o = n.size ? `?${n.toString()}` : "";
(d = t.headers) != null && d.length && (e.headers = {}, t.headers.forEach((r) => {
), s = a.size ? `?${a.toString()}` : "";
(d = t.headers) != null && d.length && (e.headers = {}, t.headers.forEach((o) => {
e.headers[o.name] = o.value;
})), (r = t.cookies) != null && r.length && (e.headers = e.headers || {}, t.cookies.forEach((o) => {
e.headers["Set-Cookie"] = e.headers["Set-Cookie"] ? `${e.headers["Set-Cookie"]}; ${o.name}=${o.value}` : `${o.name}=${o.value}`;
})), Object.keys(e).forEach((o) => {
e[o] === void 0 && delete e[o];
}), t.postData && (e.body = t.postData.text, t.postData.mimeType === "application/json" && (e.body = `JSON.stringify(${c(
JSON.parse(e.body)
)})`));
const h = Object.keys(e).length ? `, ${c(e)}` : "";
return {
target: "js",
client: "fetch",
code: `fetch('${t.url}${s}'${h})`
};
}
function y(n) {
var i, d;
const t = {
method: "GET",
...n
};
t.method = t.method.toUpperCase();
const e = {
method: t.method === "GET" ? void 0 : t.method
}, a = new URLSearchParams(
t.queryString ? u(t.queryString) : void 0
);
a.size && (e.query = {}, a.forEach((r, o) => {
e.query[o] = r;
})), (i = t.headers) != null && i.length && (e.headers = {}, t.headers.forEach((r) => {
e.headers[r.name] = r.value;
})), (i = t.cookies) != null && i.length && (e.headers = e.headers || {}, t.cookies.forEach((r) => {
})), (d = t.cookies) != null && d.length && (e.headers = e.headers || {}, t.cookies.forEach((r) => {
e.headers["Set-Cookie"] = e.headers["Set-Cookie"] ? `${e.headers["Set-Cookie"]}; ${r.name}=${r.value}` : `${r.name}=${r.value}`;
})), Object.keys(e).forEach((r) => {
e[r] === void 0 && delete e[r];
}), t.postData && (e.body = t.postData.text, t.postData.mimeType === "application/json" && (e.body = `JSON.stringify(${h(
JSON.parse(e.body)
)})`));
const c = Object.keys(e).length ? `, ${h(e)}` : "";
}), t.postData && (e.body = t.postData.text, t.postData.mimeType === "application/json" && (e.body = JSON.parse(e.body)));
const s = Object.keys(e).length ? `, ${c(e)}` : "";
return {
target: "js",
client: "fetch",
code: `fetch('${t.url}${o}'${c})`
client: "ofetch",
code: `ofetch('${t.url}'${s})`
};
}
function y() {
const s = [$, g, m];
function S(n) {
var i, d;
const t = {
method: "GET",
...n
};
t.method = t.method.toUpperCase();
const e = {
method: t.method === "GET" ? void 0 : t.method
}, a = new URLSearchParams(
t.queryString ? u(t.queryString) : void 0
);
a.size && (e.query = {}, a.forEach((r, o) => {
e.query[o] = r;
})), (i = t.headers) != null && i.length && (e.headers = {}, t.headers.forEach((r) => {
e.headers[r.name] = r.value;
})), (d = t.cookies) != null && d.length && (e.headers = e.headers || {}, t.cookies.forEach((r) => {
e.headers["Set-Cookie"] = e.headers["Set-Cookie"] ? `${e.headers["Set-Cookie"]}; ${r.name}=${r.value}` : `${r.name}=${r.value}`;
})), Object.keys(e).forEach((r) => {
e[r] === void 0 && delete e[r];
}), t.postData && (e.body = t.postData.text, t.postData.mimeType === "application/json" && (e.body = JSON.parse(e.body)));
const s = Object.keys(e).length ? `, ${c(e)}` : "";
return {
get(t, e, n) {
const o = this.findPlugin(t, e);
if (o)
return o(n);
target: "node",
client: "ofetch",
code: `ofetch('${t.url}'${s})`
};
}
function v() {
const n = [m, $, g, y, S];
return {
get(t, e, a) {
const s = this.findPlugin(t, e);
if (s)
return s(a);
},
print(t, e, n) {
var o;
return (o = this.get(t, e, n)) == null ? void 0 : o.code;
print(t, e, a) {
var s;
return (s = this.get(t, e, a)) == null ? void 0 : s.code;
},
targets() {
return s.map((t) => t().target).filter((t, e, n) => n.indexOf(t) === e);
return n.map((t) => t().target).filter((t, e, a) => a.indexOf(t) === e);
},
clients() {
return s.map((t) => t().client);
return n.map((t) => t().client);
},
plugins() {
return s.map((t) => {
return n.map((t) => {
const e = t();

@@ -156,5 +212,5 @@ return {

findPlugin(t, e) {
return s.find((n) => {
const o = n();
return o.target === t && o.client === e;
return n.find((a) => {
const s = a();
return s.target === t && s.client === e;
});

@@ -168,3 +224,3 @@ },

export {
y as snippetz
v as snippetz
};
{
"name": "@scalar/snippetz",
"version": "0.1.5",
"version": "0.1.6",
"type": "module",

@@ -12,6 +12,8 @@ "devDependencies": {

"dependencies": {
"@scalar/snippetz-core": "0.1.3",
"@scalar/snippetz-plugin-node-undici": "0.1.5",
"@scalar/snippetz-plugin-node-fetch": "0.1.1",
"@scalar/snippetz-plugin-js-fetch": "0.1.0"
"@scalar/snippetz-core": "0.1.4",
"@scalar/snippetz-plugin-node-fetch": "0.1.2",
"@scalar/snippetz-plugin-node-ofetch": "^0.1.1",
"@scalar/snippetz-plugin-node-undici": "0.1.6",
"@scalar/snippetz-plugin-js-ofetch": "^0.1.1",
"@scalar/snippetz-plugin-js-fetch": "0.1.1"
},

@@ -18,0 +20,0 @@ "files": [

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc