From 8099cf427bb1f2b9afffe44d6cbcbeb84b9bdf11 Mon Sep 17 00:00:00 2001 From: Michael Barrett Date: Fri, 15 Jan 2016 15:51:48 +0000 Subject: [PATCH] dont modify string prototype --- index.js | 11 ----------- test.js | 14 -------------- 2 files changed, 25 deletions(-) diff --git a/index.js b/index.js index 4ffc318..6001290 100644 --- a/index.js +++ b/index.js @@ -98,14 +98,3 @@ Timestring.prototype.parse = function parse(string, returnUnit) { convert.call(this, totalSeconds, returnUnit) : totalSeconds; }; - -/** - * Parse a timestring - * - * @param {string} unit - * @param {Object} opts - * @return {string} - */ -String.prototype.parseTime = function parseTime(unit, opts) { - return (new Timestring(opts)).parse(this, unit); -}; diff --git a/test.js b/test.js index 2e3f2fd..4ffb60e 100644 --- a/test.js +++ b/test.js @@ -46,18 +46,4 @@ describe('timestring', function() { it('can parse a messy time string', function() { expect((new timestring()).parse('5 D a YS 4 h 2 0 mI nS')).to.equal(447600); }); - - it('should expose a method on String.prototype that will parse the string as a timestring', function(){ - var str = '1min'; - - // no arguments passed - expect(str.parseTime()).to.equal(60); - - // units argument passed - expect(str.parseTime('m')).to.equal(1); - - // units + options argument passed - str = '5h'; - expect(str.parseTime('d', { hoursPerDay: 5 })).to.equal(1); - }); });