diff options
author | 2023-05-22 18:51:05 -0700 | |
---|---|---|
committer | 2023-05-22 18:51:05 -0700 | |
commit | fc40c690ea30a632a8d0d9490321c50ec898d8a5 (patch) | |
tree | 6e3ca0bb2c02347006a6b2a09c4aa156b86bd770 /src/bun.js/builtins/codegen/helpers.ts | |
parent | 23d42dc2377440dedc9d8e423f1ea077507d62c8 (diff) | |
download | bun-fc40c690ea30a632a8d0d9490321c50ec898d8a5.tar.gz bun-fc40c690ea30a632a8d0d9490321c50ec898d8a5.tar.zst bun-fc40c690ea30a632a8d0d9490321c50ec898d8a5.zip |
Write out builtins with TypeScript + Minify them (#2999)
* start work drafting how builtins will work
* work on ts builtin
* builtins stuff so far
* builtins
* done for today
* continue work
* working on it
* bindings so far
* well, it builds. doesnt run
* IT RUNS
* still lots of ts errors but it is functional
* sloppy mode
Diffstat (limited to 'src/bun.js/builtins/codegen/helpers.ts')
-rw-r--r-- | src/bun.js/builtins/codegen/helpers.ts | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/bun.js/builtins/codegen/helpers.ts b/src/bun.js/builtins/codegen/helpers.ts new file mode 100644 index 000000000..6345f8ffa --- /dev/null +++ b/src/bun.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); +} |