/**
 * simple hook
 * webpack-plugin-liked api
 */
class Hook {
    name = '';
    ops = [];
    constructor(name) {
        this.name = name;
    }
    tap(cb) {
        if (this.ops.indexOf(cb) === -1) {
            this.ops.push(cb);
        }
        return () => {
            this.remove(cb);
        };
    }
    remove(cb) {
        const idx = this.ops.indexOf(cb);
        if (idx < 0) {
            return;
        }
        this.ops.splice(idx, 1);
    }
    isEmpty() {
        return this.ops.length === 0;
    }
    call(...args) {
        let ret;
        this.ops.forEach(op => {
            ret = op(...args);
        });
        return ret;
    }
}
export default Hook;
//# sourceMappingURL=hook.js.map