Appends the directive end for a resulting string
and returns a new string

@param {string} str - resulting string
@param {!Object} struct - structure object
@return {string}
501310
function appendDirEnd(str, struct) {
	if (!struct.block) {
		return str;
	}

	const [rightSpace] = rightWSRgxp.exec(str);
	str = str.replace(rightPartRgxp, '');

	const
		s = alb + lb,
		e = rb;

	let tmp;
	if (needSpace) {
		tmp = `${struct.trim.right ? '' : eol}${endDirInit ? '' : `${s}__&+__${e}`}${struct.trim.right ? eol : ''}`;

	} else {
		tmp = eol + struct.space.slice(1);
	}

	endDirInit = true;
	str += `${tmp}${struct.adv + lb}__end__${e}${s}__cutLine__${e}`;

	if (rightSpace && needSpace) {
		str += `${s}__&-__${rb}`;
	}

	return str + rightSpace;
}
638714
public static String insert(final String str, final String given, final int begin, final int end) {
    if (begin < 1 || end > str.length() || end < begin) { return str; }
    return str.substring(0, begin - 1) + given + str.substring(end);
  }
948785
function fmt(str){
  var args = [].slice.call(arguments, 1);
  var j = 0;

  return str.replace(/%([a-z])/gi, function(_, f){
    return fmt[f]
      ? fmt[f](args[j++])
      : _ + f;
  });
}
337046
def StrConcat(*args):
    
    new_value = ''.join([arg.value for arg in args])
    return StringV(new_value)
615763
function string(str) {
  assertString(str);
  var expected = "'" + str + "'";
  return Parsimmon(function(input, i) {
    var j = i + str.length;
    var head = input.slice(i, j);
    if (head === str) {
      return makeSuccess(j, head);
    } else {
      return makeFailure(i, expected);
    }
  });
}
1360503
public String End(final boolean format) {
    if (this.openedStructCounter != 0) {
      throw new IllegalStateException("Detected unclosed structs: " + this.openedStructCounter);
    }

    final StringBuilder buffer = new StringBuilder(128);

    int structCounter = 0;

    for (final Item item : this.items) {
      switch (item.type) {
        case STRUCT: {
          doTabs(format, buffer, structCounter).append(item.name == null ? "" : item.name).append('{');
          structCounter++;
        }
        break;
        case STRUCT_ARRAY: {
          doTabs(format, buffer, structCounter).append(item.name == null ? "" : item.name).append('[').append(item.sizeExpression).append(']').append('{');
          structCounter++;
        }
        break;
        case UNDEFINED: {
          if (item instanceof ItemStructEnd) {
            final ItemStructEnd structEnd = (ItemStructEnd) item;
            if (structEnd.endAll) {
              while (structCounter > 0) {
                structCounter--;
                doTabs(format, buffer, structCounter).append('}');
                if (structCounter > 0 && format) {
                  buffer.append('\n');
                }
              }
            } else {
              structCounter--;
              doTabs(format, buffer, structCounter).append('}');
            }
          } else if (item instanceof ItemCustom) {
            doTabs(format, buffer, structCounter).append(item.toString());
          } else if (item instanceof ItemAlign) {
            doTabs(format, buffer, structCounter).append("align").append(item.sizeExpression == null ? "" : ':' + item.makeExpressionForExtraField(item.sizeExpression)).append(';');
          } else if (item instanceof ItemVal) {
            doTabs(format, buffer, structCounter).append("val").append(':').append(item.makeExpressionForExtraField(item.sizeExpression)).append(' ').append(item.name).append(';');
          } else if (item instanceof ItemResetCounter) {
            doTabs(format, buffer, structCounter).append("reset$$;");
          } else if (item instanceof ItemSkip) {
            doTabs(format, buffer, structCounter).append("skip").append(item.sizeExpression == null ? "" : ':' + item.makeExpressionForExtraField(item.sizeExpression)).append(';');
          } else if (item instanceof ItemComment) {
            final ItemComment comment = (ItemComment) item;
            final String commentText = comment.getComment().replace("\n", " ");
            if (comment.isNewLine()) {
              if (buffer.length() > 0) {
                final int lastNewLine = buffer.lastIndexOf("\n");
                if (lastNewLine < 0 || buffer.substring(lastNewLine + 1).length() != 0) {
                  buffer.append('\n');
                }
              }
              doTabs(format, buffer, structCounter).append("// ").append(commentText);
            } else {
              final String current = buffer.toString();
              if (current.endsWith(";\n") || current.endsWith("}\n")) {
                buffer.setLength(buffer.length() - 1);
              }
              final int lastCommentIndex = buffer.lastIndexOf("//");
              if (lastCommentIndex < 0) {
                buffer.append("// ");
              } else if (buffer.lastIndexOf("\n") > lastCommentIndex) {
                buffer.append("// ");
              } else {
                buffer.append(' ');
              }
              buffer.append(commentText);
            }
          } else {
            throw new IllegalArgumentException("Unexpected item : " + item.getClass().getName());
          }
        }
        break;
        default: {
          doTabs(format, buffer, structCounter).append(item.toString());
        }
        break;
      }
      if (format || item instanceof ItemComment) {
        buffer.append('\n');
      }
    }

    return buffer.toString();
  }
891494
function stringDestination() {
        var cs = [], ps = []; return function() {
            if (arguments.length === 0)
                return ps.join('')+stringFromCharCode.apply(String, cs);
            if (cs.length + arguments.length > 1024)
                ps.push(stringFromCharCode.apply(String, cs)),
                    cs.length = 0;
            Array.prototype.push.apply(cs, arguments);
        };
    }
904930
function strToBoolean(str) {
    switch (str && str.toLowerCase && str.toLowerCase()) {
        case 'true':
            return true;
        case 'false':
            return false;
        case 'null':
            return null;
    }
    return undefined;
}
1285223
function toElement(str) {
    if (!range && doc.createRange) {
        range = doc.createRange();
        range.selectNode(doc.body);
    }

    var fragment;
    if (range && range.createContextualFragment) {
        fragment = range.createContextualFragment(str);
    } else {
        fragment = doc.createElement('body');
        fragment.innerHTML = str;
    }
    return fragment.childNodes[0];
}
1192738
function bundle (str, header) {
    return _.extend(header, {
      valueOf:  function () { return str; },
      toString: function () { return str; }
    });
  }
1347965
public IStringBuffer append( String str )
    {
        if ( str == null )
            throw new NullPointerException();
        //check the necessary to resize the buffer.
        if ( count + str.length() > buff.length ) {
            resizeTo( (count + str.length()) * 2 + 1 );
        }
        
        for ( int j = 0; j < str.length(); j++ ) {
            buff[count++] = str.charAt(j);
        }
        
        return this;
    }
735914
function create (str) {
  createTmpElement.innerHTML = str
  if (!createTmpElement.children.length) {
    return null
  }
  let children = Array.prototype.slice.call(createTmpElement.children)
  createTmpElement.innerHTML = ''
  return children.length > 1 ? children : children[0]
}
154691
function endsWithString(endingValue, valueToTest) {
  const position = valueToTest.length - endingValue.length;
  const lastIndexOfValue = valueToTest.lastIndexOf(endingValue);

  return !!~lastIndexOfValue && lastIndexOfValue === position;
}
804109
function makeStructures(char) {
    let structures = function (id) {
        return new StructureImpl(char, id);
    };
    structures.search = search_1.makeCharacterSearch(char.agent, "structure" /* STRUCTURE */, char.id, char.ssoToken);
    return structures;
}
1361808
def append_string(t, string):
    """"""
    node = t.tree
    if string:
        if len(node) == 0:
            if node.text is not None:
                node.text += string
            else:
                node.text = string
        else:  # Get last child
            child = list(node)[-1]
            if child.tail is not None:
                child.tail += string
            else:
                child.tail = string
1199394
private String _serializeStruct(Struct struct, Map<Object, String> done, String id) throws ConverterException {
	StringBuilder sb = new StringBuilder(goIn() + "<STRUCT ID=\"" + id + "\">");

	Iterator<Key> it = struct.keyIterator();

	deep++;
	while (it.hasNext()) {
	    Key key = it.next();
	    // <ENTRY NAME="STRING" TYPE="STRING">hello</ENTRY>
	    String value = _serialize(struct.get(key, null), done);
	    sb.append(goIn() + "<ENTRY NAME=\"" + key.toString() + "\" TYPE=\"" + type + "\">");
	    sb.append(value);
	    sb.append(goIn() + "</ENTRY>");
	}
	deep--;

	sb.append(goIn() + "</STRUCT>");
	type = "STRUCT";
	return sb.toString();
    }
1260325
public static void ensureEndsWithSlash(StringBuilder str) {
        if (str.length() == 0 || str.charAt(str.length() - 1) != '/') {
            str.append('/');
        }
    }