Socket
Socket
Sign inDemoInstall

magic-string

Package Overview
Dependencies
Maintainers
1
Versions
115
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

magic-string - npm Package Compare versions

Comparing version 0.3.0 to 0.3.1

16

magic-string.js

@@ -575,3 +575,10 @@ (function (global, factory) {

} else {
this.replace( index, index, content );
var mapped = this.locate(index);
if ( mapped === null ) {
throw new Error( 'Cannot insert at replaced character index: ' + index );
}
this.str = this.str.substr( 0, mapped ) + content + this.str.substr( mapped );
adjust( this.mappings, index, this.mappings.length, content.length );
}

@@ -632,2 +639,9 @@

if ( firstChar > lastChar + 1 ) {
throw new Error(
'BUG! First character mapped to a position after the last character: ' +
'[' + start + ', ' + end + '] -> [' + firstChar + ', ' + ( lastChar + 1 ) + ']'
);
}
this.str = this.str.substr( 0, firstChar ) + content + this.str.substring( lastChar + 1 );

@@ -634,0 +648,0 @@

2

package.json

@@ -5,3 +5,3 @@ {

"author": "Rich Harris",
"version": "0.3.0",
"version": "0.3.1",
"repository": "https://github.com/rich-harris/magic-string",

@@ -8,0 +8,0 @@ "main": "magic-string.js",

@@ -9,3 +9,3 @@ # magic-string

Currently, magic-string only works in node.js (this will likely change in future):
magic-string works in both node.js and browser environments. For node, install with npm:

@@ -16,4 +16,15 @@ ```bash

To use in browser, you'll need to make [vlq](https://github.com/Rich-Harris/vlq) available. Add it, along with [magic-string.js](https://raw.githubusercontent.com/Rich-Harris/magic-string/master/magic-string.js), to your page:
```html
<script src='vlq.js'></script>
<script src='magic-string.js'></script>
```
(Both libraries also work with various module systems, if you prefer that sort of thing.)
## Usage
These examples assume you're in node.js, or something similar:
```js

@@ -169,2 +180,2 @@ var MagicString = require( 'magic-string' );

MIT
MIT
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc