Nerds Publishing Monstrosities

    @util.js/emails

    0.41.1 • Public • Published

    @util.js/emails

    JavaScript utility methods for emails

    NPM Status Travis CI Build Status

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

    Classes

    Emails

    JavaScript utility methods for emails

    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".

    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

    Param Type Description
    string string The 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:

    [ { name: 'Delivered-To', value: 'c@creemama.com' },
    ...
      { name: 'Date', value: 'Tue, 10 Jul 2018 10:18:52 -0700' },
    ...
      { name: 'To', value: 'Chris Topher ' } ]
    

    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

    Param Type Description
    nameValueArrayOfHeaders Array An 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

    Param Type Description
    headerName string The 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

    Install

    npm i @util.js/emails

    DownloadsWeekly Downloads

    1

    Version

    0.41.1

    License

    MIT

    Unpacked Size

    29 kB

    Total Files

    9

    Last publish

    Collaborators

    • creemama