New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

github-username

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github-username - npm Package Compare versions

Comparing version 4.1.0 to 5.0.0

index.d.ts

38

index.js
'use strict';
const ghGot = require('gh-got');
function searchCommits(email, token) {
return ghGot('search/commits', {
async function searchCommits(email, token) {
const result = await ghGot('search/commits', {
token,

@@ -17,19 +17,19 @@ query: {

}
}).then(result => {
const data = result.body;
});
if (data.total_count === 0) {
throw new Error(`Couldn't find username for \`${email}\``);
}
const {body: data} = result;
return data.items[0].author.login;
});
if (data.total_count === 0) {
throw new Error(`Couldn't find username for \`${email}\``);
}
return data.items[0].author.login;
}
module.exports = (email, token) => {
module.exports = async (email, token) => {
if (!(typeof email === 'string' && email.includes('@'))) {
return Promise.reject(new Error('Email required'));
throw new Error('Email required');
}
return ghGot('search/users', {
const result = await ghGot('search/users', {
token,

@@ -42,11 +42,11 @@ query: {

}
}).then(result => {
const data = result.body;
});
if (data.total_count === 0) {
return searchCommits(email, token);
}
const {body: data} = result;
return data.items[0].login;
});
if (data.total_count === 0) {
return searchCommits(email, token);
}
return data.items[0].login;
};
{
"name": "github-username",
"version": "4.1.0",
"description": "Get a GitHub username from an email address",
"license": "MIT",
"repository": "sindresorhus/github-username",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=4"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js"
],
"keywords": [
"github",
"user",
"username",
"email",
"address",
"gh",
"git"
],
"dependencies": {
"gh-got": "^6.0.0"
},
"devDependencies": {
"ava": "*",
"xo": "*"
},
"xo": {
"esnext": true
}
"name": "github-username",
"version": "5.0.0",
"description": "Get a GitHub username from an email address",
"license": "MIT",
"repository": "sindresorhus/github-username",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=8"
},
"scripts": {
"test": "xo && ava && tsd"
},
"files": [
"index.js",
"index.d.ts"
],
"keywords": [
"github",
"user",
"username",
"email",
"address",
"gh",
"git"
],
"dependencies": {
"gh-got": "^8.1.0"
},
"devDependencies": {
"ava": "^1.4.1",
"tsd": "^0.7.2",
"xo": "^0.24.0"
}
}

@@ -18,6 +18,6 @@ # github-username [![Build Status](https://travis-ci.org/sindresorhus/github-username.svg?branch=master)](https://travis-ci.org/sindresorhus/github-username)

githubUsername('sindresorhus@gmail.com').then(username => {
console.log(username);
(async () => {
console.log(await githubUsername('sindresorhus@gmail.com'));
//=> 'sindresorhus'
});
})();
```

@@ -30,3 +30,3 @@

Returns a `Promise` for the username.
Returns a `Promise<string>` with the username.

@@ -33,0 +33,0 @@ #### email

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc