gravatar-from-email v1.0.0
gravatar-from-email
Install
pnpm add --save-prod gravatar-from-email
Warning: This package is ESM only
Note: The
engines
field is set to>=18
, but it should work with Node.js >=14.16, and >=16.0
Usage
import { gravatarFromEmail } from 'gravatar-from-email';
API
gravatarFromEmail(email, options?): URL
email
(required)
Type: string
Email to get the Gravatar for.
options?
Type: Options
An optional Object can be passed to the function. If omitted, the following defaults are always applied:
{
rating: 'g',
size: '80',
}
Why?
Why bother making this?
A lot of websites support Gravatars these days, either implicitly, or they allow you to set your profile picture explicitly by passing an image request URL.
Why use this over existing implementations?
No reason at all. If you find existing implementations better suited to your needs, by all means, use that. I wrote this for my own needs, and plan on maintaining it for a long time.
Why does this not also check if the input (email) is email-like?
That’s not what this module is intended for^1. Use
email-regex
for that.
Why does this return a URL
and not a string
?
Because it is more versatile. You can always use
.toJSON()
, or
.toString()
to convert the URL
to a string
.
Why use a named export instead of a default export?
In this case, it’s a preference. This is extensively discussed here.
Why not support the http://
protocol even though Gravatar supports it?
Because it’s 2023. Also, because it is more secure than the alternative.
Related
^2:
It does not support ESM, has an external dependency
(crypto-js
), and is not
actively maintained
^3:
It does support ESM, is actively maintained, and will probably work just as
well as this package. But it has external dependencies
(md5-hex and
type-fest
)
^4:
It does not support ESM, has external dependencies
(@sailshq/lodash and
machine
), and is not actively
maintained
^5:
It does not support ESM, has an external dependency
(md5
), and is not actively maintained
1 year ago