javascript-time-ago 2.5.4 → 2.5.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +2 -2
  2. package/index.d.ts +7 -3
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -181,7 +181,7 @@ timeAgo.format(Date.now() - 1.5 * 60 * 1000, 'round')
181
181
  * 1 hour ago
182
182
  * 2 hours ago
183
183
  * …
184
- * 59 hours ago
184
+ * 23 hours ago
185
185
  * 1 day ago
186
186
  * 2 days ago
187
187
  * …
@@ -938,4 +938,4 @@ On March 9th, 2020, GitHub, Inc. silently [banned](https://medium.com/@catamphet
938
938
 
939
939
  ## License
940
940
 
941
- [MIT](LICENSE)
941
+ [MIT](LICENSE)
package/index.d.ts CHANGED
@@ -2,7 +2,11 @@ export type DateInput = Date | number;
2
2
 
3
3
  export type Locale = string;
4
4
 
5
- export type LabelStyleName = 'long' | 'short' | 'narrow' | 'mini' | 'now';
5
+ // Users can add custom styles via `TimeAgo.addLabels(locale, styleName, labels)`.
6
+ export type CustomLabelStyleName = string;
7
+ // There're also "legacy" label styles like "time" or "long-time" that have been deprecated.
8
+ // Users can still use those by adding them manually via `TimeAgo.addLabels()`.
9
+ export type LabelStyleName = 'long' | 'short' | 'narrow' | 'mini' | 'now' | CustomLabelStyleName;
6
10
 
7
11
  export type Rounding = 'round' | 'floor';
8
12
 
@@ -126,8 +130,8 @@ export default class TimeAgo {
126
130
  // Perhaps it's not the best solution, and it would be better to introduce a new function called
127
131
  // `.formatAndGetTimeToNextUpdate()`. But at this stage that would require a "major" version number update,
128
132
  // and I wouldn't prefer doing that for such an insignificant change.
129
- format(date: DateInput, style?: FormatStyleName | Style, options?: FormatOptions): string | [string, number?];
130
- format(date: DateInput, options: FormatOptions): string | [string, number?];
133
+ format(date: DateInput, style?: FormatStyleName | Style, options?: FormatOptions): FormatOptions['getTimeToNextUpdate'] extends true ? [string, number?] : string;
134
+ format<Options extends FormatOptions>(date: DateInput, options: Options): Options['getTimeToNextUpdate'] extends true ? [string, number?] : string;
131
135
  getLabels(labelsType: LabelStyleName | LabelStyleName[]): Labels;
132
136
  static addLocale(localeData: LocaleData): void;
133
137
  static addDefaultLocale(localeData: LocaleData): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "javascript-time-ago",
3
- "version": "2.5.4",
3
+ "version": "2.5.7",
4
4
  "description": "Localized relative date/time formatting",
5
5
  "main": "index.cjs",
6
6
  "module": "index.js",