src/HCL.js
function renderDefinitionRhs(val, indent) {
  indent = indent || 0;
  const indentStr = Array(indent + 1).join(' ');

  if (isUndefined(val)) {
    throw new Error('Undefined value in definition RHS.');
  }
  if (isBoolean(val)) {
    return val.toString();
  }
  if (isInteger(val)) {
    return val;
  }
  if (isString(val)) {
    return JSON.stringify(val);
  }
  if (isArray(val)) {
    return ['[', map(val, (elem) => `${indentStr}  ${JSON.stringify(elem)}`).join(',\n'), `${indentStr}]`].join('\n');
  }
  if (isObject(val)) {
    const rhsLines = exports.renderDefinition(val, indent + 2);
    const rhsStr = rhsLines;
    return `{
${rhsStr}
${indentStr}}`;
  }
}
function renderDefinitionRhs(val, indent) {
  indent = indent || 0;
  const indentStr = Array(indent + 1).join(' ');

  if (isUndefined(val)) {
    throw new Error('Undefined value in definition RHS.');
  }
  if (isBoolean(val)) {
    return val.toString();
  }
  if (isInteger(val)) {
    return val;
  }
  if (isString(val)) {
    return JSON.stringify(val);
  }
  if (isArray(val)) {
    return ['[', map(val, (elem) => `${indentStr}  ${JSON.stringify(elem)}`).join(',\n'), `${indentStr}]`].join('\n');
  }
  if (isObject(val)) {
    const rhsLines = exports.renderDefinition(val, indent + 2);
    const rhsStr = rhsLines;
    return `{
${rhsStr}
${indentStr}}`;
  }
}
function renderDefinitionRhs ( val , indent ) { indent = indent || 0 ; const indentStr = Array ( indent + 1 ) . join ( ' ' ) ; if ( isUndefined ( val ) ) { throw new Error ( 'Undefined value in definition RHS.' ) ; } if ( isBoolean ( val ) ) { return val . toString ( ) ; } if ( isInteger ( val ) ) { return val ; } if ( isString ( val ) ) { return JSON . stringify ( val ) ; } if ( isArray ( val ) ) { return [ '[' , map ( val , ( elem ) => ` ${ indentStr } ${ JSON . stringify ( elem ) } ` ) . join ( ',\n' ) , ` ${ indentStr } ` ] . join ( '\n' ) ; } if ( isObject ( val ) ) { const rhsLines = exports . renderDefinition ( val , indent + 2 ) ; const rhsStr = rhsLines ; return ` ${ rhsStr } ${ indentStr } ` ; } }
Render the right-hand side of a definition.
@param {*} val Value to render
@param {?number} indent Number of spaces to indent.
@return {string} Rendered RHS.
Render the right - hand side of a definition .