UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

90 lines 2.25 kB
export default LineBuilder; /** * Useful for generating formatted snippets of code. * @example * const b = new LineBuilder(); * b.add("function hello(){"); * b.indent(); * b.add("return \"hello world\";"); * b.dedent(); * b.add("}"); * b.build(); * // function hello(){ * // return "hello world"; * // } */ declare class LineBuilder { /** * @param {string} text * @param {string} [line_separator] defaults to new-line character * @returns {LineBuilder} */ static fromText(text: string, line_separator?: string): LineBuilder; /** * Current indentation level * Mainly intended for testing * @return {number} */ get indentation(): number; /** * TODO replace with indent string, that is tab, space or any combination or something else entirely * @private * @type {number} */ private indentSpaces; /** * Number of lines * @return {number} */ get count(): number; /** * Substring test of per-line basis. A match can only span a single line, so multi-line matches will not be found. * @return {boolean} * @param {string} term */ containsSubstring(term: string): boolean; /** * * @returns {LineBuilder} */ indent(): LineBuilder; /** * NOTE: clamps indentation to 0 (can't go negative) * @returns {LineBuilder} */ dedent(): LineBuilder; /** * Adds an entire new line with a given text. * Inherits the current indentation level. * @param {string} line_text * @returns {LineBuilder} */ add(line_text: string): LineBuilder; /** * Appends text to the last line. * * @param {string} text * @returns {void} * @example * const b = new LineBuilder(); * b.add("hello"); * b.extend(" world"); * b.build(); // "hello world" * */ extend(text: string): void; /** * * @param {LineBuilder} lines */ addLines(lines: LineBuilder): void; clear(): void; /** * Renders out an indented string of lines * @returns {string} */ build(): string; toString(): string; #private; } //# sourceMappingURL=LineBuilder.d.ts.map