import {Storage as ConfigStorage, Modes} from './config'; class AppStorage { public setPrefix(newPrefix: string) { ConfigStorage.prefix(newPrefix); } public noPrefix() { ConfigStorage.noPrefix(); } private proxy(methodName: string, ..._args: any[]) { let args = Array.prototype.slice.call(_args); let promise = new Promise((resolve, reject) => { args.push((result: T) => { resolve(result); }); ConfigStorage[methodName].apply(ConfigStorage, args); }); return promise; } public get(...args: any[]) { return this.proxy('get', ...args); } public set(...args: any[]) { //console.trace(...args); return this.proxy('set', ...args); } public remove(...args: any[]) { return this.proxy('remove', ...args); } public clear(...args: any[]) { return this.proxy('clear', ...args); } constructor() { if(Modes.test) { this.setPrefix('t_'); } } } export default new AppStorage();