aboutsummaryrefslogtreecommitdiff
path: root/src/js/builtins/codegen/helpers.ts
diff options
context:
space:
mode:
authorGravatar dave caruso <me@paperdave.net> 2023-06-01 21:16:47 -0400
committerGravatar GitHub <noreply@github.com> 2023-06-01 18:16:47 -0700
commit4df1d37ddc54242c339765f22fb90ba2e9e3a99a (patch)
treed63ede76463e7ecba78a4d4b31e5e8158193552f /src/js/builtins/codegen/helpers.ts
parent03ffd1c732aaaa30b5481f197221ce96da559e63 (diff)
downloadbun-4df1d37ddc54242c339765f22fb90ba2e9e3a99a.tar.gz
bun-4df1d37ddc54242c339765f22fb90ba2e9e3a99a.tar.zst
bun-4df1d37ddc54242c339765f22fb90ba2e9e3a99a.zip
Bundle and minify `.exports.js` files. (#3036)
* move all exports.js into src/js * finalize the sort of this * and it works * add test.ts to gitignore * okay * convert some to ts just to show * finish up * fixup makefile * minify syntax in dev * finish rebase * dont minify all modules * merge * finish rebase merge * flaky test that hangs
Diffstat (limited to 'src/js/builtins/codegen/helpers.ts')
-rw-r--r--src/js/builtins/codegen/helpers.ts25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/js/builtins/codegen/helpers.ts b/src/js/builtins/codegen/helpers.ts
new file mode 100644
index 000000000..6345f8ffa
--- /dev/null
+++ b/src/js/builtins/codegen/helpers.ts
@@ -0,0 +1,25 @@
+export function fmtCPPString(str: string) {
+ return (
+ '"' +
+ str
+ .replace(/\\/g, "\\\\")
+ .replace(/"/g, '\\"')
+ .replace(/\n/g, "\\n")
+ .replace(/\r/g, "\\r")
+ .replace(/\t/g, "\\t")
+ .replace(/\?/g, "\\?") + // https://stackoverflow.com/questions/1234582
+ '"'
+ );
+}
+
+export function cap(str: string) {
+ return str[0].toUpperCase() + str.slice(1);
+}
+
+export function low(str: string) {
+ if (str.startsWith("JS")) {
+ return "js" + str.slice(2);
+ }
+
+ return str[0].toLowerCase() + str.slice(1);
+}