Skip to content

Commit

Permalink
Added a trim() + integer() helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
matholroyd committed Mar 10, 2012
1 parent 4f2aaa5 commit 2628e20
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions javascript/lib/the_good_parts.js
Expand Up @@ -17,8 +17,18 @@ exports.crockify = function() {
};
});

var is_array = function (value) {
return Object.prototype.toString.apply(value) === '[object Array]';
};
// Need to check this
// Object.method('is_array', function () {
// return Object.prototype.toString.apply(this) === '[object Array]';
// };

Number.method('integer', function () {
return Math[this < 0 ? 'ceil' : 'floor'](this);
});

String.method('trim', function () {
return this.replace(/^\s+|\s+$/g, '');
});

};

0 comments on commit 2628e20

Please sign in to comment.