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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@worktionary/workfriends

v0.0.2

Published

Ooh work friends. Check if email addresses are from the same domain to infer if they're work friends.

Downloads

4

Readme

@worktionary/workfriends 👍👍

Ooh work friends. A simple utility to check email addresses to infer if they are work friends.

Ooh friend

Installation

npm install @worktionary/workfriends

Quick Start

import { areWorkFriends } from "@worktionary/workfriends"

areWorkFriends(["[email protected]", "[email protected]"]) // true

Usage

import { areWorkFriends } from "@worktionary/workfriends"

// Auto-detect (all emails must be from same domain)
const emails1 = ["[email protected]", "[email protected]"]
areWorkFriends(emails1) // true

const emails2 = ["[email protected]", "[email protected]"]
areWorkFriends(emails2) // false

// With known domain
const emails3 = [
	"[email protected]",
	"[email protected]",
	"[email protected]",
]
areWorkFriends(emails3, "worktionary.com") // false (external person present)

// With multiple known domains (for companies with multiple domains)
const emails4 = ["[email protected]", "[email protected]"]
areWorkFriends(emails4, ["worktionary.com", "worktionary-advisors.com"]) // true

// Clean ternary usage
{
	areWorkFriends(emails) ? <div>Internal</div> : <div>External</div>
}

// Descriptive variable names
const isInternalMeeting = areWorkFriends(emails)
const sameUserOrg = areWorkFriends(emails)
const fromSameDomain = areWorkFriends(emails)

API

areWorkFriends(emails, knownDomains?)

Check if emails are from work friends. Returns boolean directly for clean usage.

  • emails: string[] - Array of email addresses
  • knownDomains?: string | string[] - Optional known internal domain(s)
  • Returns boolean - True if all emails are internal
  • Throws WorkFriendsError - When validation fails

Error Handling

Validation errors throw WorkFriendsError with detailed information. Use try-catch when you need error details:

import { areWorkFriends, WorkFriendsError } from "@worktionary/workfriends"

try {
	const result = areWorkFriends(
		["[email protected]", "invalid-email", "[email protected]"],
		"company.com"
	)

	console.log("Are work friends:", result)
} catch (error) {
	if (error instanceof WorkFriendsError) {
		console.log("Invalid emails:", error.invalidEmails) // Format errors: ["invalid-email"]
		console.log("Invalid domains:", error.invalidDomains) // Domain errors: ["invalid"]
		console.log("Error message:", error.message)
	}
}

// Validate email format
import { isValidEmail } from "@worktionary/workfriends"

isValidEmail("[email protected]") // true
isValidEmail("not-an-email") // false

Examples

// Company with single domain
areWorkFriends(
	["[email protected]", "[email protected]"],
	"worktionary.com"
) // true

// Company with multiple domains (e.g., main + advisors)
areWorkFriends(
	["[email protected]", "[email protected]"],
	["worktionary.com", "worktionary-advisors.com"]
) // true

// Auto-detect when you don't know the domain
areWorkFriends(["[email protected]", "[email protected]"]) // true
areWorkFriends(["[email protected]", "[email protected]"]) // false

// React component usage
function MeetingBadge({ emails }) {
	return (
		<div>
			{areWorkFriends(emails) ? (
				<span className="internal">🏢 Internal Meeting</span>
			) : (
				<span className="external">🌍 External Meeting</span>
			)}
		</div>
	)
}

// Conditional logic
if (areWorkFriends(meetingEmails)) {
	enableInternalFeatures()
	showConfidentialAgenda()
} else {
	restrictExternalAccess()
}

// Error handling when needed
try {
	const isInternal = areWorkFriends(userInputEmails)
	updateMeetingStatus(isInternal)
} catch (error) {
	if (error instanceof WorkFriendsError) {
		// Handle different types of validation errors
		if (error.invalidEmails) {
			showEmailFormatErrors(error.invalidEmails)
		}
		if (error.invalidDomains) {
			showDomainErrors(error.invalidDomains)
		}
	}
}

Email Validation

isValidEmail(email)

A standalone email validation utility that you can use independently for form validation, input sanitization, or anywhere you need to check email format.

import { isValidEmail } from "@worktionary/workfriends"

// Basic validation
isValidEmail("[email protected]") // true
isValidEmail("not-an-email") // false

// Form validation example
function validateEmailInput(email: string) {
	if (!isValidEmail(email)) {
		throw new Error("Please enter a valid email address")
	}
	return email
}

// Input sanitization
function sanitizeEmails(emails: string[]) {
	return emails.filter((email) => isValidEmail(email))
}

// React form validation
function EmailForm() {
	const [email, setEmail] = useState("")
	const [isValid, setIsValid] = useState(true)

	const handleEmailChange = (e) => {
		const value = e.target.value
		setEmail(value)
		setIsValid(isValidEmail(value))
	}

	return (
		<input
			type="email"
			value={email}
			onChange={handleEmailChange}
			className={isValid ? "valid" : "invalid"}
		/>
	)
}

What it validates:

  • Must contain exactly one @ symbol
  • Must have content before and after the @
  • Domain must contain at least one . (dot)
  • All domain parts must have content (no empty segments)

What it accepts:

What it rejects:

  • notanemail ❌ (no @ symbol)
  • @domain.com ❌ (no local part)
  • user@ ❌ (no domain)
  • user@domain ❌ (domain needs dot)
  • user@@domain.com ❌ (multiple @ symbols)
  • user@domain. ❌ (empty domain segment)
  • [email protected] ❌ (empty domain segment)

License

MIT