text: "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  const quote_1 = require("./quote");
  const function_1 = require("./function");
  /**
   * Stringify an object of keys and values.
   */
  function objectToString(obj, indent, next) {
      const eol = indent ? "\n" : "";
      // Iterate over object keys and concat string together.
      const values = Object.keys(obj)
          .reduce(function (values, key) {
          if (typeof obj[key] === "function") {
              const parser = new function_1.FunctionParser(obj[key], indent, next, key);
              const result = parser.stringify();
              values.push(indent + result.split("\n").join(`\n${indent}`));
              return values;
          }
          const result = next(obj[key], key);
          // Omit `undefined` object entries.
          if (result === undefined)
              return values;
          // String format the value data.
          const value = result.split("\n").join(`\n${indent}`);
          values.push(`${indent}${quote_1.quoteKey(key, next)}:${indent ? " " : ""}${value}`);
          return values;
      }, [])
          .join(`,${eol}`);
      // Avoid new lines in an empty object.
      if (values === "")
          return "{}";
      return `{${eol}${values}${eol}}`;
  }
  exports.objectToString = objectToString;
  //# sourceMappingURL=object.js.map