Calculate running pace, time or length by providing the other two.
Interactive demo: https://daghall.github.io/run-pace/
Run as a command line program.
npm install -g run-pace
run-pace -t <time> -l <length> -p <pace> [-i] [-m] [-s]
Two of "time", "length" and "pace" must be provided.
"Speed" is only valid when (only) pace is given or calculated
Parameters:
-l, --length, <value><unit> (10km, 10mi, 10000m, hm, ma)
-p, --pace, <value>/<unit> (4:30/km, 4m30s/mi)
-t, --time, <value> (11:23, 11min23sec, 11m23s)
-i, --imperial, force imperial output
-m, --metric, force metric output
-s, --speed, output speed instead of pace
run-pace -p 4:50/km -t 1hour
12.41 km
run-pace -p 4:50/km -l 3.5km
16:55
run-pace -p 4:30/km -s -i
8.3 mph
run-pace -l 3 -t 15:00
5:00/km
Use in a node script.
npm install run-pace
const runPace = require("run-pace");
All methods takes an object as its only argument.
Call with an object with the properties time
and length
.
const length = runPace.calculateLength({
time: "45m",
pace: "4:30/km",
});
console.log(length); // 10km
Call with an object with the properties pace
and length
.
const time = runPace.calculateTime({
length: "10km",
pace: "4:30/km",
});
console.log(time); // 45:00
Call with an object with the properties time
and length
.
const pace = runPace.calculatePace({
time: "45m",
length: "10km",
});
console.log(pace); // 4:30/km
Can be provided in the following formats:
04:40
2:44:36
0:59
0:3599
(non-standard)
Only one unit needs to be provided.
<d>
is in the formatdays
,day
ord
<h>
is in the formathours
,hour
,hrs
orh
<m>
is in the formatmins
,min
orm
<s>
is in the formatsecs
,sec
ors
2days13hours45mins16secs
3hrs15sec
23m16s
Defaults to kilometers. If length is provided in miles, imperial output is implicitly enabled, but can be overridden using the metric switch.
If no unit is given, the type is inferred from the metric/imperial flags, and/or the unit given in the pace field.
X
is a number, including optional decimal point
<unit>
is one of the following:
- Kilometers:
km
ork
- Meters:
m
- Miles:
mi
- Blank: defaults to kilometers
- Half-marathon:
hm
- Marathon:
ma
hm
10k
5.25KM
(case-insensitive)26.21875mi
Defaults to kilometer pace. If length is provided in miles, imperial output is implicitly enabled, but can be overridden using the metric switch.
<time>
as specified above
<unit>
is km
or mi
if explicitly given. Left blank it defaults to km
or is inferred from other given parameters
Default output is kilometers. Use this switch to force output in miles.
If miles are given in pace or length output will be in miles as well. Use this switch to force output in kilometers.
Output speed in instead of pace. Units used are km/h or mph depending on types/options specified.
Only valid if pace is given or calculated.
run-pace -t 7m15s -l 1mi -m
4:30/km
run-pace -t 4:30 -l 1k -i
7:15/mi
run-pace -p 4:55/km -s
12.2 km/h
run-pace -p 4:00/mi -s
15 mph