Comparing version 1.0.6 to 1.0.7
@@ -19,49 +19,46 @@ "use strict"; | ||
function compiler(lang, code) { | ||
var _a, _b, _c, _d, _e, _f, _g; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const body = { | ||
compiler: languages_json_1.default[lang].compiler, | ||
code: code, | ||
codes: [], | ||
stdin: "", | ||
options: languages_json_1.default[lang].options, | ||
"compiler-option-raw": "", | ||
"runtime-option-raw": "", | ||
}; | ||
const compiled = yield node_fetch_1.default("https://wandbox.org/compile", { | ||
headers: { | ||
accept: "text/event-stream", | ||
"accept-language": "tr-TR,tr;q=0.9,en-US;q=0.8,en;q=0.7", | ||
"cache-control": "no-cache", | ||
"content-type": "application/json", | ||
"sec-fetch-dest": "empty", | ||
"sec-fetch-mode": "cors", | ||
"sec-fetch-site": "same-origin", | ||
"sec-gpc": "1", | ||
"x-requested-with": "XMLHttpRequest", | ||
}, | ||
body: JSON.stringify(body), | ||
method: "POST", | ||
}) | ||
.then((x) => x.text()) | ||
.catch((e) => e); | ||
const splitted = compiled.split("\n"); | ||
const exitCode = splitted | ||
.find((x) => x.includes("data: ExitCode")) | ||
.replace("data: ExitCode:", ""); | ||
const end = splitted.findIndex((i) => i.includes("data: ExitCode")); | ||
const result = splitted | ||
.slice(5, end - 3) | ||
.filter((i) => !i.includes("\r")) | ||
.join("\n") | ||
.replace(/(data: |data:|StdOut:|StdErr:|\\n)/g, "") | ||
.split("\n") | ||
.filter((i) => i !== "" && i !== "\r") | ||
.join("\n"); | ||
if (result === null || result === void 0 ? void 0 : result.length) { | ||
return { | ||
result: result, | ||
exitCode: exitCode, | ||
try { | ||
const body = { | ||
compiler: languages_json_1.default[lang].compiler, | ||
code: code, | ||
codes: [], | ||
stdin: "", | ||
options: languages_json_1.default[lang].options, | ||
"compiler-option-raw": "", | ||
"runtime-option-raw": "", | ||
}; | ||
const compiled = yield node_fetch_1.default("https://wandbox.org/compile", { | ||
headers: { | ||
accept: "text/event-stream", | ||
"accept-language": "tr-TR,tr;q=0.9,en-US;q=0.8,en;q=0.7", | ||
"cache-control": "no-cache", | ||
"content-type": "application/json", | ||
"sec-fetch-dest": "empty", | ||
"sec-fetch-mode": "cors", | ||
"sec-fetch-site": "same-origin", | ||
"sec-gpc": "1", | ||
"x-requested-with": "XMLHttpRequest", | ||
}, | ||
body: JSON.stringify(body), | ||
method: "POST", | ||
}) | ||
.then((x) => x.text()) | ||
.catch((e) => e); | ||
const splitted = compiled === null || compiled === void 0 ? void 0 : compiled.split("\n"); | ||
const exitCode = (_a = splitted === null || splitted === void 0 ? void 0 : splitted.find((x) => x === null || x === void 0 ? void 0 : x.includes("data: ExitCode"))) === null || _a === void 0 ? void 0 : _a.replace("data: ExitCode:", ""); | ||
const end = splitted === null || splitted === void 0 ? void 0 : splitted.findIndex((i) => i === null || i === void 0 ? void 0 : i.includes("data: ExitCode")); | ||
const result = (_g = (_f = (_e = (_d = (_c = (_b = splitted === null || splitted === void 0 ? void 0 : splitted.slice(5, end - 3)) === null || _b === void 0 ? void 0 : _b.filter((i) => !i.includes("\r"))) === null || _c === void 0 ? void 0 : _c.join("\n")) === null || _d === void 0 ? void 0 : _d.replace(/(data: |data:|StdOut:|StdErr:|\\n)/g, "")) === null || _e === void 0 ? void 0 : _e.split("\n")) === null || _f === void 0 ? void 0 : _f.filter((i) => i !== "" && i !== "\r")) === null || _g === void 0 ? void 0 : _g.join("\n"); | ||
if (result === null || result === void 0 ? void 0 : result.length) { | ||
return { | ||
result: result, | ||
exitCode: exitCode, | ||
}; | ||
} | ||
throw new Error("Command failed to run!"); | ||
} | ||
throw new Error("Command failed to run!"); | ||
catch (error) { | ||
return console.log(error); | ||
} | ||
}); | ||
@@ -68,0 +65,0 @@ } |
@@ -6,3 +6,3 @@ { | ||
"name": "wandboxjs", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"main": "dist", | ||
@@ -9,0 +9,0 @@ "scripts": { |
@@ -8,54 +8,58 @@ "use strict"; | ||
export async function compiler(lang: keyof langs, code: string) { | ||
const body = { | ||
compiler: languages[lang].compiler, | ||
code: code, | ||
codes: [] as string[], | ||
stdin: "", | ||
options: languages[lang].options, | ||
"compiler-option-raw": "", | ||
"runtime-option-raw": "", | ||
}; | ||
try { | ||
const body = { | ||
compiler: languages[lang].compiler, | ||
code: code, | ||
codes: [] as string[], | ||
stdin: "", | ||
options: languages[lang].options, | ||
"compiler-option-raw": "", | ||
"runtime-option-raw": "", | ||
}; | ||
const compiled = await fetch("https://wandbox.org/compile", { | ||
headers: { | ||
accept: "text/event-stream", | ||
"accept-language": "tr-TR,tr;q=0.9,en-US;q=0.8,en;q=0.7", | ||
"cache-control": "no-cache", | ||
"content-type": "application/json", | ||
"sec-fetch-dest": "empty", | ||
"sec-fetch-mode": "cors", | ||
"sec-fetch-site": "same-origin", | ||
"sec-gpc": "1", | ||
"x-requested-with": "XMLHttpRequest", | ||
}, | ||
body: JSON.stringify(body), | ||
method: "POST", | ||
}) | ||
.then((x) => x.text()) | ||
.catch((e: string) => e); | ||
const compiled = await fetch("https://wandbox.org/compile", { | ||
headers: { | ||
accept: "text/event-stream", | ||
"accept-language": "tr-TR,tr;q=0.9,en-US;q=0.8,en;q=0.7", | ||
"cache-control": "no-cache", | ||
"content-type": "application/json", | ||
"sec-fetch-dest": "empty", | ||
"sec-fetch-mode": "cors", | ||
"sec-fetch-site": "same-origin", | ||
"sec-gpc": "1", | ||
"x-requested-with": "XMLHttpRequest", | ||
}, | ||
body: JSON.stringify(body), | ||
method: "POST", | ||
}) | ||
.then((x) => x.text()) | ||
.catch((e: string) => e); | ||
const splitted: string[] = compiled.split("\n"); | ||
const exitCode: string = splitted | ||
.find((x: string) => x.includes("data: ExitCode")) | ||
.replace("data: ExitCode:", ""); | ||
const end: number = splitted.findIndex((i: string) => | ||
i.includes("data: ExitCode") | ||
); | ||
const splitted: string[] = compiled?.split("\n"); | ||
const exitCode: string = splitted | ||
?.find((x: string) => x?.includes("data: ExitCode")) | ||
?.replace("data: ExitCode:", ""); | ||
const end: number = splitted?.findIndex((i: string) => | ||
i?.includes("data: ExitCode") | ||
); | ||
const result: string = splitted | ||
.slice(5, end - 3) | ||
.filter((i: string) => !i.includes("\r")) | ||
.join("\n") | ||
.replace(/(data: |data:|StdOut:|StdErr:|\\n)/g, "") | ||
.split("\n") | ||
.filter((i: string) => i !== "" && i !== "\r") | ||
.join("\n"); | ||
const result: string = splitted | ||
?.slice(5, end - 3) | ||
?.filter((i: string) => !i.includes("\r")) | ||
?.join("\n") | ||
?.replace(/(data: |data:|StdOut:|StdErr:|\\n)/g, "") | ||
?.split("\n") | ||
?.filter((i: string) => i !== "" && i !== "\r") | ||
?.join("\n"); | ||
if (result?.length) { | ||
return { | ||
result: result, | ||
exitCode: exitCode, | ||
}; | ||
if (result?.length) { | ||
return { | ||
result: result, | ||
exitCode: exitCode, | ||
}; | ||
} | ||
throw new Error("Command failed to run!"); | ||
} catch (error) { | ||
return console.log(error); | ||
} | ||
throw new Error("Command failed to run!"); | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
33248
519
0