function str (parts, ...args) {
  let [res, ...rest] = parts
  for (let i = 0; i < rest.length; i++) {
    let expr = stringify(args[i])
    const nextTmpl = rest[i]
    if (res.endsWith('"') && nextTmpl.startsWith('"')) {
      expr = escape(expr)
    }
    res += expr + nextTmpl
  }
  return res
}
/**
 * Looks like a reason to use a ES6 tag function first time in my life
 * Also if you replace `parts` with `parts.raw`, you will avoid escaping characters in the template
 *
 * @example
 * let test = { "foo": "bar" }
 * str`unquoted ${test}, quoted "${test}"`
 * // unquoted {"foo":"bar"}, quoted "{\"foo\":\"bar\"}"
 *
 * @param {string[]} parts Template literal string parts
 * @param {...string} args Template literal expressions
 *
 * @returns {string} The same string but expressions are JSON-stringified
 */
Looks like a reason to use a ES6 tag function first time in my life
Also if you replace `parts` with `parts.raw`, you will avoid escaping characters in the template



@param {string[]} parts Template literal string parts
@param {...string} args Template literal expressions

@returns {string} The same string but expressions are JSON-stringified
Looks like a reason to use a ES6 tag function first time in my life Also if you replace ` parts ` with ` parts . raw ` you will avoid escaping characters in the template @param { string [] } parts Template literal string parts @param { ... string } args Template literal expressions @returns { string } The same string but expressions are JSON - stringified
function str (parts, ...args) {
  let [res, ...rest] = parts
  for (let i = 0; i < rest.length; i++) {
    let expr = stringify(args[i])
    const nextTmpl = rest[i]
    if (res.endsWith('"') && nextTmpl.startsWith('"')) {
      expr = escape(expr)
    }
    res += expr + nextTmpl
  }
  return res
}
function str ( parts , ... args ) { let [ res , ... rest ] = parts for ( let i = 0 ; i < rest . length ; i ++ ) { let expr = stringify ( args [ i ] ) const nextTmpl = rest [ i ] if ( res . endsWith ( '"' ) && nextTmpl . startsWith ( '"' ) ) { expr = escape ( expr ) } res += expr + nextTmpl } return res }
Looks like a reason to use a ES6 tag function first time in my life
 Also if you replace `parts` with `parts.raw`, you will avoid escaping characters in the template
Looks like a reason to use a ES6 tag function first time in my life Also if you replace ` parts ` with ` parts . raw ` you will avoid escaping characters in the template