stringify-without-comments.js 465 B

123456789101112131415161718
  1. "use strict";
  2. /*
  3. Copyright 2018 Google LLC
  4. Use of this source code is governed by an MIT-style
  5. license that can be found in the LICENSE file or at
  6. https://opensource.org/licenses/MIT.
  7. */
  8. const objectStringify = require('stringify-object');
  9. const stripComments = require('strip-comments');
  10. module.exports = obj => {
  11. return objectStringify(obj, {
  12. transform: (_obj, _prop, str) => typeof _obj[_prop] === 'function' ? stripComments(str) : str
  13. });
  14. };