Quantcast
Channel: Active questions tagged config - Stack Overflow
Viewing all articles
Browse latest Browse all 5054

Refactoring javascript string config

$
0
0

I have a huge string config in a file and i want to refactor it to have intelisense.
Note there are also variables in it, so using a function would be the best option.
The result of the return function should be exactly what's inside the config string.

  const existingConfig = `  var configOptions =  {    enableProp: true,    style: "plain",    onReady: function() {        return true    }  }    `;

I tried something like:

  const newConfig = (val) => {    return {      enableProp: true,      style: val,      onReady: function() {        return true      }    };  };  const res = JSON.stringify(newConfig());

Any ideas?


Viewing all articles
Browse latest Browse all 5054

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>