Skip to content

chore: fix typos #167

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions lib/ReplaceSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ class ReplaceSource extends Source {
const replacements = this._replacements;
let pos = 0;
let i = 0;
let replacmentEnd = -1;
let replacementEnd = -1;
let nextReplacement =
i < replacements.length
? Math.floor(replacements[i].start)
Expand Down Expand Up @@ -257,9 +257,9 @@ class ReplaceSource extends Source {
let endPos = pos + chunk.length;

// Skip over when it has been replaced
if (replacmentEnd > pos) {
if (replacementEnd > pos) {
// Skip over the whole chunk
if (replacmentEnd >= endPos) {
if (replacementEnd >= endPos) {
const line = generatedLine + generatedLineOffset;
if (chunk.endsWith("\n")) {
generatedLineOffset--;
Expand All @@ -278,7 +278,7 @@ class ReplaceSource extends Source {
}

// Partially skip over chunk
chunkPos = replacmentEnd - pos;
chunkPos = replacementEnd - pos;
if (
checkOriginalContent(
sourceIndex,
Expand Down Expand Up @@ -384,23 +384,23 @@ class ReplaceSource extends Source {
}

// Remove replaced content by settings this variable
replacmentEnd = Math.max(
replacmentEnd,
replacementEnd = Math.max(
replacementEnd,
Math.floor(replacements[i].end + 1)
);

// Move to next replacment
// Move to next replacement
i++;
nextReplacement =
i < replacements.length
? Math.floor(replacements[i].start)
: MAX_SOURCE_POSITION;

// Skip over when it has been replaced
const offset = chunk.length - endPos + replacmentEnd - chunkPos;
const offset = chunk.length - endPos + replacementEnd - chunkPos;
if (offset > 0) {
// Skip over whole chunk
if (replacmentEnd >= endPos) {
if (replacementEnd >= endPos) {
let line = generatedLine + generatedLineOffset;
if (chunk.endsWith("\n")) {
generatedLineOffset--;
Expand Down
2 changes: 1 addition & 1 deletion lib/helpers/createMappingsSerializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const createFullMappingsSerializer = () => {
} else {
// No mapping is active
if (sourceIndex < 0) {
// avoid writing unneccessary generated mappings
// avoid writing unnecessary generated mappings
return "";
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/ReplaceSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ export default function StaticPage(_ref) {
`);
});

it("should not generate invalid mappings when replacing mulitple lines of code", () => {
it("should not generate invalid mappings when replacing multiple lines of code", () => {
const source = new ReplaceSource(
new OriginalSource(
["if (a;b;c) {", " a; b; c;", "}"].join("\n"),
Expand Down