Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Refactoring the parse method.

  • Loading branch information...
commit 8bb8b27dd19ac2e8c60e1e4dbebef010ccb2bdea 1 parent 96f093f
@vesln authored
Showing with 3 additions and 23 deletions.
  1. +3 −7 lib/watcher.js
  2. +0 −16 test/watcher.test.js
View
10 lib/watcher.js
@@ -36,24 +36,20 @@ Watcher.prototype.__proto__ = events.EventEmitter.prototype;
/**
* Parses pids.
*
- * @param {String|Number|Array} pid or process name.
+ * @param {String|Number} pid or process name.
* @param {Function} callback.
*/
Watcher.prototype.parse = function(pids, cb) {
var self = this;
switch(true) {
- case Array.isArray(pids):
- cb.call(this, this.pids(pids));
- break;
-
case toString.call(pids) === '[object Number]':
- cb.call(this, this.pids([pids]));
+ cb.call(this, pids);
break;
default:
this.pidof(pids, function(pid) {
- cb.call(self, self.pids(pid));
+ cb.call(self, pid);
});
}
};
View
16 test/watcher.test.js
@@ -21,22 +21,6 @@ describe('Watcher', function() {
});
describe('parse', function() {
- it('should convert number to array', function(done) {
- var watcher = new Watcher;
- watcher.parse(3333, function(pids) {
- pids.should.eql([3333]);
- done();
- })
- });
-
- it('should convert keep the array', function(done) {
- var watcher = new Watcher;
- watcher.parse([3333], function(pids) {
- pids.should.eql([3333]);
- done();
- })
- });
-
it('should convert string to number', function(done) {
var watcher = new Watcher;
watcher.parse('node', function(pids) {
Please sign in to comment.
Something went wrong with that request. Please try again.