Skip to content

Commit

Permalink
Remove delimiter logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Wise-StenRaudmets committed Jan 29, 2024
1 parent be9d6e4 commit e660c2d
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 172 deletions.
24 changes: 0 additions & 24 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -127849,36 +127849,12 @@ function getSign(bytes) {
}

;// CONCATENATED MODULE: ./src/text-format.ts
function createHtmlComment(content) {
return `<!-- ${content} -->`;
}
function getAppNameDelimiter(appName) {
return {
start: createHtmlComment(`${appName} start`),
end: createHtmlComment(`${appName} end`),
};
}
function formatTextFragments(...text) {
return text
.map((fragment) => fragment.trim())
.filter(Boolean)
.join('\n\n');
}
function swapContentPartiallyByDelimiter({ existingContent, newPartialContent, delimiterIdentifier, }) {
const delimiter = getAppNameDelimiter(delimiterIdentifier);
const startIndex = existingContent.indexOf(delimiter.start);
const endIndex = existingContent.indexOf(delimiter.end, startIndex);
if (startIndex === -1 || endIndex === -1) {
return formatTextFragments(existingContent, delimiter.start, newPartialContent, delimiter.end);
}
const existingBodyStart = existingContent.substring(0, startIndex);
const existingBodyEnd = existingContent.substring(endIndex + delimiter.end.length);
return formatTextFragments(existingBodyStart, delimiter.start, newPartialContent, delimiter.end, existingBodyEnd);
}
function createContentByDelimiter({ title, content, delimiterIdentifier, }) {
const appNameDelimiter = getAppNameDelimiter(delimiterIdentifier);
return formatTextFragments(title, appNameDelimiter.start, content, appNameDelimiter.end);
}

;// CONCATENATED MODULE: ./src/comments.ts

Expand Down
97 changes: 0 additions & 97 deletions src/text-format.test.ts

This file was deleted.

51 changes: 0 additions & 51 deletions src/text-format.ts
Original file line number Diff line number Diff line change
@@ -1,57 +1,6 @@
function createHtmlComment(content: string) {
return `<!-- ${content} -->`;
}

function getAppNameDelimiter(appName: string) {
return {
start: createHtmlComment(`${appName} start`),
end: createHtmlComment(`${appName} end`),
} as const;
}

export function formatTextFragments(...text: string[]) {
return text
.map((fragment) => fragment.trim())
.filter(Boolean)
.join('\n\n');
}

export function swapContentPartiallyByDelimiter({
existingContent,
newPartialContent,
delimiterIdentifier,
}: {
existingContent: string;
newPartialContent: string;
delimiterIdentifier: string;
}) {
const delimiter = getAppNameDelimiter(delimiterIdentifier);
const startIndex = existingContent.indexOf(delimiter.start);
const endIndex = existingContent.indexOf(delimiter.end, startIndex);
if (startIndex === -1 || endIndex === -1) {
return formatTextFragments(existingContent, delimiter.start, newPartialContent, delimiter.end);
}
const existingBodyStart = existingContent.substring(0, startIndex);
const existingBodyEnd = existingContent.substring(endIndex + delimiter.end.length);

return formatTextFragments(
existingBodyStart,
delimiter.start,
newPartialContent,
delimiter.end,
existingBodyEnd,
);
}

export function createContentByDelimiter({
title,
content,
delimiterIdentifier,
}: {
title: string;
content: string;
delimiterIdentifier: string;
}) {
const appNameDelimiter = getAppNameDelimiter(delimiterIdentifier);
return formatTextFragments(title, appNameDelimiter.start, content, appNameDelimiter.end);
}

0 comments on commit e660c2d

Please sign in to comment.