For Interval, Pace/Speed, Distance, and Duration calculations
import * as dfit from "dfit";
// Objects
dfit.interval();
dfit.distance();
dfit.duration();
dfit.speed();
dfit.pace();
let dur;
// with an object - can accept any keys allowed by moment.duration() {y|M|w|d|h|m|s|ms}
dur = dfit.duration({ h: 2, m: 55, s: 00 });
dur.pretty(); // '2:55:00'
// with a string
dur = dfit.duration("2:55:00");
dur.pretty(); // '2:55:00'
// with a number and unit
dur = dfit.duration(2, "h");
dur.pretty(); // '2:00:00'
// adding or subtracting
dur = dfit.duration(2, "h").add({ m: 55 });
dur.pretty(); // '2:55:00'
dur = dfit.duration("3:00:00").subtract(5, "m");
dur.pretty(); // '2:55:00'
let dist;
// with an object - accepted units {km|m|cm|mm|mile|miles}
dist = dfit.distance({ miles: 26.2 });
// with a number and unit
dist = dfit.distance(10, "km");
// initialize to 0
dist = dfit.distance();
let pace;
// with Duration and Distance
pace = dfit.pace(dfit.duration({ h: 2, m: 55 }), dfit.distance(26.2, "miles"));
// with duration/distance values and units (duration, distance, durationUnit, distanceUnit)
pace = dfit.pace("2:55:00", 26.2, null, "miles");
Prerequisite:
Install package:
npm install dfit
dfit depends on the following modules at runtime:
- moment - For Duration calculations
dfit depends on the following modules for testing:
Cleans the build folder, copies squarespace files (jsont, less, assets folder content) into the build folder, runs webpack to build the template javascript.
/base-template-npm
|--- modules/
|--- tests/
|--- index.js
|--- index.mjs
|--- node_modules/ <-- generated by npm install, ignored by this repo
|--- package.json <-- defines build commands, template module dependencies