line-counter
Advanced tools
Comparing version 1.0.0 to 1.0.3
@@ -7,4 +7,8 @@ # Change log | ||
## [Unreleased][unreleased] | ||
## v1.0.3 - 2015-05-11 | ||
### Fix | ||
- Issue #1: Endless-Loop calling `.upTo(content.length)` for contents that end with a new-line. | ||
## v1.0.2 - 2015-05-10 | ||
### Added | ||
- Initial version of the line-counter module |
@@ -70,2 +70,8 @@ /* | ||
this.countUpTo = function (upTo) { | ||
if (upTo >= contents.length) { | ||
throw new Error( | ||
"Index out of bounds! " + | ||
"Index " + upTo + " is not beyound the end of the string." | ||
) | ||
} | ||
if (upTo < startOfLineIndex) { | ||
@@ -72,0 +78,0 @@ throw new Error( |
{ | ||
"name": "line-counter", | ||
"version": "1.0.0", | ||
"version": "1.0.3", | ||
"description": "A simple class that allows to count lines while iterating over a string", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -97,3 +97,24 @@ var LineCounter = require("../index.js"); | ||
)); | ||
}) | ||
}); | ||
it("should throw an error, if `upTo` in an index out of bounds" , function() { | ||
var lc = new LineCounter("abc\ndef"); | ||
expect(function() { | ||
lc.countUpTo(7); | ||
}).toThrow(new Error( | ||
"Index out of bounds! " + | ||
"Index 7 is not beyound the end of the string." | ||
)); | ||
}); | ||
it("should throw an error, if `upTo` in an index out of bounds (for string ending with newline)" , function() { | ||
var lc = new LineCounter("abc\ndef\n"); | ||
expect(function() { | ||
lc.countUpTo(8); | ||
}).toThrow(new Error( | ||
"Index out of bounds! " + | ||
"Index 8 is not beyound the end of the string." | ||
)); | ||
}); | ||
}); |
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
17551
243