Skip to content

Commit 91e5c32

Browse files
authored
Merge pull request #3945 from curbengh/deployer-class
refactor(deployer): Class syntax
2 parents 4c86aac + ab46af5 commit 91e5c32

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

lib/extend/deployer.js

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,31 @@
22

33
const Promise = require('bluebird');
44

5-
function Deployer() {
6-
this.store = {};
7-
}
5+
class Deployer {
6+
constructor() {
7+
this.store = {};
8+
}
89

9-
Deployer.prototype.list = function() {
10-
return this.store;
11-
};
10+
list() {
11+
return this.store;
12+
}
1213

13-
Deployer.prototype.get = function(name) {
14-
return this.store[name];
15-
};
14+
get(name) {
15+
return this.store[name];
16+
}
1617

17-
Deployer.prototype.register = function(name, fn) {
18-
if (!name) throw new TypeError('name is required');
19-
if (typeof fn !== 'function') throw new TypeError('fn must be a function');
18+
register(name, fn) {
19+
if (!name) throw new TypeError('name is required');
20+
if (typeof fn !== 'function') throw new TypeError('fn must be a function');
2021

21-
if (fn.length > 1) {
22-
fn = Promise.promisify(fn);
23-
} else {
24-
fn = Promise.method(fn);
25-
}
22+
if (fn.length > 1) {
23+
fn = Promise.promisify(fn);
24+
} else {
25+
fn = Promise.method(fn);
26+
}
2627

27-
this.store[name] = fn;
28-
};
28+
this.store[name] = fn;
29+
}
30+
}
2931

3032
module.exports = Deployer;

0 commit comments

Comments
 (0)