Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move to ESM #26

Merged
merged 1 commit into from
Jan 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions gravatar.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* @param email - Email matching a Gravatar profile.
* @example
* ```
* import gravatarUrl = require('@xn-02f/gravatar');
* gravatarUrl('[email protected]', {s: 80});
* import gravatar from '@xn-02f/gravatar';
* gravatar('[email protected]', {s: 80});
* //=> 'https://www.gravatar.com/avatar/961254e23a4de2aa887ac0f56ef5debf?s=80'
* ```
*/
Expand All @@ -17,4 +17,4 @@ declare const gravatar: (
options?: object
) => string;

export = gravatar;
export default gravatar;
6 changes: 3 additions & 3 deletions gravatar.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
* License: MIT
*/

const md5 = require('@xn-02f/md5');
import md5 from '@xn-02f/md5';

const gravatarUrl = 'https://www.gravatar.com/avatar/';

module.exports = (email, options) => {
queryString = (options) ? handleOptions(options) : '';
export default (email, options) => {
let queryString = (options) ? handleOptions(options) : '';

return gravatarUrl + md5Hash(email) + queryString;
}
Expand Down
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
"name": "@xn-02f/gravatar",
"version": "1.3.3",
"description": "A library to generate gravatar image url.",
"type": "module",
"exports": "./gravatar.js",
"main": "gravatar.js",
"types": "gravatar.d.ts",
"scripts": {
Expand All @@ -27,6 +29,9 @@
"ava": "^5.2.0",
"tsd": "^0.28.1"
},
"engines": {
"node": ">=16"
},
"files": [
"gravatar.js",
"gravatar.d.ts"
Expand Down
6 changes: 3 additions & 3 deletions test/gravatar.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*
* This file is used to test.
*/
const test = require('ava')
const md5 = require('@xn-02f/md5')
import test from 'ava'
import md5 from '@xn-02f/md5'

const gravatar = require('../gravatar')
import gravatar from '../gravatar.js'

const baseURL = 'https://www.gravatar.com/avatar/'
const mailReg = /^[-!#$%&'*+\/0-9=?A-Z^_a-z{|}~](\.?[-!#$%&'*+\/0-9=?A-Z^_a-z`{|}~])*@[a-zA-Z0-9](-*\.?[a-zA-Z0-9])*\.[a-zA-Z](-?[a-zA-Z0-9])+$/
Expand Down
Loading