aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAmine El Baghdadi <75886237+NoobJsPerson@users.noreply.github.com> 2021-05-15 18:30:55 +0000
committerAmine El Baghdadi <75886237+NoobJsPerson@users.noreply.github.com> 2021-05-15 18:30:55 +0000
commitb817a19326b67668ee1026d7cc52781666ec44b7 (patch)
tree32c89fa13d3b0e03fd5db1856fc0b96ac4398343
parent12b56ae0c3980eb786fc8a9f2ca44a9a72392dac (diff)
update 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()
{