stringify-without-comments.js 1.1 KB

12345678910111213141516171819202122232425262728
  1. "use strict";
  2. /*
  3. Copyright 2021 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. var __importDefault = (this && this.__importDefault) || function (mod) {
  9. return (mod && mod.__esModule) ? mod : { "default": mod };
  10. };
  11. Object.defineProperty(exports, "__esModule", { value: true });
  12. exports.stringifyWithoutComments = void 0;
  13. const stringify_object_1 = __importDefault(require("stringify-object"));
  14. const strip_comments_1 = __importDefault(require("strip-comments"));
  15. function stringifyWithoutComments(obj) {
  16. return (0, stringify_object_1.default)(obj, {
  17. // See https://github.com/yeoman/stringify-object#transformobject-property-originalresult
  18. transform: (_obj, _prop, str) => {
  19. if (typeof _prop !== 'symbol' && typeof _obj[_prop] === 'function') {
  20. // Can't typify correctly stripComments
  21. return (0, strip_comments_1.default)(str); // eslint-disable-line
  22. }
  23. return str;
  24. },
  25. });
  26. }
  27. exports.stringifyWithoutComments = stringifyWithoutComments;