{"id":17322298,"url":"https://github.com/morsby/string-escape-spacing","last_synced_at":"2025-04-06T10:41:54.993Z","repository":{"id":42882704,"uuid":"255862847","full_name":"morsby/string-escape-spacing","owner":"morsby","description":"Javascript package that escapes spacing characters (eg. newline) in strings","archived":false,"fork":false,"pushed_at":"2023-03-04T12:24:26.000Z","size":1015,"stargazers_count":0,"open_issues_count":4,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-12T16:19:21.413Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/morsby.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-04-15T09:08:23.000Z","updated_at":"2022-02-13T08:48:06.000Z","dependencies_parsed_at":"2023-02-05T05:15:15.427Z","dependency_job_id":null,"html_url":"https://github.com/morsby/string-escape-spacing","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morsby%2Fstring-escape-spacing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morsby%2Fstring-escape-spacing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morsby%2Fstring-escape-spacing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morsby%2Fstring-escape-spacing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/morsby","download_url":"https://codeload.github.com/morsby/string-escape-spacing/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247471288,"owners_count":20944153,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-15T13:41:37.888Z","updated_at":"2025-04-06T10:41:54.975Z","avatar_url":"https://github.com/morsby.png","language":"TypeScript","readme":"# string-escape-spacing\n\n## Background\n\nA small javascript package for escaping special characters interpreted as spacing in strings.\n\nImagine you're writing a code snippet in a template string.\n\n```js\nconst code = `fmt.Printf(\"%06d\\n\",1)`;\n```\n\nIf you then did a `console.log` (or any other outputting), you'd get\n\n```\nfmt.Printf(\"%06d\n\",1)\n```\n\nHey, that's not what you wanted! 😭\n\nObviously, you could escape the backslash (`\\n` → `\\\\n`) but that's not how you'd actually write the code.\n\n_Enter **string-escape-spacing**_! It works by looking for unescaped spacing characters (i.e. `\\n`, `\\r`, `\\t`, `\\v` ) enclosed in string characters (`\"The\\tdog\\twas\\tlazy\"`) whilst ignoring the string if it had no quotes around it (`The\\tdog\\twas\\tlazy`).\n\n## Usage\n\n### Installation\n\n```\nyarn add string-escape-spacing\nnpm install string-escape-spacing\n```\n\n### Example\n\n```js\nimport escapeString from \"string-escape-spacing\";\n\nconst string = `\"The\\tdog\\twas\\tlazy\"`;\nconsole.log(escapeString(string));\n// output:`\"The\\\\tdog\\\\twas\\\\tlazy\"`\n```\n\n### API\n\n```js\nconst escaped = escapeString(stringToEscape, options);\n```\n\n**Options**\n\n```js\noptions = {\n  quotes: \"single\" | \"double\",\n};\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmorsby%2Fstring-escape-spacing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmorsby%2Fstring-escape-spacing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmorsby%2Fstring-escape-spacing/lists"}