src/parts.js
function resolveNodeValue(value, part) {
  if (isDirective(value)) {
    value = resolveDirectiveValue(value, part);
  }

  if (value === nothingString || value === undefined) {
    return emptyStringBuffer;
  }

  if (isPrimitive(value)) {
    const string = typeof value !== 'string' ? String(value) : value;
    // Escape if not prefixed with unsafePrefixString, otherwise strip prefix
    return Buffer.from(
      string.indexOf(unsafePrefixString) === 0 ? string.slice(33) : escapeHTML(string)
    );
  } else if (isTemplateResult(value) || Buffer.isBuffer(value)) {
    return value;
  } else if (isPromise(value)) {
    return value.then((value) => resolveNodeValue(value, part));
  } else if (isSyncIterator(value)) {
    if (!Array.isArray(value)) {
      value = Array.from(value);
    }
    return value.reduce((values, value) => {
      value = resolveNodeValue(value, part);
      // Flatten
      if (Array.isArray(value)) {
        return values.concat(value);
      }
      values.push(value);
      return values;
    }, []);
  } else if (isAsyncIterator(value)) {
    return resolveAsyncIteratorValue(value, part);
  } else {
    throw Error('unknown NodePart value', value);
  }
}
function resolveNodeValue(value, part) {
  if (isDirective(value)) {
    value = resolveDirectiveValue(value, part);
  }

  if (value === nothingString || value === undefined) {
    return emptyStringBuffer;
  }

  if (isPrimitive(value)) {
    const string = typeof value !== 'string' ? String(value) : value;
    // Escape if not prefixed with unsafePrefixString, otherwise strip prefix
    return Buffer.from(
      string.indexOf(unsafePrefixString) === 0 ? string.slice(33) : escapeHTML(string)
    );
  } else if (isTemplateResult(value) || Buffer.isBuffer(value)) {
    return value;
  } else if (isPromise(value)) {
    return value.then((value) => resolveNodeValue(value, part));
  } else if (isSyncIterator(value)) {
    if (!Array.isArray(value)) {
      value = Array.from(value);
    }
    return value.reduce((values, value) => {
      value = resolveNodeValue(value, part);
      // Flatten
      if (Array.isArray(value)) {
        return values.concat(value);
      }
      values.push(value);
      return values;
    }, []);
  } else if (isAsyncIterator(value)) {
    return resolveAsyncIteratorValue(value, part);
  } else {
    throw Error('unknown NodePart value', value);
  }
}
function resolveNodeValue ( value , part ) { if ( isDirective ( value ) ) { value = resolveDirectiveValue ( value , part ) ; } if ( value === nothingString || value === undefined ) { return emptyStringBuffer ; } if ( isPrimitive ( value ) ) { const string = typeof value !== 'string' ? String ( value ) : value ; // Escape if not prefixed with unsafePrefixString, otherwise strip prefix return Buffer . from ( string . indexOf ( unsafePrefixString ) === 0 ? string . slice ( 33 ) : escapeHTML ( string ) ) ; } else if ( isTemplateResult ( value ) || Buffer . isBuffer ( value ) ) { return value ; } else if ( isPromise ( value ) ) { return value . then ( ( value ) => resolveNodeValue ( value , part ) ) ; } else if ( isSyncIterator ( value ) ) { if ( ! Array . isArray ( value ) ) { value = Array . from ( value ) ; } return value . reduce ( ( values , value ) => { value = resolveNodeValue ( value , part ) ; // Flatten if ( Array . isArray ( value ) ) { return values . concat ( value ) ; } values . push ( value ) ; return values ; } , [ ] ) ; } else if ( isAsyncIterator ( value ) ) { return resolveAsyncIteratorValue ( value , part ) ; } else { throw Error ( 'unknown NodePart value' , value ) ; } }
Resolve "value" to string Buffer if possible

@param { any } value
@param { NodePart } part
@returns { any }
Resolve value to string Buffer if possible