npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@savearray2/forte

v0.1.1

Published

Email Address validation library, based on rfc 2822 and rfc 6532.

Downloads

37

Readme

forte

Parser for RFC-2822/RFC-6532 email addresses.

This library's sole purpose is to validate email addresses, and email addresses only (including esoteric ones!). It can be used in the browser or from within Node.js. Special care has been taken to ensure strange email addresses can be validated successfully.

Unicode/Punycode is also supported.

Examples:

[email protected]
[email protected]
" "@example.org
"john..doe"@example.org
email@ドメイン.com

A wide array of test vectors can be found in the project test files.

Installation

npm install @savearray2/forte

Usage

const Forte = require('@savearray2/forte')
const parsed_email = Forte.parse_email('[email protected]')
{
  local_part: { value: 'email', comments: [], quoted_string: false },
  domain: {
    value: 'domain.com',
    comments: [],
    safe_value: 'domain.com',
    type: 'fqdn'
  },
  rfc6532: false,
  address: '[email protected]',
  safe_address: '[email protected]'
}

API

Forte.parse_email(addr, [opts])

  • addr: string - The email address to parse.
  • opts: object with the following options:
    • reject_quoted_string: bool - Rejects any address whose local part a quoted string. Default: false.
    • reject_comments: bool - Rejects any address whose local part or domain contains comments. Default: false.
    • reject_local: bool - Rejects any address whose domain is determined to be local (no TLD). Default: false.
    • reject_ip: bool - Rejects any address whose domain is determined to be an IP literal (an IPv4 or IPv6 address). Default: false.

Returns null, if invalid address. Otherwise, returns an EmailAddress object with email address information:

  • local_part: object - The local part of the email address.
    • value: string - The parsed local part string.
    • quoted_string: bool - If true, the local part contained a quoted string, when parsed.
    • comments: array - A (possibly nested) array of strings representing the comments.
  • domain: object - The domain part of the email address.
    • value: string - The parsed domain string.
    • safe_value: string - A version of the domain that is safe to use with systems that only accept ASCII-encoded domains (punycode-encoded).
    • comments: array - A (possibly nested) array of strings representing the comments.
    • type: string - The type of domain parsed. (Values: fqdn, local, ipv4, ipv6)
  • address: string - A pretty/simplified version of the address.
  • safe_address: string - A pretty/simplified version of the address that is safe to use with systems that only accept ASCII-encoded email addresses (punycode-encoded).
  • rfc6532: bool - If true, then the parsed address was processed in rfc6532 mode, and contains unicode characters (\u0080-\uFFFF).

License

This library is licensed under MIT.