@docaohuynh/ielts-api-utils 1.0.11 → 1.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -644,6 +644,24 @@ function removeEmptyLines(str) {
644
644
  return str.split(/\r?\n/).filter((line) => line.trim() !== "").join(`
645
645
  `);
646
646
  }
647
+ // src/utils/strings/remove-string.util.ts
648
+ function removeWordsFromText(text, words) {
649
+ if (!text || !words || words.length === 0) {
650
+ return text;
651
+ }
652
+ const escapedWords = words.map((word) => {
653
+ const escapedWord = word.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
654
+ const startsWithSpecialChar = /^\W/.test(word);
655
+ const endsWithSpecialChar = /\W$/.test(word);
656
+ if (startsWithSpecialChar || endsWithSpecialChar) {
657
+ return escapedWord;
658
+ } else {
659
+ return `\\b${escapedWord}\\b`;
660
+ }
661
+ });
662
+ const regex = new RegExp(`(${escapedWords.join("|")})`, "gi");
663
+ return text.replace(regex, "").replace(/\s+/g, " ").trim();
664
+ }
647
665
  // src/utils/decode/decode-signed.util.ts
648
666
  function decodeSignedPayload(signedPayload) {
649
667
  const parts = signedPayload.split(".");
@@ -7549,6 +7567,7 @@ export {
7549
7567
  sendDeleteWithBearer,
7550
7568
  sendDelete,
7551
7569
  replaceWordInList,
7570
+ removeWordsFromText,
7552
7571
  removeEmptyLines,
7553
7572
  normalizeText,
7554
7573
  isEqual,
@@ -1,3 +1,4 @@
1
1
  export * from './split.util';
2
2
  export * from './normalize.util';
3
3
  export * from './empty-line.util';
4
+ export * from './remove-string.util';
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Removes specified words from the given text
3
+ * @param text - The input text to remove words from
4
+ * @param words - Array of words to remove from the text
5
+ * @returns The text with specified words removed
6
+ */
7
+ export declare function removeWordsFromText(text: string, words: string[]): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docaohuynh/ielts-api-utils",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "description": "Utilities for IELTS API",
5
5
  "module": "index.ts",
6
6
  "main": "dist/index.js",