Sha256: d7d5889cc073734875c67583695d1542bea0dfeb0529f7c7b5e02c45bddcfe7b
Contents?: true
Size: 781 Bytes
Versions: 69
Compression:
Stored size: 781 Bytes
Contents
var toString = require('../lang/toString'); var WHITE_SPACES = require('./WHITE_SPACES'); /** * Remove chars from end of string. */ function rtrim(str, chars) { str = toString(str); chars = chars || WHITE_SPACES; var end = str.length - 1, charLen = chars.length, found = true, i, c; while (found && end >= 0) { found = false; i = -1; c = str.charAt(end); while (++i < charLen) { if (c === chars[i]) { found = true; end--; break; } } } return (end >= 0) ? str.substring(0, end + 1) : ''; } module.exports = rtrim;
Version data entries
69 entries across 69 versions & 2 rubygems