Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gravator

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gravator - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

50

index.js

@@ -1,47 +0,27 @@

#!/usr/bin/env node
'use strict';
var got = require('got');
const got = require('got');
var cheerio = require('cheerio');
var Promise = require('pinkie-promise');
module.exports = function (username) {
module.exports = (username, opts) => {
if (typeof username !== 'string') {
return Promise.reject(new Error('username required'));
throw new TypeError(`Expected a string, got ${typeof username}`);
}
var url = 'http://en.gravatar.com/' + username;
if (typeof opts !== 'string') {
throw new TypeError(`Expected a string, got ${typeof opts}`);
}
return got(url).then(function (res) {
var $ = cheerio.load(res.body);
const url = `https://en.gravatar.com/${username}.json`;
return got(url, {json: true}).then(res => {
const val = res.body;
return {
username: $('.fn').text() || null,
location: $('.location').text() || null,
biography: $('#bio').text().trim() || null,
wordpress: $('a.accounts_wordpress').attr('href') || null,
twitter: $('a.accounts_twitter').attr('href') || null,
facebook: $('a.accounts_facebook').attr('href') || null,
flickr: $('a.accounts_flickr').attr('href') || null,
googlePlus: $('a.accounts_google').attr('href') || null,
linkedIn: $('a.accounts_linkedin').attr('href') || null,
youtube: $('a.accounts_youtube').attr('href') || null,
blogger: $('a.accounts_blogger').attr('href') || null,
tumblr: $('a.accounts_tumblr').attr('href') || null
opts: val.entry[0][opts]
};
}).catch(err => {
if (err) {
err.message = `${username} is not a gravatar user`;
}
return err.message;
});
};
{
"name": "gravator",
"version": "1.0.1",
"description": "Get user information of a Gravatar user",
"version": "1.0.2",
"description": "An unofficial API for Gravatar.com mostly for scrapping user data",
"license": "MIT",

@@ -32,5 +32,3 @@ "repository": {

"dependencies": {
"cheerio": "^0.19.0",
"got": "^5.0.0",
"pinkie-promise": "^2.0.0"
"got": "^5.0.0"
},

@@ -37,0 +35,0 @@ "devDependencies": {

<h1 align="center">
<img src="media/gravator.png" alt="GRAVATOR" width="400">
<img src="https://raw.githubusercontent.com/CodeDotJS/gravator/master/media/gravator.png" alt="GRAVATOR" width="400">
<br>
<img src="https://travis-ci.org/CodeDotJS/gravator.svg?branch=master">
<img src="https://img.shields.io/badge/code_style-XO-5ed9c7.svg">
</h1>
<h5 align="center">Get user information of a Gravatar User</h5>
<p align="center"><b>An unofficial API for Gravatar.com mostly for scrapping user data.</b></p>
<h1 align="center">
<img src="https://travis-ci.org/CodeDotJS/gravator.svg?branch=master">
</h1>
## Install
## Install
```

@@ -20,40 +18,80 @@ $ npm install --save gravator

- `username` of a gravatar user is always __`foo`__`@example.com`
```js
'use strict';
const gravator = require('rushforlinux');
const gravator = require('gravator');
gravator('rushforlinux').then(user => {
console.log(user);
/*
{ username : 'Rishi Giri (DotJS)',
location : 'Gorakhpur',
biography : 'JavaScript, Python and FOSS Enthusiast. Open Source Addict.',
wordpress : null,
twitter : 'http://twitter.com/Rishi_Giri_',
facebook : 'https://www.facebook.com/rishi.giri.90',
flickr : null,
googlePlus : 'http://profiles.google.com/106157567815478859311',
linkedIn : 'https://www.linkedin.com/in/rishidotjs',
youtube : null,
blogger : 'http://www.blogger.com/profile/g106157567815478859311',
tumblr : 'http://geekyrush.tumblr.com/' }
*/
gravator('username', 'options').then(res => {
console.log(res);
// {opts: 'data'}
});
gravator('foo', 'hash').then(res => {
console.log(res);
// {opts: 'foo'}
})
```
## Related
## API
- [gravator-cli](https://github.com/CodeDotJS/gravator-cli) : CLI Tool for Gravator.
### `gravator(username, options)`
- [twifo](https://github.com/CodeDotJS/whatiz-cli) : Get user information of a twitter user.
#### __`username`__
- [packages-by](https://github.com/CodeDotJS/packages-by) : Total packages published by a npm user.
Type: `string`
- [packstat](https://github.com/CodeDotJS/packstat) : Displays metrics about npm modules.
#### __`options`__
- [curver](https://github.com/CodeDotJS/curver) : Easily fetch the latest version of node module available on npm.
Type: `string`
Options:
- `id`
__`Example `__
```js
gravator('matt', 'id').then(res => {
console.log(res);
// // {opts: '5'}
});
```
- `hash`
- `requestHash`
- `profileUrl`
- `preferredUsername`
- `thumbnailUrl`
- `photos`
- `name`
- `ims`
- `displayName`
- `aboutMe`
- `currentLocation`
- `emails`
- `accounts`
- `urls`
## Related
- __[`gravator-cli`](https://github.com/CodeDotJS/gravator-cli)__ `: CLI Tool for Gravator.`
- __[`twifo`](https://github.com/CodeDotJS/whatiz-cli)__ `: Get user information of a twitter user.`
## License
MIT &copy; [Rishi Giri](http://rishigiri.com/)
MIT &copy; [Rishi Giri](http://rishigiri.com)
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