// export interface Cachable { // get(path:string, ...args): Promise; // put(path:string, data, ...args): Promise; // post(path:string, data, ...args): Promise; // patch(path:string, data, ...args): Promise; // del(path:string, ...args): Promise; // } // // export function splitPath(path) { // let pathParts = path.split('/').filter(x=>x); // let lastPart = pathParts[pathParts.length-1]; // let [lastPartResource, queryString] = lastPart.split('?'); // pathParts[pathParts.length-1] = lastPartResource; // return { pathParts, queryString }; // } // // export class Cached implements Cachable{ // cache: any = {}; // constructor(public base: Cachable, public cacheConfig: any, public isId: (x: string)=>boolean) { // // } // // resourceConfig(pathParts: string[]) { // return pathParts.reduce((config, pathPart) => { // if (!config) return config; // if (config.$cachDescendents) return config; // let resourceConfig = this.isId(pathPart) ? config.$id : config[pathPart]; // return resourceConfig; // }, this.cacheConfig); // } // // getCacheEntry(pathParts: string[]) { // return pathParts.reduce((cache, pathPart) => { // if (!cache) return cache; // let resource = cache[pathPart]; // return resource; // }, this.cache); // } // // getCacheValue(pathParts: string[]) { // return this.getCacheEntry(pathParts).$value; // } // // canCache(path: string) { // let {pathParts, queryString} = splitPath(path); // let resourceConfig = this.resourceConfig(pathParts); // if (resourceConfig && resourceConfig.$cache) { // return true; // } // } // // del(path: string, ...args): Promise { // return this.base.del(path, ...args); // } // // get(path: string, ...args): Promise { // if (this.canCache(path)) { // // } else { // return this.base.get(path, ...args); // } // } // // patch(path: string, data, ...args): Promise { // if (this.canCache(path)) { // return this.base.patch(path, ...args); // // } else { // return this.base.patch(path, ...args); // } // } // // post(path: string, data, ...args): Promise { // if (this.canCache(path)) { // return this.base.post(path, ...args); // // } else { // return this.base.post(path, ...args); // } // } // // put(path: string, data, ...args): Promise { // if (this.canCache(path)) { // return this.base.put(path, ...args); // } else { // return this.base.put(path, ...args); // } // } // // }