{"name":"code-block-writer","version":"7.0.0","description":"A simple code writer that assists with formatting and visualizing blocks of code.","main":"dist/code-block-writer.js","typings":"dist/code-block-writer.d.ts","scripts":{"test":"nyc --reporter=lcov mocha --opts mocha.opts","test-ci":"npm run test && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js","build":"rimraf dist && tsc","lint":"tslint src/**/*.ts","dopublish":"npm run build && npm publish"},"repository":{"type":"git","url":"git+https://github.com/dsherret/code-block-writer.git"},"keywords":["decorators","typescript","routes"],"author":{"name":"David Sherret"},"license":"MIT","bugs":{"url":"https://github.com/dsherret/code-block-writer/issues"},"homepage":"https://github.com/dsherret/code-block-writer#readme","nyc":{"extension":[".ts",".tsx"],"include":["src/**/*.ts","!src/tests/**/*.ts"],"reporter":["html"],"all":true},"typescript":{"definition":"code-block-writer.d.ts"},"dependencies":{},"devDependencies":{"@types/mocha":"^2.2.44","@types/node":"^8.0.53","coveralls":"^2.13.1","mocha":"^3.3.0","nyc":"^11.6.0","source-map-support":"^0.5.4","ts-node":"^5.0.1","tslint":"^5.6.0","typescript":"^2.8.1"},"gitHead":"00a9d19c7391457778f3c647588ee3f826d1f831","_id":"code-block-writer@7.0.0","_shasum":"8d5ab347ce5c130b8fa50df59684096792a6661f","_from":".","_npmVersion":"3.8.8","_nodeVersion":"8.5.0","_npmUser":{"name":"dsherret","email":"dsherret@gmail.com"},"dist":{"shasum":"8d5ab347ce5c130b8fa50df59684096792a6661f","tarball":"http://registry-npm.ywwl.com/code-block-writer/download/code-block-writer-7.0.0.tgz","fileCount":21,"unpackedSize":184653,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJa5gywCRA9TVsSAnZWagAAB1sQAIloyRLf0HGhmfG3ZD2x\nBvMQB7zet7zi5ZRZNDRcWzofu9t27cqmkQexfbpGT6qwFnj45D8M8bcy56Zl\nsNmfGsaMggjay7nTRfe2uVDef5nCzP4FrS+g3STxfI9GBNMY57dNE3iSinxB\nfotSlBtRtOZn8iCZjX1D8ejvjgg3GTc8qN00KxDY3C0F3ILMArxEEs4LLJC+\nR010XrgyU/NhQsFAxvG48wYI4NXgVXyiESGBvKqyn/JMu3Dnf5XTdPwzDckx\nvYZSAQJOa7jRxoApL1Hw33zRy5NtjE83F4suXNTW6t7Wl49TlF1j4LmZ9Yc9\nk9POgZ2sdukA7xHv71m6LNNkAffi/foykq18DmzzGUFxZMzLX3b/2MKvshAx\nt96BierL//vth5uvp4Mi/xdtDY/LM8sEChYF73Z+Qr5JXb0Py6gK46bS1YVz\nbZsCQQFdAU9FMsbuL3sgCbTtNIWpRJydU/Pg6VxzPm3vBg4XeWyra6Jzgsqm\nFMEE+xjDIg+GmRAQnHUlR0ellx3Ft6r6L8RK5zY8uPcIyF7Gqm8kzfjMopzc\n1Uw7J8Bu0w0qZ9lCZGLtC8MxAIH3FZiPScMJXM7/Rai7fkjo5KKPWJI7UcSg\nr/XMDKHytxn1s5eSP52RxZiVY5IXe4Js6aA8JaHONrIIds4tl4gYSLutvdAr\n9eAT\r\n=l2kZ\r\n-----END PGP SIGNATURE-----\r\n","integrity":"sha512-xRfCDSa5jxsHraDxG8tQodMmOPa8bmdhP+UpAYUkUZIz1NirMMZOUup1aBwTIMJU6CXiWaOLN0OBkpueN9hANQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEQzaWzBRAnPSY3N9MdJTK2OT6EcdaHyLhj9KuZvHH0dAiEAmwfoh0JxaXp73kPCQDzKDB2OJ0t9P8K6JSu85Pp7JYs="}],"size":39837,"noattachment":false,"key":"/code-block-writer/-/code-block-writer-7.0.0.tgz"},"maintainers":[{"name":"dsherret","email":"dsherret@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/code-block-writer_7.0.0_1525025966746_0.5937489465719648"},"_hasShrinkwrap":false,"readme":"# code-block-writer\n\n[![npm version](https://badge.fury.io/js/code-block-writer.svg)](https://badge.fury.io/js/code-block-writer)\n[![CI](https://github.com/dsherret/code-block-writer/workflows/CI/badge.svg)](https://github.com/dsherret/code-block-writer/actions?query=workflow%3ACI)\n[![deno doc](https://doc.deno.land/badge.svg)](https://doc.deno.land/https/deno.land/x/code_block_writer/mod.ts)\n[![stable](http://badges.github.io/stability-badges/dist/stable.svg)](http://github.com/badges/stability-badges)\n\nCode writer for JavaScript and TypeScript code.\n\nWith Deno:\n\n```ts\nimport CodeBlockWriter from \"https://deno.land/x/code_block_writer/mod.ts\";\n```\n\nOr with Node:\n\n```\nnpm install --save code-block-writer\n```\n\n## Example\n\n<!-- dprint-ignore -->\n\n```typescript\nimport CodeBlockWriter from \"https://deno.land/x/code_block_writer/mod.ts\";\n\nconst writer = new CodeBlockWriter({\n  // optional options\n  newLine: \"\\r\\n\",         // default: \"\\n\"\n  indentNumberOfSpaces: 2, // default: 4\n  useTabs: false,          // default: false\n  useSingleQuote: true     // default: false\n});\n\nwriter.write(\"class MyClass extends OtherClass\").block(() => {\n  writer.writeLine(`@MyDecorator(1, 2)`);\n  writer.write(`myMethod(myParam: any)`).block(() => {\n    writer.write(\"return this.post(\").quote(\"myArgument\").write(\");\");\n  });\n});\n\nconsole.log(writer.toString());\n```\n\nOutputs (using \"\\r\\n\" for newlines):\n\n<!-- dprint-ignore -->\n\n```js\nclass MyClass extends OtherClass {\n  @MyDecorator(1, 2)\n  myMethod(myParam: any) {\n    return this.post('myArgument');\n  }\n}\n```\n\n## Methods\n\n- `block(block?: () => void)` - Indents all the code written within and surrounds it in braces.\n- `inlineBlock(block?: () => void)` - Same as block, but doesn't add a space before the first brace and doesn't add a newline at the end.\n- `getLength()` - Get the current number of characters.\n- `writeLine(text: string)` - Writes some text and adds a newline.\n- `newLine()` - Writes a newline.\n- `newLineIfLastNot()` - Writes a newline if what was written last wasn't a newline.\n- `blankLine()` - Writes a blank line. Does not allow consecutive blank lines.\n- `blankLineIfLastNot()` - Writes a blank line if what was written last wasn't a blank line.\n- `quote()` - Writes a quote character.\n- `quote(text: string)` - Writes text surrounded in quotes.\n- `indent(times?: number)` - Indents the current line. Optionally indents multiple times when providing a number.\n- `indent(block?: () => void)` - Indents a block of code.\n- `space(times?: number)` - Writes a space. Optionally writes multiple spaces when providing a number.\n- `spaceIfLastNot()` - Writes a space if the last was not a space.\n- `tab(times?: number)` - Writes a tab. Optionally writes multiple tabs when providing a number.\n- `tabIfLastNot()` - Writes a tab if the last was not a tab.\n- `write(text: string)` - Writes some text.\n- `conditionalNewLine(condition: boolean)` - Writes a newline if the condition is matched.\n- `conditionalBlankLine(condition: boolean)` - Writes a blank line if the condition is matched.\n- `conditionalWrite(condition: boolean, text: string)` - Writes if the condition is matched.\n- `conditionalWrite(condition: boolean, textFunc: () => string)` - Writes if the condition is matched.\n- `conditionalWriteLine(condition: boolean, text: string)` - Writes some text and adds a newline if the condition is matched.\n- `conditionalWriteLine(condition: boolean, textFunc: () => string)` - Writes some text and adds a newline if the condition is matched.\n- `setIndentationLevel(indentationLevel: number)` - Sets the current indentation level.\n- `setIndentationLevel(whitespaceText: string)` - Sets the current indentation level based on the provided whitespace text.\n- `withIndentationLevel(indentationLevel: number, action: () => void)` - Sets the indentation level within the provided action.\n- `withIndentationLevel(whitespaceText: string, action: () => void)` - Sets the indentation level based on the provided whitespace text within the action.\n- `getIndentationLevel()` - Gets the current indentation level.\n- `queueIndentationLevel(indentationLevel: number)` - Queues an indentation level to be used once a new line is written.\n- `queueIndentationLevel(whitespaceText: string)` - Queues an indentation level to be used once a new line is written based on the provided whitespace text.\n- `hangingIndent(action: () => void)` - Writes the code within the action with hanging indentation.\n- `hangingIndentUnlessBlock(action: () => void)` - Writes the code within the action with hanging indentation unless a block is written going from the first line to the second.\n- `closeComment()` - Writes text to exit a comment if in a comment.\n- `unsafeInsert(pos: number, text: string)` - Inserts text into the writer. This will not update the writer's state. Read more in its jsdoc.\n- `isInComment()` - Gets if the writer is currently in a comment.\n- `isAtStartOfFirstLineOfBlock()` - Gets if the writer is currently at the start of the first line of the text, block, or indentation block.\n- `isOnFirstLineOfBlock()` - Gets if the writer is currently on the first line of the text, block, or indentation block.\n- `isInString()` - Gets if the writer is currently in a string.\n- `isLastNewLine()` - Gets if the writer last wrote a newline.\n- `isLastBlankLine()` - Gets if the writer last wrote a blank line.\n- `isLastSpace()` - Gets if the writer last wrote a space.\n- `isLastTab()` - Gets if the writer last wrote a tab.\n- `getLastChar()` - Gets the last character written.\n- `endsWith(text: string)` - Gets if the writer ends with the provided text.\n- `iterateLastChars<T>(action: (char: string, index: number) => T | undefined): T | undefined` - Iterates over the writer's characters in reverse order, stopping once a non-null or undefined value is returned and returns that value.\n- `iterateLastCharCodes<T>(action: (charCode: number, index: number) => T | undefined): T | undefined` - A slightly faster version of `iterateLastChars` that doesn't allocate a string per character.\n- `getOptions()` - Gets the writer options.\n- `toString()` - Gets the string.\n\n## Other Features\n\n- Does not indent within strings.\n- Escapes newlines within double and single quotes created with `.quote(text)`.\n\n## C# Version\n\nSee [CodeBlockWriterSharp](https://github.com/dsherret/CodeBlockWriterSharp).\n","publish_time":1525025966854,"_cnpm_publish_time":1525025966854,"dist-tags":{"latest":"13.0.3"}}