Code coverage report for string/endsWith.js

Statements: 100% (7 / 7)      Branches: 100% (4 / 4)      Functions: 100% (3 / 3)      Lines: 100% (6 / 6)     

All files » string/ » endsWith.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 181                   1 6 6 6   1    
define(function () {
    /**
    * Checks if string ends with specified suffix.
    * @example endsWith('lorem ipsum', 'ipsum') -> true
    * @example endsWith('lorem ipsum', 'lorem') -> false
    * @param {string} str
    * @param {string} suffix
    * @return {bool}
    * @version 0.1.0 (2012/03/01)
    */
    function endsWith(str, suffix) {
        str = (str || '');
        suffix = (suffix || '');
        return str.indexOf(suffix, str.length - suffix.length) !== -1;
    }
    return endsWith;
});