feat(gravatar): missing 1.8 version features (#42843)

- correct DT header and package version
- `profile_url` method
- `cdn` options property
- `forceProtocol` aligned with documented `protocol`
- adding new method resulted in module shape correction (export `url`
and `profile_url` directly from the module
- tests updated
- update tslint config

https://github.com/emerleite/node-gravatar#usage
https://github.com/emerleite/node-gravatar#examples
dd76e57087/Changelog.md (180)

Thanks!
This commit is contained in:
Andrew Casey 2020-03-05 12:54:53 -08:00 committed by GitHub
parent 1c9e1cbfbb
commit 5f2ca8c55a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 51 additions and 45 deletions

View File

@ -1,16 +1,21 @@
import gravatar = require('gravatar');
gravatar.url("email@example.com");
gravatar.url("email@example.com", { s: "200", r: "pg", d: "404" });
gravatar.url("email@example.com", { size: "200", r: "pg", d: "404" });
gravatar.url("email@example.com", { s: "200" });
gravatar.url("email@example.com", { default: "404" });
gravatar.url("email@example.com", { s: "200", rating: "pg", d: "404" }, true);
gravatar.url("email@example.com", { s: "200", r: "pg", default: "404" }, false);
gravatar.url("email@example.com", { d: "404" }, false);
gravatar.url("email@example.com", { forcedefault: "y" }, false);
gravatar.url("email@example.com", { f: "y" });
gravatar.url("email@example.com", { protocol: "https" });
gravatar.url("email@example.com", { format: "xml" });
gravatar.url('email@example.com');
gravatar.url('email@example.com', { s: '200', r: 'pg', d: '404' });
gravatar.url('email@example.com', { size: '200', r: 'pg', d: '404' });
gravatar.url('email@example.com', { s: '200' });
gravatar.url('email@example.com', { default: '404' });
gravatar.url('email@example.com', { s: '200', rating: 'pg', d: '404' }, true);
gravatar.url('email@example.com', { s: '200', r: 'pg', default: '404' }, false);
gravatar.url('email@example.com', { d: '404' }, false);
gravatar.url('email@example.com', { forcedefault: 'y' }, false);
gravatar.url('email@example.com', { f: 'y' });
gravatar.url('email@example.com', { protocol: 'https' });
gravatar.url('email@example.com', { format: 'xml' });
gravatar.profile_url('email@example.com');
gravatar.profile_url('email@example.com', {});
gravatar.profile_url('email@example.com', {}, true);
gravatar.profile_url('emerleite@gmail.com', { protocol: 'https' });
gravatar.profile_url('emerleite@gmail.com', { protocol: 'http', format: 'qr' });
gravatar.url('email@example.com', { cdn: 'http://cdn-gravatar.wuweixing.com' });
gravatar.profile_url('email@example.com', { cdn: 'http://cdn-gravatar.wuweixing.com' });

View File

@ -1,23 +1,35 @@
// Type definitions for gravatar v1.8.0
// Type definitions for gravatar 1.8
// Project: https://github.com/emerleite/node-gravatar
// Definitions by: Denis Sokolov <https://github.com/denis-sokolov>
// Piotr Błażejewicz <https://github.com/peterblazejewicz>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace GravatarModule {
type Options = {
d?: string
default?: string
f?: string
forcedefault?: string
format?: string
protocol?: string
r?: string
rating?: string
s?: string
size?: string
}
function url(email: string, options?: Options, forceProtocol?: boolean): string;
export interface Options {
cdn?: string;
d?: string;
default?: string;
f?: string;
forcedefault?: string;
format?: string;
protocol?: string;
r?: string;
rating?: string;
s?: string;
size?: string;
}
export = GravatarModule;
/**
* @param email - The gravatar email
* @param [options] - Query string options
* @param [protocol] - Define if will use no protocol, http or https gravatar URL.
* Default is 'undefined', which generates URLs without protocol.
* True to force https and false to force http
*/
export function url(email: string, options?: Options, protocol?: boolean): string;
/**
* @param email - The gravatar email
* @param [options] - Query string options
* @param [protocol] - Define if will use no protocol, http or https gravatar URL.
* Default is 'undefined', which generates URLs without protocol.
* True to force https and false to force http
*/
export function profile_url(email: string, options?: Options, protocol?: boolean): string;

View File

@ -1,14 +1,3 @@
{
"extends": "dtslint/dt.json",
"rules": {
"callable-types": false,
"dt-header": false,
"export-just-namespace": false,
"interface-over-type-literal": false,
"no-consecutive-blank-lines": false,
"no-redundant-jsdoc": false,
"prefer-method-signature": false,
"semicolon": false,
"trim-file": false
}
}
"extends": "dtslint/dt.json"
}