{"_id":"@dmitryrechkin/text-email-body-parser","_rev":"3-34fe95322e5cf232c2b4507f0e05f3ba","name":"@dmitryrechkin/text-email-body-parser","dist-tags":{"latest":"1.0.3"},"versions":{"1.0.0":{"name":"@dmitryrechkin/text-email-body-parser","version":"1.0.0","_id":"@dmitryrechkin/text-email-body-parser@1.0.0","maintainers":[{"name":"dmitryrechkin","email":"rechkin@gmail.com"}],"dist":{"shasum":"320c3e6f2d7a3c949d3e127d5f2b0a3cd06ae4e1","tarball":"https://registry.npmjs.org/@dmitryrechkin/text-email-body-parser/-/text-email-body-parser-1.0.0.tgz","fileCount":14,"integrity":"sha512-W6884nLNpdTVnvL8K8BORCvLGYyHvSc89LIMp6//wGthC40sZEZ3O1615ncRte+QChh4m4S0DCYUW5+172QrXg==","signatures":[{"sig":"MEUCIC/pSEFkvzrF/9IWw76KdqL2Q2FILrreqwRJCdj9iMLSAiEA2KC7WPHth5qJOG5AcFJ6v73HtufaeUiWS9XPjg1nmBA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":62804},"type":"module","_from":"file:dmitryrechkin-text-email-body-parser-1.0.0.tgz","scripts":{"lint":"eslint .","test":"vitest run","build":"rm -rf ./dist && tsc && bun build ./src/index.ts --outdir ./dist","check":"tsc --noEmit","format":"eslint --fix .","package:publish":"pnpm publish --access public"},"_npmUser":{"name":"dmitryrechkin","email":"rechkin@gmail.com"},"_resolved":"/private/var/folders/67/qcbb1q556vbfzygwbkm5glcr0000gn/T/4796d2f0f5bf17b9077864f91229d2cc/dmitryrechkin-text-email-body-parser-1.0.0.tgz","_integrity":"sha512-W6884nLNpdTVnvL8K8BORCvLGYyHvSc89LIMp6//wGthC40sZEZ3O1615ncRte+QChh4m4S0DCYUW5+172QrXg==","_npmVersion":"10.8.2","description":"**Text Email Body Parser is a TypeScript library inspired by Email Reply Parser to parse plain-text email bodies and extract meaningful fragments.**","directories":{},"_nodeVersion":"22.5.1","dependencies":{},"_hasShrinkwrap":false,"devDependencies":{"eslint":"^8.0.0","vitest":"^0.24.5","typescript":"^5.5.3","@types/node":"^20.8.3","@cloudflare/workers-types":"^3.0.0","eslint-plugin-unused-imports":"^3.0.0","@dmitryrechkin/eslint-standard":"^1.0.7"},"_npmOperationalInternal":{"tmp":"tmp/text-email-body-parser_1.0.0_1723596389544_0.9061011545073958","host":"s3://npm-registry-packages"}},"1.0.1":{"name":"@dmitryrechkin/text-email-body-parser","version":"1.0.1","_id":"@dmitryrechkin/text-email-body-parser@1.0.1","maintainers":[{"name":"dmitryrechkin","email":"rechkin@gmail.com"}],"dist":{"shasum":"59a5ea5ae361003bcb03303c40c86ca14bc7584b","tarball":"https://registry.npmjs.org/@dmitryrechkin/text-email-body-parser/-/text-email-body-parser-1.0.1.tgz","fileCount":11,"integrity":"sha512-4enSfqXM0sFUINTbcsonxmdSBhdC12fGUhzPUFaCUcZ8yG9kwp3zMTHeSg9hyfPw4EB3erssuVTo7wZl0RUjGA==","signatures":[{"sig":"MEQCIDTimf7k2Rjy1UO3/ca6VV/+BpNInFTIE0zamX+ekuCPAiB240HZjB7bZJHtoRNAmQrHDffagQoguMCBh/BokEzfyw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":56132},"main":"dist/index.js","type":"module","_from":"file:dmitryrechkin-text-email-body-parser-1.0.1.tgz","types":"dist/index.d.ts","scripts":{"lint":"eslint .","test":"vitest run","build":"shx rm -rf dist && tsc","check":"tsc --noEmit","format":"eslint --fix .","package:publish":"pnpm publish --access public"},"_npmUser":{"name":"dmitryrechkin","email":"rechkin@gmail.com"},"_resolved":"/private/var/folders/67/qcbb1q556vbfzygwbkm5glcr0000gn/T/62d267a249d3f1909dbdc1a4d8a3bd5b/dmitryrechkin-text-email-body-parser-1.0.1.tgz","_integrity":"sha512-4enSfqXM0sFUINTbcsonxmdSBhdC12fGUhzPUFaCUcZ8yG9kwp3zMTHeSg9hyfPw4EB3erssuVTo7wZl0RUjGA==","_npmVersion":"10.8.2","description":"**Text Email Body Parser is a TypeScript library inspired by Email Reply Parser to parse plain-text email bodies and extract meaningful fragments.**","directories":{},"_nodeVersion":"22.5.1","dependencies":{},"_hasShrinkwrap":false,"devDependencies":{"shx":"^0.3.4","eslint":"^8.0.0","vitest":"^0.24.5","typescript":"^5.5.3","@types/node":"^20.8.3","@cloudflare/workers-types":"^3.0.0","eslint-plugin-unused-imports":"^3.0.0","@dmitryrechkin/eslint-standard":"^1.0.7"},"_npmOperationalInternal":{"tmp":"tmp/text-email-body-parser_1.0.1_1723597367284_0.5562360967220408","host":"s3://npm-registry-packages"}},"1.0.2":{"name":"@dmitryrechkin/text-email-body-parser","version":"1.0.2","_id":"@dmitryrechkin/text-email-body-parser@1.0.2","maintainers":[{"name":"dmitryrechkin","email":"rechkin@gmail.com"}],"dist":{"shasum":"be18975e20a9a67e954bd68903ceca4a5d202dba","tarball":"https://registry.npmjs.org/@dmitryrechkin/text-email-body-parser/-/text-email-body-parser-1.0.2.tgz","fileCount":11,"integrity":"sha512-PHVtaXrWbX2eeJkCaSo86l39MVdxsh4AuY65lDcEVcMcOTG0uNNQnHv1tWyCXxRAlBYuT95yQ35HxQalwWkiTw==","signatures":[{"sig":"MEQCIHHEkbH0P6lEAeZe3IEMpRHmY2lThLUVlrntk9dW6gR3AiAde0QVTpoScfINIB+TAuXRmYDBhr0xyctEfebfwoc6xA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":56157},"main":"dist/index.js","type":"module","_from":"file:dmitryrechkin-text-email-body-parser-1.0.2.tgz","types":"dist/index.d.ts","scripts":{"lint":"eslint .","test":"vitest run","build":"shx rm -rf dist && tsc && fix-esm-import-path dist","check":"tsc --noEmit","format":"eslint --fix .","package:publish":"pnpm publish --access public"},"_npmUser":{"name":"dmitryrechkin","email":"rechkin@gmail.com"},"_resolved":"/private/var/folders/67/qcbb1q556vbfzygwbkm5glcr0000gn/T/cf37c83d13d7f24aee8f5775f3d4c685/dmitryrechkin-text-email-body-parser-1.0.2.tgz","_integrity":"sha512-PHVtaXrWbX2eeJkCaSo86l39MVdxsh4AuY65lDcEVcMcOTG0uNNQnHv1tWyCXxRAlBYuT95yQ35HxQalwWkiTw==","_npmVersion":"10.8.2","description":"**Text Email Body Parser is a TypeScript library inspired by Email Reply Parser to parse plain-text email bodies and extract meaningful fragments.**","directories":{},"_nodeVersion":"22.5.1","dependencies":{},"_hasShrinkwrap":false,"devDependencies":{"shx":"^0.3.4","eslint":"^8.0.0","vitest":"^0.24.5","typescript":"^5.5.3","fix-esm-import-path":"^1.0.1","eslint-plugin-unused-imports":"^3.0.0","@dmitryrechkin/eslint-standard":"^1.0.7"},"_npmOperationalInternal":{"tmp":"tmp/text-email-body-parser_1.0.2_1723607395364_0.5062672157138428","host":"s3://npm-registry-packages"}},"1.0.3":{"name":"@dmitryrechkin/text-email-body-parser","type":"module","version":"1.0.3","main":"dist/index.js","types":"dist/index.d.ts","devDependencies":{"fix-esm-import-path":"^1.0.1","@dmitryrechkin/eslint-standard":"^1.0.7","eslint":"^8.0.0","eslint-plugin-unused-imports":"^3.0.0","typescript":"^5.5.3","vitest":"^0.24.5","shx":"^0.3.4"},"dependencies":{},"scripts":{"lint":"eslint .","format":"eslint --fix .","test":"vitest run","check":"tsc --noEmit","build":"shx rm -rf dist && tsc && fix-esm-import-path dist","package:publish":"pnpm publish --access public"},"_id":"@dmitryrechkin/text-email-body-parser@1.0.3","description":"**Text Email Body Parser is a TypeScript library inspired by Email Reply Parser to parse plain-text email bodies and extract meaningful fragments.**","_integrity":"sha512-jNsaLBIWGPkx3N3u87vcQzWChyd9xVBHbtijkfYx390LkzY06ciOAjgZHOt7g2oYWGaFchLH9kS/nrN9JKXVZQ==","_resolved":"/private/var/folders/67/qcbb1q556vbfzygwbkm5glcr0000gn/T/4e444f1da0d502c9ae8887cfb46567c5/dmitryrechkin-text-email-body-parser-1.0.3.tgz","_from":"file:dmitryrechkin-text-email-body-parser-1.0.3.tgz","_nodeVersion":"22.5.1","_npmVersion":"10.8.2","dist":{"integrity":"sha512-jNsaLBIWGPkx3N3u87vcQzWChyd9xVBHbtijkfYx390LkzY06ciOAjgZHOt7g2oYWGaFchLH9kS/nrN9JKXVZQ==","shasum":"44f7b89aa36128886f591320ceaef2e3e3c561b2","tarball":"https://registry.npmjs.org/@dmitryrechkin/text-email-body-parser/-/text-email-body-parser-1.0.3.tgz","fileCount":11,"unpackedSize":57537,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCs9/MeaCjHBf+mL2ky61dH59k2ahdq2Bp8i+W2BhJTNAIhAOJLdOoR0TeVbvYVsivRakt25sTZFpp10O6iR+iMhToF"}]},"_npmUser":{"name":"dmitryrechkin","email":"rechkin@gmail.com"},"directories":{},"maintainers":[{"name":"dmitryrechkin","email":"rechkin@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/text-email-body-parser_1.0.3_1723611340094_0.9419274446763759"},"_hasShrinkwrap":false}},"time":{"created":"2024-08-14T00:46:29.448Z","modified":"2024-08-14T04:55:40.442Z","1.0.0":"2024-08-14T00:46:29.688Z","1.0.1":"2024-08-14T01:02:47.456Z","1.0.2":"2024-08-14T03:49:55.527Z","1.0.3":"2024-08-14T04:55:40.272Z"},"description":"**Text Email Body Parser is a TypeScript library inspired by Email Reply Parser to parse plain-text email bodies and extract meaningful fragments.**","maintainers":[{"name":"dmitryrechkin","email":"rechkin@gmail.com"}],"readme":"# Text Email Body Parser\n\n**Text Email Body Parser is a TypeScript library inspired by Email Reply Parser to parse plain-text email bodies and extract meaningful fragments.**\n\nThis library supports most email replies, signatures, and locales.\n\n**Author**: Dmitry Rechkin <rechkin@gmail.com>\n\n## Installation\n\nInstall the project using pnpm:\n\n```bash\npnpm add @dmitryrechkin/text-email-body-parser\n```\n\n## Features\n\n- Strip email replies like On DATE, NAME <EMAIL> wrote:\n- Supports around 10 locales, including English, French, Spanish, Portuguese, Italian, Japanese, Chinese.\n- Removes signatures like Sent from my iPhone\n- Removes signatures like Best wishes\n\n## Usage\n\n```javascript\nimport { TextEmailBodyParser } from \"@dmitryrechkin/text-email-body-parser\";\n\nconst parser = new TextEmailBodyParser();\nconst email = parser.parse(MY_EMAIL_STRING);\n\nconsole.log(email.map(fragment => fragment.text).join('\\n'));\n```\n\n## Defining Custom Patterns\n\nThe TextEmailBodyParser class allows you to define custom patterns for headers and signatures. These patterns can be passed to the constructor using the TextEmailBodyPatterns interface.\n\n```javascript\nexport interface TextEmailBodyPatterns {\n    readonly HEADER_REGEX: RegExp[];\n    readonly SIGNATURE_REGEX: RegExp[];\n}\n```\n\n### Example of Custom Patterns\n\n```javascript\nimport { TextEmailBodyParser, TextEmailBodyPatterns } from \"text-email-body-parser\";\n\nconst customPatterns: TextEmailBodyPatterns = {\n    HEADER_REGEX: [\n        // Custom header patterns\n        /CustomHeaderPattern/,\n    ],\n    SIGNATURE_REGEX: [\n        // Custom signature patterns\n        /CustomSignaturePattern/,\n    ]\n};\n\nconst parser = new TextEmailBodyParser(customPatterns);\nconst email = parser.parse(MY_EMAIL_STRING);\n\nconsole.log(email.map(fragment => fragment.text).join('\\n'));\n```\n\n## Fragment Structure\n\nThe parsed email is broken down into fragments, each represented by the TypeTextEmailBodyFragment interface.\n\n### TypeTextEmailBodyFragment Interface\n\n```javascript\nexport interface TypeTextEmailBodyFragment {\n    headerText?: string; // The header text, if any, associated with this fragment\n    text: string;        // The main content of the fragment\n    depth: number;       // The quote depth of the fragment, indicating how deeply nested the quote is\n    signature: boolean;  // Indicates whether the fragment is recognized as a signature\n}\n```\n\n### Example of a Parsed Fragment\n\n```javascript\nconst parser = new TextEmailBodyParser();\nconst email = parser.parse(MY_EMAIL_STRING);\n\nemail.forEach(fragment => {\n    console.log(`Header: ${fragment.headerText}`);\n    console.log(`Text: ${fragment.text}`);\n    console.log(`Depth: ${fragment.depth}`);\n    console.log(`Is Signature: ${fragment.signature}`);\n});\n```\n\n## Inspired By\n\nIt has been inspired by Email Reply Parser, which requires RE2 and does not work in nodeless environments like Cloudflare. \n\nText Email Body Parser has been completely rewritten in TypeScript, retaining only the regex patterns and the core idea of fragments from the original. \nIt has been thoroughly tested, and all unit tests pass.\n\n## Contributing\n\nFeel free to fork this project and submit fixes. We may adapt your code to fit the codebase.\n\nYou can run unit tests using:\n\n```bash\npnpm test\n```\n","readmeFilename":"README.md"}