code-block-writer
Advanced tools
Comparing version 6.11.0 to 6.12.0
@@ -5,2 +5,17 @@ # Change Log | ||
<a name="6.12.0"></a> | ||
# [6.12.0](https://github.com/dsherret/code-block-writer/compare/v6.11.0...v6.12.0) (2018-04-07) | ||
### Bug Fixes | ||
* Remove warning for now. ([ee36fac](https://github.com/dsherret/code-block-writer/commit/ee36fac)) | ||
### Features | ||
* Add .isAtStartOfFirstLineOfBlock() ([d5eda32](https://github.com/dsherret/code-block-writer/commit/d5eda32)) | ||
<a name="6.11.0"></a> | ||
@@ -7,0 +22,0 @@ # [6.11.0](https://github.com/dsherret/code-block-writer/compare/v6.10.0...v6.11.0) (2018-04-07) |
@@ -154,2 +154,6 @@ export default class CodeBlockWriter { | ||
/** | ||
* Gets if the writer is currently at the start of the first line of the text, block, or indentation block. | ||
*/ | ||
isAtStartOfFirstLineOfBlock(): boolean; | ||
/** | ||
* Gets if the writer is currently on the first line of the text, block, or indentation block. | ||
@@ -156,0 +160,0 @@ */ |
@@ -233,2 +233,8 @@ "use strict"; | ||
/** | ||
* Gets if the writer is currently at the start of the first line of the text, block, or indentation block. | ||
*/ | ||
CodeBlockWriter.prototype.isAtStartOfFirstLineOfBlock = function () { | ||
return this.isOnFirstLineOfBlock() && (this.isLastNewLine() || this.getLastChar() == null); | ||
}; | ||
/** | ||
* Gets if the writer is currently on the first line of the text, block, or indentation block. | ||
@@ -235,0 +241,0 @@ */ |
{ | ||
"name": "code-block-writer", | ||
"version": "6.11.0", | ||
"version": "6.12.0", | ||
"description": "A simple code writer that assists with formatting and visualizing blocks of code.", | ||
@@ -5,0 +5,0 @@ "main": "dist/code-block-writer.js", |
@@ -75,2 +75,3 @@ code-block-writer | ||
* `isInComment()` - Gets if the writer is currently in a comment. | ||
* `isAtStartOfFirstLineOfBlock()` - Gets if the writer is currently at the start of the first line of the text, block, or indentation block. | ||
* `isOnFirstLineOfBlock()` - Gets if the writer is currently on the first line of the text, block, or indentation block. | ||
@@ -77,0 +78,0 @@ * `isInString()` - Gets if the writer is currently in a string. |
@@ -305,2 +305,9 @@ import {stringRepeat, escapeForWithinString} from "./utils/stringUtils"; | ||
/** | ||
* Gets if the writer is currently at the start of the first line of the text, block, or indentation block. | ||
*/ | ||
isAtStartOfFirstLineOfBlock() { | ||
return this.isOnFirstLineOfBlock() && (this.isLastNewLine() || this.getLastChar() == null); | ||
} | ||
/** | ||
* Gets if the writer is currently on the first line of the text, block, or indentation block. | ||
@@ -307,0 +314,0 @@ */ |
@@ -982,2 +982,3 @@ import * as assert from "assert"; | ||
const writer = new CodeBlockWriter(); | ||
assertState(true); | ||
writer.writeLine("testing"); | ||
@@ -1010,2 +1011,43 @@ assertState(false); | ||
describe("#isAtStartOfFirstLineOfBlock", () => { | ||
function doTest(str: string, expectedValues: boolean[]) { | ||
runSequentialCheck(str, expectedValues, writer => writer.isAtStartOfFirstLineOfBlock()); | ||
} | ||
it("should be true only for the first", () => { | ||
doTest("t \t\n", [true, false, false, false, false]); | ||
}); | ||
it("should be true when on a new block at the start", () => { | ||
const writer = new CodeBlockWriter(); | ||
assertState(true); | ||
writer.writeLine("testing"); | ||
assertState(false); | ||
writer.inlineBlock(() => { | ||
assertState(true); | ||
writer.write(" "); | ||
assertState(false); | ||
writer.newLine(); | ||
assertState(false); | ||
writer.indentBlock(() => { | ||
assertState(true); | ||
writer.write("testing\n"); | ||
assertState(false); | ||
writer.write("more\n"); | ||
assertState(false); | ||
}); | ||
assertState(false); | ||
writer.block(() => { | ||
assertState(true); | ||
}); | ||
assertState(false); | ||
}); | ||
assertState(false); | ||
function assertState(state: boolean) { | ||
assert.equal(writer.isAtStartOfFirstLineOfBlock(), state); | ||
} | ||
}); | ||
}); | ||
describe("#isLastNewLine", () => { | ||
@@ -1012,0 +1054,0 @@ function doTest(str: string, expectedValues: boolean[], customWriter?: CodeBlockWriter) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
196415
2282
83