postal-mime
Advanced tools
Comparing version 2.1.0 to 2.1.1
# Changelog | ||
## [2.1.1](https://github.com/postalsys/postal-mime/compare/v2.1.0...v2.1.1) (2024-02-26) | ||
### Bug Fixes | ||
* **types:** Updated types for PostalMime ([bc90f6d](https://github.com/postalsys/postal-mime/commit/bc90f6d5b7d3e2475cece77bb094caf421dead97)) | ||
## [2.1.0](https://github.com/postalsys/postal-mime/compare/v2.0.2...v2.1.0) (2024-02-22) | ||
@@ -4,0 +11,0 @@ |
{ | ||
"name": "postal-mime", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"description": "Email parser for browser environments", | ||
@@ -30,8 +30,9 @@ "main": "./src/postal-mime.js", | ||
"devDependencies": { | ||
"@types/node": "20.11.20", | ||
"cross-blob": "3.0.2", | ||
"eslint": "8.56.0", | ||
"cross-env": "7.0.3", | ||
"eslint": "8.57.0", | ||
"eslint-cli": "1.1.1", | ||
"iframe-resizer": "4.3.9", | ||
"cross-env": "7.0.3" | ||
"iframe-resizer": "4.3.9" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
export type RawEmail = string | ArrayBuffer | Blob | Buffer; | ||
export type RawEmail = string | ArrayBuffer | Uint8Array | Blob | Buffer | ReadableStream; | ||
@@ -16,3 +16,3 @@ export type Header = Record<string, string>; | ||
contentId?: string; | ||
content: ArrayBuffer; | ||
content: Uint8Array; | ||
}; | ||
@@ -19,0 +19,0 @@ |
@@ -320,3 +320,3 @@ import MimeNode from './mime-node.js'; | ||
// check if the input is a readable stream and resolve it into an ArrayBuffer | ||
// Check if the input is a readable stream and resolve it into an ArrayBuffer | ||
if (buf && typeof buf.getReader === 'function') { | ||
@@ -326,17 +326,17 @@ buf = await this.resolveStream(buf); | ||
// should it thrown on empty value instead? | ||
// Should it throw for an empty value instead of defaulting to an empty ArrayBuffer? | ||
buf = buf || ArrayBuffer(0); | ||
// Cast string input to Uint8Array | ||
if (typeof buf === 'string') { | ||
// cast string input to ArrayBuffer | ||
buf = textEncoder.encode(buf); | ||
} | ||
// Cast Blob to ArrayBuffer | ||
if (buf instanceof Blob || Object.prototype.toString.call(buf) === '[object Blob]') { | ||
// can't process blob directly, cast to ArrayBuffer | ||
buf = await blobToArrayBuffer(buf); | ||
} | ||
// Cast Node.js Buffer object or Uint8Array into ArrayBuffer | ||
if (buf.buffer instanceof ArrayBuffer) { | ||
// Node.js Buffer object or Uint8Array | ||
buf = new Uint8Array(buf).buffer; | ||
@@ -346,2 +346,3 @@ } | ||
this.buf = buf; | ||
this.av = new Uint8Array(buf); | ||
@@ -348,0 +349,0 @@ this.readPos = 0; |
127324
6