{"id":22763547,"url":"https://github.com/mearns/text-scribe","last_synced_at":"2025-06-18T19:32:13.095Z","repository":{"id":78409851,"uuid":"87571318","full_name":"mearns/text-scribe","owner":"mearns","description":"Simple Javascript module for writing lines of text with indenting","archived":false,"fork":false,"pushed_at":"2017-04-07T20:25:55.000Z","size":13,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-10T13:54:47.738Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/mearns.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-04-07T17:38:33.000Z","updated_at":"2017-04-07T19:44:18.000Z","dependencies_parsed_at":"2023-03-02T01:30:27.779Z","dependency_job_id":null,"html_url":"https://github.com/mearns/text-scribe","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/mearns/text-scribe","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mearns%2Ftext-scribe","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mearns%2Ftext-scribe/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mearns%2Ftext-scribe/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mearns%2Ftext-scribe/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mearns","download_url":"https://codeload.github.com/mearns/text-scribe/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mearns%2Ftext-scribe/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259742564,"owners_count":22904604,"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-12-11T11:08:57.740Z","updated_at":"2025-06-18T19:32:08.085Z","avatar_url":"https://github.com/mearns.png","language":"JavaScript","readme":"# text-scribe\n\nA simple Javascript module for writing lines of text with indenting.\n\n## Example\n\n```javascript\nimport {TextWriter} from 'text-writer';\n\nconst writer = new TextWriter();\n\nwriter.write('Hello').write(', World!').endline()\n    .writeline('Here is a new line for you!')\n    .indent()\n    .writeline('This line is indented.')\n    .writeline('This one, too.')\n    .indent(2).writeline('This one is indented 3 times!')\n    .outdent().writeline('This is only indented 2 times.')\n    .setLevel().writeline('This one is back to no-indent.')\n    .skipline()\n    .writeline('Maybe this is a new paragraph, or something.')\n    .endline()\n    .write('This is still just on the next line, because the line was already ended.')\n    .endline()\n    .write('Next line, again.')\n    .endline().endline().endline()\n    .writeline('It is idempotent when invoked multiple times in a row.');\n\nconsole.log(writer.toString());\n```\n\nThe above code will write the following to console (including a blank line at the end).\n\n```\nHello, World!\nHere is a new line for you!\n    This line is indented.\n    This one, too.\n            This one is indented 3 times!\n        This is only indented 2 times.\nThis one is back to no-indent.\n\nMaybe this is a new paragraph, or something.\nThis is still just on the next line, because the line was already ended.\nNext line, again.\nIt is idempotent when invoked multiple times in a row.\n\n```\n\n## Install\n\nInstall via npm:\n\n```bash\nnpm install --save text-scribe\n```\n\n## License\n\nMIT\n\n## API\n\n### class `TextWriter`\n\n#### constructor: `new TextWriter({initialLevel = 0, tab = 4, linesep = '\\n'})`\n\nThe `initialLevel` param specifies the initial indent level, and defaults to 0.\n\nThe `tab` param specifies what to use for the tab at the beginning of each line,\nfor each level of indent. If a number, it specifies the number of ASCII space characters\nto use for a tab. Otherwise, it is used as a string. The default is a string of four spaces.\n\nThe `linesep` param specifies what to use between lines. The default is a JavaScript linebreak,\n`'\\n'`.\n\n#### `.write(text)` _(chainable)_\n\nAppend the given text to the current line.\n\n#### `.writeline(text)` _(chainable)_\n\nAppend the given text to the current line, and then end the line. Subsequent writes\nwill be appended to subequent lines.\n\n#### `.indent(amt = 1)` _(chainable)_\n\nIncrease the current _indent level_ by the specified amount, default is 1 level.\nNegative values work as well, but the level is clamped at a minimum of 0.\n\n#### `.outdent(amt = 1)` _(chainable)_\n\nDecrease the current _indent level_ by the specified amount, default is 1 level.\nNegative values work as well, but the level is clamped at a minimum of 0.\n\n#### `.setLevel(level = 0)` _(chainable)_\n\nSet the current _indent level_ to the specified value, clamped to a minimum of 0.\n\n#### `.newline()` _(chainable)_\n\nEnd the current line and create a new (null) line after it. This is the same as\ncalling `writeLine` with no argument.\n\n#### `.blankline()` _(chainable)_\n\nA convenience function for calling `newline()` twice in a row, leaving a blank\nline following the current line.\n\n#### `.endline()` _(chainable)_\n\nIf the current line is non-null, end it. Otherwise, do nothing.\n\n#### `.skipline()` _(chainable)_\n\nEnsures the current line is ended (as with `endline()`), and then adds a new line.\nThis is similar to `blankline()` except that if the current line is already _null_,\nit _does not_ end it.\n\n#### `toString()`\n\nRenders the currently written text to a single string, using the currently configured\n`linesep` and `tab` values.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmearns%2Ftext-scribe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmearns%2Ftext-scribe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmearns%2Ftext-scribe/lists"}