magic-string
Advanced tools
Comparing version 0.1.3 to 0.1.4
# changelog | ||
## 0.1.4 | ||
* `s.locate()` doesn't throw out-of-bound error if index is equal to original string's length | ||
## 0.1.3 | ||
@@ -17,2 +21,2 @@ | ||
* First release | ||
* First release |
@@ -88,3 +88,3 @@ var guessIndent = require( './guessIndent' ), | ||
if ( character < 0 || character >= this.mappings.length ) { | ||
if ( character < 0 || character > this.mappings.length ) { | ||
throw new Error( 'Character is out of bounds' ); | ||
@@ -148,3 +148,3 @@ } | ||
firstChar = this.locate( start ); | ||
lastChar = this.locate( end ); | ||
lastChar = this.locate( end - 1 ) + 1; | ||
@@ -151,0 +151,0 @@ if ( firstChar === null || lastChar === null ) { |
{ | ||
"name": "magic-string", | ||
"author": "Rich Harris", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"main": "index.js", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
@@ -124,3 +124,3 @@ var assert = require( 'assert' ), | ||
assert.throws( function () { s.locate( -1 ); }); | ||
assert.throws( function () { s.locate( 12 ); }); | ||
assert.throws( function () { s.locate( 13 ); }); | ||
}); | ||
@@ -303,2 +303,9 @@ | ||
it( 'should replace characters at the end of the original string', function () { | ||
var s = new MagicString( 'abcdefghijkl' ); | ||
s.replace( 12, 12, '<<<' ); | ||
assert.equal( s.toString(), 'abcdefghijkl<<<' ); | ||
}); | ||
it( 'should return this', function () { | ||
@@ -352,2 +359,2 @@ var s = new MagicString( 'abcdefghijkl' ); | ||
}); | ||
}); | ||
}); |
24100
603