/
githubmirror
/
hexo
Обзор
Документация
Войти
/
githubmirror
/
hexo
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
4.2.1
lib/extend/deployer.js
32 строки
532 B
curbengh
refactor(deployer): Class syntax
13 дек 2019, 12:14
Не верифицирован
13 дек 2019, 12:14
ab46af5
Код
Авторство
О чём код?
'use strict'; const Promise = require('bluebird'); class Deployer { constructor() { this.store = {}; } list() { return this.store; } get(name) { return this.store[name]; } register(name, fn) { if (!name) throw new TypeError('name is required'); if (typeof fn !== 'function') throw new TypeError('fn must be a function'); if (fn.length > 1) { fn = Promise.promisify(fn); } else { fn = Promise.method(fn); } this.store[name] = fn; } } module.exports = Deployer;