UNPKG

@cachemap/controller

Version:

The Cachemap controller module.

3 lines (2 loc) 1.32 kB
"use strict";var e=require("@cachemap/utils"),t=require("eventemitter3");const n=({name:e,type:t})=>"string"==typeof e&&e.length>0||"string"==typeof t&&t.length>0;class r extends t.EventEmitter{clearCaches({name:t,type:r}={}){if(!n({name:t,type:r}))throw new e.ArgsError("@cachemap/controller expected event data to include 'name' or 'type' props.");this.emit(e.constants.CLEAR,{name:t,type:r})}startBackups({name:t,type:r}={}){if(!n({name:t,type:r}))throw new e.ArgsError("@cachemap/controller expected event data to include 'name' or 'type' props.");this.emit(e.constants.START_BACKUP,{name:t,type:r})}startReapers({name:t,type:r}={}){if(!n({name:t,type:r}))throw new e.ArgsError("@cachemap/controller expected event data to include 'name' or 'type' props.");this.emit(e.constants.START_REAPER,{name:t,type:r})}stopBackups({name:t,type:r}={}){if(!n({name:t,type:r}))throw new e.ArgsError("@cachemap/controller expected event data to include 'name' or 'type' props.");this.emit(e.constants.STOP_BACKUP,{name:t,type:r})}stopReapers({name:t,type:r}={}){if(!n({name:t,type:r}))throw new e.ArgsError("@cachemap/controller expected event data to include 'name' or 'type' props.");this.emit(e.constants.STOP_REAPER,{name:t,type:r})}}const a=new r;exports.Controller=r,exports.instance=a; //# sourceMappingURL=index.cjs.map