From 12b56ae0c3980eb786fc8a9f2ca44a9a72392dac Mon Sep 17 00:00:00 2001 From: Amine El Baghdadi <75886237+NoobJsPerson@users.noreply.github.com> Date: Sat, 15 May 2021 18:29:33 +0000 Subject: delete interpolate.js --- interpolate.js | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 interpolate.js diff --git a/interpolate.js b/interpolate.js deleted file mode 100644 index 0c20589..0000000 --- a/interpolate.js +++ /dev/null @@ -1,11 +0,0 @@ -export default 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); -} \ No newline at end of file -- cgit v1.2.3