-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
WIP: Add std/smtp module #8413
WIP: Add std/smtp module #8413
Conversation
* Use of this source code is governed by a BSD-style | ||
* license that can be found in the LICENSE file. | ||
*/ | ||
export function validateLine(line: string): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe move into _address_validation.ts to remove the generically named helpers.ts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_util.ts
would be more consistent. These are private, I wouldn't worry about a generic _util
module per-directory.
* See func Dial for a description of the hostport parameter, and host | ||
* and port results. | ||
*/ | ||
export function splitHostPort(hostport: string): [string, number] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe move into _address_parameter_extrator.ts to remove the generically named helpers.ts?
export function splitHostPort(hostport: string): [string, number] { | ||
const missingPort = "missing port in address"; | ||
const tooManyColons = "too many colons in address"; | ||
function addrErr(addr: string, why: string): AddrError { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid contraction and use addressError as the name?
let j = 0, k = 0; | ||
|
||
// The port starts after the last colon. | ||
const i = hostport.lastIndexOf(":"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit pick: Not a fan of variable name with single letter, how about indexOfLastColon
function addrErr(addr: string, why: string): AddrError { | ||
return new AddrError(why, addr); | ||
} | ||
let j = 0, k = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit pick: Not a fan or single letter variables
let code2: number; | ||
let moreMessage: string; | ||
[code2, continued, moreMessage] = await parseCodeLine(line, 0); | ||
if (code2 !== code) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code2 and code are hard to understand as variable names? Can these be named better?
continued = true; | ||
continue; | ||
} | ||
message += "\n" + moreMessage; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a named constant for \n?
skipSpace(l: Uint8Array): number { | ||
let n = 0; | ||
for (let i = 0; i < l.length; i++) { | ||
if (l[i] === charCode(" ") || l[i] === charCode("\t")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, would it be more reabable to name named constants for space and tab?
} | ||
|
||
function parseCodeLine(line: string, expectCode: number): CodeLine { | ||
if (line.length < 4 || (line[3] !== " " && line[3] !== "-")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few magic numbers here. Named constant for 3 and 4 would reveal the position significance?
break; | ||
case WRITE_STATE_CR: | ||
this.#state = WRITE_STATE_DATA; | ||
if (c === charCode("\n")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More uses of the \n and \r. As these are also reference in the other files can they share a enum to improve readability
class AddrError extends Error { | ||
constructor(why: string, readonly addr: string) { | ||
super(why); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be exported if users see it. Does this class need to exist, though?
Please not a tag of a I personally believe we shouldn't add something like this to |
@uki00a This looks pretty good! But because of the size - it's going to be difficult for us to review this properly. I would feel much more comfortable merging this into std if it first existed in deno.land/x people were using it. How does this compare to? https://deno.land/x/smtp@v0.6.0 |
@ry From my personal point of view, I compared each module: std/smtp
x/smtp
My personal thoughts
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. |
@uki00a looks like this PR is still not ready, so we won't land this PR before standard library migration to a separate repository (#9029 (comment)). I'm still very much interested in discussing these changes on upcoming meetings and potentially landing the PR. |
this would be such a good addition to std. i know people disagree with the fact that the smtp module should be part of std, but look at node and nodemailer and after then maybe reconsider :) |
Deno standard library was moved to denoland/deno_std, please reopen your PR there. |
Towards #7906.
Summary
std/smtp
module.Usage
Changes
std/smtp
module.TextProtoReader
class fromstd/textproto/mod.ts
tostd/textproto/reader.ts
and re-export it fromstd/textproto/mod.ts
.TextProtoWriter
class (std/textproto/writer.ts
)TextProtoConn
class (std/textproto/conn.ts
)Question
This PR is a bit more complex 😢 Should I split this PR into multiple PRs?
TODO
README.md