Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

magic-string

Package Overview
Dependencies
Maintainers
4
Versions
116
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.26.0 to 0.26.1

39

dist/magic-string.cjs.js

@@ -688,3 +688,7 @@ 'use strict';

const original = this.original.slice(start, end);
Object.defineProperty(this.storedNames, original, { writable: true, value: true, enumerable: true });
Object.defineProperty(this.storedNames, original, {
writable: true,
value: true,
enumerable: true,
});
}

@@ -1025,19 +1029,15 @@

replace(searchValue, replacement) {
function getReplacement(match) {
function getReplacement(match, str) {
if (typeof replacement === 'string') {
return replacement.replace(/\$(\$|&|\d+)/g, (_, i) => {
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#specifying_a_string_as_a_parameter
if (i === '$')
return '$';
if (i === '&')
return match[0];
if (i === '$') return '$';
if (i === '&') return match[0];
const num = +i;
if (num < match.length)
return match[+i];
if (num < match.length) return match[+i];
return `$${i}`;
});
} else {
return replacement(...match, match.index, str, match.groups);
}
else {
return replacement(...match);
}
}

@@ -1047,3 +1047,3 @@ function matchAll(re, str) {

const matches = [];
while (match = re.exec(str)) {
while ((match = re.exec(str))) {
matches.push(match);

@@ -1057,9 +1057,16 @@ }

if (match.index != null)
this.overwrite(match.index, match.index + match[0].length, getReplacement(match));
this.overwrite(
match.index,
match.index + match[0].length,
getReplacement(match, this.original)
);
});
}
else {
} else {
const match = this.original.match(searchValue);
if (match && match.index != null)
this.overwrite(match.index, match.index + match[0].length, getReplacement(match));
this.overwrite(
match.index,
match.index + match[0].length,
getReplacement(match, this.original)
);
}

@@ -1066,0 +1073,0 @@ return this;

@@ -746,3 +746,7 @@ (function (global, factory) {

const original = this.original.slice(start, end);
Object.defineProperty(this.storedNames, original, { writable: true, value: true, enumerable: true });
Object.defineProperty(this.storedNames, original, {
writable: true,
value: true,
enumerable: true,
});
}

@@ -1083,19 +1087,15 @@

replace(searchValue, replacement) {
function getReplacement(match) {
function getReplacement(match, str) {
if (typeof replacement === 'string') {
return replacement.replace(/\$(\$|&|\d+)/g, (_, i) => {
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#specifying_a_string_as_a_parameter
if (i === '$')
return '$';
if (i === '&')
return match[0];
if (i === '$') return '$';
if (i === '&') return match[0];
const num = +i;
if (num < match.length)
return match[+i];
if (num < match.length) return match[+i];
return `$${i}`;
});
} else {
return replacement(...match, match.index, str, match.groups);
}
else {
return replacement(...match);
}
}

@@ -1105,3 +1105,3 @@ function matchAll(re, str) {

const matches = [];
while (match = re.exec(str)) {
while ((match = re.exec(str))) {
matches.push(match);

@@ -1115,9 +1115,16 @@ }

if (match.index != null)
this.overwrite(match.index, match.index + match[0].length, getReplacement(match));
this.overwrite(
match.index,
match.index + match[0].length,
getReplacement(match, this.original)
);
});
}
else {
} else {
const match = this.original.match(searchValue);
if (match && match.index != null)
this.overwrite(match.index, match.index + match[0].length, getReplacement(match));
this.overwrite(
match.index,
match.index + match[0].length,
getReplacement(match, this.original)
);
}

@@ -1124,0 +1131,0 @@ return this;

{
"name": "magic-string",
"version": "0.26.0",
"version": "0.26.1",
"description": "Modify strings, generate sourcemaps",

@@ -5,0 +5,0 @@ "keywords": [

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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