aboutsummaryrefslogtreecommitdiffhomepage
path: root/main.js
diff options
context:
space:
mode:
Diffstat (limited to 'main.js')
-rw-r--r--main.js14
1 files changed, 12 insertions, 2 deletions
diff --git a/main.js b/main.js
index 789c316..e4883d9 100644
--- a/main.js
+++ b/main.js
@@ -1,5 +1,15 @@
-/* Import the interpolate function*/
-import interpolate from "interpolate.js";
+/* Define the interpolate function */
+function interpolate(template, variables) {
+ return template.replace(/\${[^{]+}/g, (match) => {
+ const path = match.slice(2, -1).trim();
+ return getObjPath(path, variables);
+ });
+}
+
+/* Get the specified property or nested property of an object */
+function getObjPath(path, obj) {
+ return path.split('.').reduce((res, key) => res[key], obj);
+}
/* Compute the total duration of the run. */
function compute()
{