UNPKG

@cachemap/controller

Version:

The Cachemap controller module.

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