Port basic lib modules to TypeScript

This commit is contained in:
Hornwitser committed 2023-08-06 01:03:13 +02:00
1 parent 2988cd962c
commit e0c197b9bc
25 files changed
+1370 -1324

No files matched your search

+21
View File
@@ -0,0 +1,21 @@
/**
* Utilities for dealing with Lua
* @module lib/lua_tools
*/
/**
* Escapes a string for inclusion into a lua string
*
* @param content - String to escape.
* @returns Escaped string.
*/
export function escapeString(content: string) {
return content
.replace(/\\/g, "\\\\")
.replace(/"/g, '\\"')
.replace(/'/g, "\\'")
.replace(/\0/g, "\\0")
.replace(/\n/g, "\\n")
.replace(/\r/g, "\\r")
;
}