Files
blog/node_modules/hexo/dist/extend/generator.js
2025-07-16 16:30:56 +00:00

33 lines
901 B
JavaScript

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
const bluebird_1 = __importDefault(require("bluebird"));
class Generator {
constructor() {
this.id = 0;
this.store = {};
}
list() {
return this.store;
}
get(name) {
return this.store[name];
}
register(name, fn) {
if (!fn) {
if (typeof name === 'function') { // fn
fn = name;
name = `generator-${this.id++}`;
}
else {
throw new TypeError('fn must be a function');
}
}
if (fn.length > 1)
fn = bluebird_1.default.promisify(fn);
this.store[name] = bluebird_1.default.method(fn);
}
}
module.exports = Generator;
//# sourceMappingURL=generator.js.map