/* Checks whether the stored string ends with given string.

If given argument is not a string or a String instance, an
InvalidArgumentException is thrown.

Returns boolean.

TODO: Examples
554176
public function ends_with ($needle)
	{
		ensure('Argument', $needle, 'is_a_string', __CLASS__, __METHOD__);

		if ($needle instanceof self) {
			$needle = $needle->to_s();
		}

		$len = strlen($needle);

		return 0 === strcmp($this->slice(-$len, $len)->to_s(), $needle);
	}
1267090
public static boolean endsWithIgnoreCase(final String base, final String end) {
	if (base.length() < end.length()) {
	    return false;
	}
	return base.regionMatches(true, base.length() - end.length(), end, 0, end.length());
    }
933803
static int findEndOfString(String sb) {
        int result;
        for (result = sb.length(); result > 0; result --) {
            if (!Character.isWhitespace(sb.charAt(result - 1))) {
                break;
            }
        }
        return result;
    }
972871
protected function textEndsWith($string, $ends_with)
    {
        $ends_with = trim($ends_with);
        if ($ends_with === '') {
            return false;
        }

        return substr_compare($string, $ends_with, -strlen($ends_with), strlen($ends_with)) === 0;
    }
1250646
public boolean endsWith(String word)
    {
        word = reverse(word);
        return trie.commonPrefixSearchWithValue(word).size() > 0;
    }
1323102
public static boolean endsWithIgnoreCase(@Nullable final String str,
      @Nullable final String suffix) {
    return str != null && suffix != null && str.length() >= suffix.length()
        && str.regionMatches(true, str.length() - suffix.length(), suffix, 0, suffix.length());
  }
503682
function endsWith(str,test){
  var lastIndex = str.lastIndexOf(test);
  return (lastIndex != -1) && (lastIndex + test.length == str.length);
}
1337618
public static int findLastNotOf(String container, String charSeq, int end){
        for (int i = end; i < container.length() && i >= 0; --i){
            if (!charSeq.contains("" + container.charAt(i)))
                return i;        
        }
        return -1;
    }
1260325
public static void ensureEndsWithSlash(StringBuilder str) {
        if (str.length() == 0 || str.charAt(str.length() - 1) != '/') {
            str.append('/');
        }
    }
949535
function endsWithAny(string, vector) {
  return _.any(vector.map(function (e) { return _str.endsWith(string, e); }));
}
518788
@Override
    public boolean endsWith(final Path other) {
        // Precondition checks
        if (other == null) {
            throw new IllegalArgumentException("other path must be specified");
        }
        // Unequal FS? (also ensures that we can safely cast to this type later)
        if (this.getFileSystem() != other.getFileSystem()) {
            return false;
        }
        final List<String> ourTokens = tokenize(this);
        final List<String> otherTokens = tokenize((ShrinkWrapPath) other);

        // Bigger than us, fails
        final int numOtherTokens = otherTokens.size();
        if (numOtherTokens > ourTokens.size()) {
            return false;
        }

        // Difference in component size
        final int differential = ourTokens.size() - numOtherTokens;
        // Given an absolute?
        if (other.isAbsolute()) {
            // We must have the same number of elements
            if (differential != 0) {
                return false;
            }
        }
        // Compare all components
        for (int i = numOtherTokens - 1; i >= 0; i--) {
            if (!ourTokens.get(i + differential).equals(otherTokens.get(i))) {
                // Any tokens don't match, punt
                return false;
            }
        }

        // All conditions met
        return true;
    }
515954
function fn(end, cb) {
        if (end || fn.ended) return cb(true)
        fn.ended = true
        if (ref.isMsg(dest) && sbot.get) {
          sbot.get(dest, function (err, value) {
            if (err) cb(true)
            else cb(null, {key: dest, value: value})
          })
        } else {
          cb(true)
        }
      }
1005884
private boolean verifyLastArgumentIsString(Node methodName, Node arg) {
    return verifyNotNull(methodName, arg)
        && verifyOfType(methodName, arg, Token.STRING)
        && verifyIsLast(methodName, arg);
  }
567478
public BooleanExpression endsWith(Expression<String> str) {
        return Expressions.booleanOperation(Ops.ENDS_WITH, mixin, str);
    }
414893
public static function ends_with( $str, $full_string, $case_sensitive = false ){
		$offset = strlen( $full_string ) - strlen( $str );
		if( strlen( $str ) == 0 || strlen( $full_string ) == 0 || $offset >= strlen( $full_string ) ){
			return false;
		}
		return substr_compare( $full_string, $str, $offset, strlen( $str ), ! $case_sensitive ) === 0;
	}
105303
public function endsWith(self $str, MStringComparison $cmp = null){
		
		if($str->isNullOrEmpty()){
			throw new \InvalidArgumentException('$str is empty');
		}
		
		if($str->count() > $this->count()){
			throw new \InvalidArgumentException('$str is longer than $this');
		}
		
		if($cmp === null || $cmp->Value === MStringComparison::CASE_SENSITIVE){
			return $this
					->substring($this->count() - $str->count(), $str->count())
					->_Value === $str->_Value;
		}
		else{
			return $this
					->substring($this->count() - $str->count(), $str->count())
					->toLower()->_Value === $str->toLower()->_Value;
		}
		
	}
344551
public static boolean endsWith(final String value, final String search, final boolean caseSensitive) {
        validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER);
        return endsWith(value, search, value.length(), caseSensitive);
    }