Skip to content

Commit

Permalink
Merge branch 'master' of github.com:mde/utilities
Browse files Browse the repository at this point in the history
  • Loading branch information
mde committed Oct 21, 2013
2 parents 0bd4127 + d9a391d commit 935fba8
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
@public
@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
@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
if no `char` is given it will trim spaces
@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 || ''
, pat = char ? new RegExp('^' + char + '+') : _LTR;
, pat = character ? new RegExp('^' + character + '+') : _LTR;
str = String(str);

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
if no `char` is given it will trim spaces
@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 || ''
, pat = char ? new RegExp(char + '+$') : _RTR;
, pat = character ? new RegExp(character + '+$') : _RTR;
str = String(str);

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
if no `char` is given it will trim spaces
@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 || ''
, pat = char ? new RegExp('^' + char + '+|' + char + '+$', 'g') : _TR;
, pat = character ? new RegExp('^' + character + '+|' + character + '+$', 'g') : _TR;
str = String(str);

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
of `string` is more than `width`
@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
*/
this.lpad = function (string, char, width) {
this.lpad = function (string, character, width) {
var str = string || ''
, width;
str = String(str);

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

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

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

while (str.length < width) {
str += char;
str += character;
}
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
of `string` is more than `width`
@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
*/
this.pad = function (string, char, width) {
this.pad = function (string, character, width) {
var str = string || ''
, width;
str = String(str);

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

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

0 comments on commit 935fba8

Please sign in to comment.