0.41.3 • Published 1 year ago

@util.js/emails v0.41.3

Weekly downloads
1
License
MIT
Repository
github
Last release
1 year ago

@util.js/emails

JavaScript utility methods for emails

@util.js/emails is part of Util.js.

Classes

Emails

JavaScript utility methods for emails

Kind: global class
Access: public

emails.isValidEmail(string) ⇒ boolean

Returns whether the given string is a valid email.

The regular expression used to validate strings comes from a W3C article.

Kind: instance method of Emails
Returns: boolean - true if the given string is a valid email or false otherwise
Access: public

ParamTypeDescription
stringstringThe string to test

emails.wrapHeaders(nameValueArrayOfHeaders) ⇒ EmailHeaders

Wraps the given nameValueArrayOfHeaders inside an object that makes email-header lookup easy.

When using the returned object, you no longer have to worry about the case (e.g., "In-Reply-To" or "In-reply-to") of email headers.

googleapis's interface to Gmail returns email headers as an array of name-value objects. The following is a sample:

Kind: instance method of Emails
Returns: EmailHeaders - A new EmailHeaders instance
Throws:

  • TypeError If nameValueArrayOfHeaders is not an array-like object containing name-value objects

Access: public

ParamTypeDescription
nameValueArrayOfHeadersArrayAn array of name-value objects containing email headers

EmailHeaders

Wrapper of email headers that makes header lookup easy.

This class makes it so that the case of header names is not important. For example, Gmail might use "In-Reply-To" whereas iCloud might use "In-reply-to".

Kind: global class
Access: public

emailHeaders.deliveredTo() ⇒ undefined | string

Returns the value of the Delivered-To header

Kind: instance method of EmailHeaders
Returns: undefined | string - The value of the Date header as a string or undefined
Access: public

emailHeaders.date() ⇒ undefined | string

Returns the value of the Date header

Kind: instance method of EmailHeaders
Returns: undefined | string - The value of the Date header as a string or undefined
Access: public

emailHeaders.from() ⇒ undefined | string

Returns the value of the From header

Kind: instance method of EmailHeaders
Returns: undefined | string - The value of the From header as a string or undefined
Access: public

emailHeaders.get(headerName) ⇒ undefined | string

Returns the value of the given headerName

Kind: instance method of EmailHeaders
Returns: undefined | string - The value of the given header name as a string or undefined
Throws:

  • TypeError If headerName does not have a toLowerCase function

Access: public

ParamTypeDescription
headerNamestringThe header to look up a value for

emailHeaders.inReplyTo() ⇒ undefined | string

Returns the value of the In-Reply-To header

Kind: instance method of EmailHeaders
Returns: undefined | string - The value of the In-Reply-To header as a string or undefined
Access: public

emailHeaders.messageId() ⇒ undefined | string

Returns the value of the Message-Id header

Kind: instance method of EmailHeaders
Returns: undefined | string - The value of the Message-Id header as a string or undefined
Access: public

emailHeaders.references() ⇒ undefined | string

Returns the value of the References header

Kind: instance method of EmailHeaders
Returns: undefined | string - The value of the References header as a string or undefined
Access: public

emailHeaders.subject() ⇒ undefined | string

Returns the value of the Subject header

Kind: instance method of EmailHeaders
Returns: undefined | string - The value of the Subject header as a string or undefined
Access: public

emailHeaders.to() ⇒ undefined | string

Returns the value of the To header

Kind: instance method of EmailHeaders
Returns: undefined | string - The value of the To header as a string or undefined
Access: public

emailHeaders.toString() ⇒ string

Returns a string listing the email-header names and values of this object

Kind: instance method of EmailHeaders
Returns: string - A string representation of this object
Access: public

0.41.3

1 year ago

0.41.2

1 year ago

0.41.1

3 years ago

0.41.0

3 years ago

0.40.0

3 years ago

0.40.1

3 years ago

0.39.2

5 years ago

0.39.1

5 years ago

0.39.0

5 years ago

0.38.0

5 years ago

0.37.1

5 years ago

0.37.0

5 years ago

0.36.1

5 years ago

0.36.0

5 years ago

0.35.0

5 years ago

0.34.0

5 years ago

0.33.1

5 years ago

0.33.0

5 years ago

0.32.0

5 years ago

0.31.0

5 years ago

0.30.0

5 years ago

0.29.1

5 years ago