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

github-email-js

v1.0.0

Published

github-email as a JS module

Downloads

4

Readme

github-email-js

This module replicates the great github-email CLI as a pure JS module.

Main differences with github-email

There are just a few differences between how this module behaves compared to the original github-email CLI.

Fixed npm email

The CLI still fetches the npm email from the https://registry.npmjs.org/-/user/org.couchdb.user deprecated endpoint, leading to an always null value for npm.

This module instead uses the mirror used by sindresorhus/npm-email that properly resolves the email for the user.

Emails from recenty activity and recent commits

In github-email, the recent activity and recent commits sections seem to be reversed:

  • "Emails from recent commits" fetches from the https://api.github.com/users/$user/events endpoint,
  • "Emails from owned-repo recent activity" fetches from the https://api.github.com/repos/$user/$repo/commits endpoint.

This module instead returns the emails found:

  • in the /events endpoint in the recentActivity result field,
  • in the /commits endpoint in the recentCommits result field.

Default repository used for recent commits history

When no repository is passed as an option, the github-email CLI resolves to the lastly "updated" one on GitHub. But a very old repo can have its name or description updated, while not having seen any new commits for a few years.

Since the repository is used to lookup emails in recent commits, this module instead resolves to the user's lastly "pushed" repository.

Optional lookup by id

Since this module can be used programmatically, as compared to the original CLI, it eases up the lookup by allowing passing the GitHub user's id instead of its username.

This can be useful when working with authentication systems that record only the user's id, such as Firebase.

Install

$ yarn add github-email-js

Usage

Lookup by username

import { githubEmail } from 'github-email-js';

const {
    npm,
    recentActivity,
    recentCommits
} = await githubEmail({
    username: 'jpreynat'
});

Lookup by id

import { githubEmail } from 'github-email-js';

const {
    npm,
    recentActivity,
    recentCommits
} = await githubEmail({
    id: 7927876
});

Allow returning email from GitHub's API

To read the email from GitHub's API, we need authentication.

import { githubEmail } from 'github-email-js';

const {
    github,
    npm,
    recentActivity,
    recentCommits
} = await githubEmail({
    username: 'jpreynat',
    token: '<your-github-token>'
});

Manually select the repository in which to lookup recent commits history

Otherwise, the default is to lookup in the lastly "pushed" owner's repository.

import { githubEmail } from 'github-email-js';

const {
    github,
    npm,
    recentActivity,
    recentCommits
} = await githubEmail({
    username: 'jpreynat',
    token: '<your-github-token>',
    repository: 'github-email-js'
});