stringify-object-values

Stringify object values

Usage no npm install needed!

<script type="module">
  import stringifyObjectValues from 'https://cdn.skypack.dev/stringify-object-values';
</script>

README

stringify-object-values

npm i stringify-object-values

Stringifies each value of an object. This is useful when paired with Webpack's DefinePlugin.

// Before
{
  hello: 'world',
  favorite: 1,
  equation: '1+1',
  random: {},
  arr: []  
}

// After
{
  hello: "'world'",
  favorite: 1,
  equation: "'1+1'",
  random: "{}",
  arr: "[]"
}

Usage

var stringify = require('stringify-object-values');
stringify(obj);

With webpack.DefinePlugin

var webpack = require('webpack');
var stringify = require('stringify-object-values');

module.exports = {
  plugins: [
    new webpack.DefinePlugin({ 'process.env': stringify(process.env) });
  ]
}