Skip to content

Commit dde4f83

Browse files
committed
Provide proper types
1 parent 54a0fab commit dde4f83

File tree

10 files changed

+46
-18
lines changed

10 files changed

+46
-18
lines changed

History.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

index.d.ts

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,37 @@
1-
// ./index.d.mts
1+
type Units = {
2+
y: 31557600000
3+
mo: 2629800000
4+
w: 604800000
5+
d: 86400000
6+
h: 3600000
7+
m: 60000
8+
s: 1000
9+
ms: 1
10+
us: 1e-3
11+
ns: 1e-6
12+
[key: string]: number;
13+
} & {
14+
group: string;
15+
decimal: string;
16+
}
17+
declare module './locale/*.js' {
18+
const unit: Units;
19+
export default unit;
20+
}
221

3-
export * from './index.js'
4-
export { default } from './index.js'
22+
declare const durationRE: RegExp;
23+
24+
declare namespace parse {
25+
const unit: Units;
26+
}
27+
28+
/**
29+
* Convert a string to milliseconds.
30+
*
31+
* @param {string} str - The string to parse.
32+
* @param {string} format - The format to use for conversion (default is 'ms').
33+
* @returns {number} - The parsed duration in milliseconds.
34+
*/
35+
declare function parse(str?: string, format?: string): number;
36+
37+
export default parse;

locale/de.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import en from './en.js'
33
const unit = Object.create(en)
44

55
unit.jahr = unit.j = en.y
6-
unit.monat = en.month
6+
unit.monat = en.mo
77
unit.woche = en.w
88
unit.tag = unit.t = en.d
99
unit.stunde = en.h

locale/en.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ const unit = Object.create(null)
22
const m = 60000, h = m * 60, d = h * 24, y = d * 365.25
33

44
unit.year = unit.yr = unit.y = y
5-
unit.month = unit.b = y / 12
5+
unit.month = unit.mth = unit.mo = y / 12
66
unit.week = unit.wk = unit.w = d * 7
77
unit.day = unit.d = d
88
unit.hour = unit.hr = unit.h = h
99
unit.minute = unit.min = unit.m = m
1010
unit.second = unit.sec = unit.s = 1000
1111
unit.millisecond = unit.millisec = unit.ms = 1
12-
unit.µs = unit.μs = unit.us = unit.microsecond = 1e-3
13-
unit.nanosecond = unit.ns = 1e-6
12+
unit.microsecond = unit.microsec = unit.us = unit.µs = 1e-3
13+
unit.nanosecond = unit.nanosec = unit.ns = 1e-6
1414

1515
unit.group = ','
1616
unit.decimal = '.'

locale/es.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import en from './en.js'
33
const unit = Object.create(en)
44

55
unit.año = unit.a = en.y
6-
unit.mes = unit.b = en.month
6+
unit.mes = en.mo
77
unit.semana = en.w
88
unit.día = en.d
99
unit.hora = en.h

locale/fr.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import en from './en.js'
33
const unit = Object.create(en)
44

55
unit.année = unit.an = unit.a = en.y
6-
unit.mois = unit.mo = en.month
6+
unit.mois = en.mo
77
unit.semaine = unit.sem = en.w
88
unit.jour = unit.j = en.d
99
unit.heure = en.h

locale/ja.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import en from './en.js'
33
const unit = Object.create(en)
44

55
unit. = unit.年間 = en.y
6-
unit. = unit.ヶ月 = en.month
6+
unit. = unit.ヶ月 = en.mo
77
unit. = unit.週間 = en.w
88
unit. = en.d
99
unit.時間 = unit. = en.h

locale/pt.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import en from './en.js'
33
const unit = Object.create(en)
44

55
unit.ano = unit.a = en.y
6-
unit.mês = unit.mes = en.month
6+
unit.mês = unit.mes = en.mo
77
unit.semana = unit.sem = en.w
88
unit.dia = en.d
99
unit.hora = en.h

locale/ru.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import en from './en.js'
33
const unit = Object.create(en)
44

55
unit.год = unit.г = en.y
6-
unit.месяц = unit.мес = en.month
6+
unit.месяц = unit.мес = en.mo
77
unit.неделя = unit.нед = en.w
88
unit.день = unit.д = en.d
99
unit.час = unit.ч = en.h

locale/zh.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import en from './en.js'
33
const unit = Object.create(en)
44

55
unit. = en.y
6-
unit. = en.month
6+
unit. = en.mo
77
unit. = unit.星期 = en.w
88
unit. = unit. = en.d
99
unit.小时 = unit. = en.h

0 commit comments

Comments
 (0)