Skip to content

Commit

Permalink
Replace the reserved word char
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Ng committed Aug 8, 2013
1 parent 3a5288d commit d9a391d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion lib/file.js
Expand Up @@ -376,7 +376,7 @@ var fileUtils = new (function () {
@name file#isAbsolute @name file#isAbsolute
@public @public
@function @function
@return {Boolean/String} If it's absolute the first char is returned otherwise false @return {Boolean/String} If it's absolute the first character is returned otherwise false
@description Checks if a given path is absolute or relative @description Checks if a given path is absolute or relative
@param {String} p Path to check @param {String} p Path to check
*/ */
Expand Down
42 changes: 21 additions & 21 deletions lib/string.js
Expand Up @@ -165,11 +165,11 @@ string = new (function () {
@description Ltrim trims `char` from the left of a `string` and returns it @description Ltrim trims `char` from the left of a `string` and returns it
if no `char` is given it will trim spaces if no `char` is given it will trim spaces
@param {String} string The string to trim @param {String} string The string to trim
@param {String} char The character to trim @param {String} character The character to trim
*/ */
this.ltrim = function (string, char) { this.ltrim = function (string, character) {
var str = string || '' var str = string || ''
, pat = char ? new RegExp('^' + char + '+') : _LTR; , pat = character ? new RegExp('^' + character + '+') : _LTR;
str = String(str); str = String(str);


return str.replace(pat, ''); return str.replace(pat, '');
Expand All @@ -183,11 +183,11 @@ string = new (function () {
@description Rtrim trims `char` from the right of a `string` and returns it @description Rtrim trims `char` from the right of a `string` and returns it
if no `char` is given it will trim spaces if no `char` is given it will trim spaces
@param {String} string The string to trim @param {String} string The string to trim
@param {String} char The character to trim @param {String} character The character to trim
*/ */
this.rtrim = function (string, char) { this.rtrim = function (string, character) {
var str = string || '' var str = string || ''
, pat = char ? new RegExp(char + '+$') : _RTR; , pat = character ? new RegExp(character + '+$') : _RTR;
str = String(str); str = String(str);


return str.replace(pat, ''); return str.replace(pat, '');
Expand All @@ -204,11 +204,11 @@ string = new (function () {
@description Trim trims `char` from the left and right of a `string` and returns it @description Trim trims `char` from the left and right of a `string` and returns it
if no `char` is given it will trim spaces if no `char` is given it will trim spaces
@param {String} string The string to trim @param {String} string The string to trim
@param {String} char The character to trim @param {String} character The character to trim
*/ */
this.trim = function (string, char) { this.trim = function (string, character) {
var str = string || '' var str = string || ''
, pat = char ? new RegExp('^' + char + '+|' + char + '+$', 'g') : _TR; , pat = character ? new RegExp('^' + character + '+|' + character + '+$', 'g') : _TR;
str = String(str); str = String(str);


return str.replace(pat, ''); return str.replace(pat, '');
Expand Down Expand Up @@ -249,20 +249,20 @@ string = new (function () {
@description Lpad adds `char` to the left of `string` until the length @description Lpad adds `char` to the left of `string` until the length
of `string` is more than `width` of `string` is more than `width`
@param {String} string The string to pad @param {String} string The string to pad
@param {String} char The character to pad with @param {String} character The character to pad with
@param {Number} width the width to pad to @param {Number} width the width to pad to
*/ */
this.lpad = function (string, char, width) { this.lpad = function (string, character, width) {
var str = string || '' var str = string || ''
, width; , width;
str = String(str); str = String(str);


// Should width be string.length + 1? or the same to be safe // Should width be string.length + 1? or the same to be safe
width = parseInt(width, 10) || str.length; width = parseInt(width, 10) || str.length;
char = char || ' '; character = character || ' ';


while (str.length < width) { while (str.length < width) {
str = char + str; str = character + str;
} }
return str; return str;
}; };
Expand All @@ -275,20 +275,20 @@ string = new (function () {
@description Rpad adds `char` to the right of `string` until the length @description Rpad adds `char` to the right of `string` until the length
of `string` is more than `width` of `string` is more than `width`
@param {String} string The string to pad @param {String} string The string to pad
@param {String} char The character to pad with @param {String} character The character to pad with
@param {Number} width the width to pad to @param {Number} width the width to pad to
*/ */
this.rpad = function (string, char, width) { this.rpad = function (string, character, width) {
var str = string || '' var str = string || ''
, width; , width;
str = String(str); str = String(str);


// Should width be string.length + 1? or the same to be safe // Should width be string.length + 1? or the same to be safe
width = parseInt(width, 10) || str.length; width = parseInt(width, 10) || str.length;
char = char || ' '; character = character || ' ';


while (str.length < width) { while (str.length < width) {
str += char; str += character;
} }
return str; return str;
}; };
Expand All @@ -301,20 +301,20 @@ string = new (function () {
@description Pad adds `char` to the left and right of `string` until the length @description Pad adds `char` to the left and right of `string` until the length
of `string` is more than `width` of `string` is more than `width`
@param {String} string The string to pad @param {String} string The string to pad
@param {String} char The character to pad with @param {String} character The character to pad with
@param {Number} width the width to pad to @param {Number} width the width to pad to
*/ */
this.pad = function (string, char, width) { this.pad = function (string, character, width) {
var str = string || '' var str = string || ''
, width; , width;
str = String(str); str = String(str);


// Should width be string.length + 1? or the same to be safe // Should width be string.length + 1? or the same to be safe
width = parseInt(width, 10) || str.length; width = parseInt(width, 10) || str.length;
char = char || ' '; character = character || ' ';


while (str.length < width) { while (str.length < width) {
str = char + str + char; str = character + str + character;
} }
return str; return str;
}; };
Expand Down

0 comments on commit d9a391d

Please sign in to comment.