import { group } from "./runner.mjs"; import { bench, run } from "./runner.mjs"; import { encode as htmlEntityEncode } from "html-entities"; import { escape as heEscape } from "he"; var bunEscapeHTML = globalThis.escapeHTML || Bun.escapeHTML; const FIXTURE = require("fs") .readFileSync(import.meta.dir + "/_fixture.txt", "utf8") .split("") .map(a => { if (a.charCodeAt(0) > 127) { return "a"; } return a; }) .join(""); const FIXTURE_WITH_UNICODE = require("fs").readFileSync(import.meta.dir + "/_fixture.txt", "utf8"); // from react-dom: const matchHtmlRegExp = /["'&<>]/; function reactEscapeHtml(string) { const str = "" + string; const match = matchHtmlRegExp.exec(str); if (!match) { return str; } let escape; let html = ""; let index; let lastIndex = 0; for (index = match.index; index < str.length; index++) { switch (str.charCodeAt(index)) { case 34: // " escape = """; break; case 38: // & escape = "&"; break; case 39: // ' escape = "'"; // modified from escape-html; used to be ''' break; case 60: // < escape = "<"; break; case 62: // > escape = ">"; break; default: continue; } if (lastIndex !== index) { html += str.substring(lastIndex, index); } lastIndex = index + 1; html += escape; } return lastIndex !== index ? html + str.substring(lastIndex, index) : html; } // for (let input of [ // "", // `long string, nothing to escape... `.repeat(9999), // `long utf16 string, no esc 🤔🤔🤔🤔🤔` + "tex".repeat(4000), // `smol`, // // `medium string with `, // FIXTURE, // // "[unicode]" + FIXTURE_WITH_UNICODE, // ]) { // group( // { // summary: true, // name: // `"` + // input.substring(0, Math.min(input.length, 32)) + // `"` + // ` (${input.length} chars)`, // }, // () => { // bench(`ReactDOM.escapeHTML`, () => reactEscapeHtml(input)); // bench(`html-entities.encode`, () => htmlEntityEncode(input)); // bench(`he.escape`, () => heEscape(input)); // bench(`Bun.escapeHTML`, () => bunEscapeHTML(input)); // } // ); // } for (let input of [ `long string, nothing to escape... `.repeat(9999999 * 3), FIXTURE.repeat(8000), // "[unicode]" + FIXTURE_WITH_UNICODE, ]) { group( { summary: true, name: `"` + input.substring(0, Math.min(input.length, 32)) + `"` + ` (${new Intl.NumberFormat().format(input.length / 100_000_000_0)} GB)`, }, () => { // bench(`ReactDOM.escapeHTML`, () => reactEscapeHtml(input)); // bench(`html-entities.encode`, () => htmlEntityEncode(input)); // bench(`he.escape`, () => heEscape(input)); bench(`Bun.escapeHTML`, () => bunEscapeHTML(input)); }, ); } await run(); value='dave/zlib'>dave/zlib Unnamed repository; edit this file 'description' to name the repository.
aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/bindings/webcrypto/CryptoAlgorithmECDSA.cpp (unfollow)
AgeCommit message (Expand)AuthorFilesLines
2023-08-19Introduce `bun --inspect-wait`Gravatar Jarred Sumner 3-19/+47
2023-08-19misc non-posix fixesGravatar Jarred Sumner 2-3/+3
2023-08-19Update lockfile.mdGravatar Jarred Sumner 1-1/+8
2023-08-19Update lockfile.mdGravatar Jarred Sumner 1-4/+4
2023-08-19Update lockfile.mdGravatar Jarred Sumner 1-1/+29
2023-08-19Update Dockerfile-distroless (#4210)Gravatar Omar 1-0/+1
2023-08-19Fix symbol visibilityGravatar Jarred Sumner 1-0/+1
2023-08-19[napi] Implement `node_api_create_syntax_error`, `node_api_symbol_for`, `nod...Gravatar Jarred Sumner 5-1/+70
2023-08-19Fix crash impacting sharp & resvg (#4221)Gravatar Jarred Sumner 5-73/+73
2023-08-19Fixes #172 (#4220)Gravatar Jarred Sumner 7-9/+87
2023-08-19Add inline sourcemaps when `--inspect` is enabled (#4213)Gravatar Jarred Sumner 3-3/+64
2023-08-19tty `ReadStream`, `WriteStream`, and readline rawmode (#4179)Gravatar Dylan Conway 23-722/+821
2023-08-18Fix make headers (again)Gravatar Jarred Sumner 1-0/+2