You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

32 lines
532 B

'use strict';
const Promise = require('bluebird');
class Migrator {
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 = Migrator;