laravel-mix-glob
Version:
Laravel mix extension that add support for globs usage with an extensive concise api. For a more natural boosted productivity and dynamic. Configure once and forget about adding the files each time.
3 lines (2 loc) • 1.62 kB
JavaScript
"use strict";var s=require("flat-cache"),e=require("../../Utils/Logger/index.js"),i=require("../../Utils/helpers/index.js");exports.MetaCache=class{flatCache;id="laravel-mix-glob:meta";_values;constructor(s){s?.id&&(this.id=s?.id),this.syncWithCache()}get values(){return this._values}syncWithCache(){return this.flatCache=s.load(this.id),this._values=this.flatCache.all(),this._values.sessions||(this._values.sessions=[]),e.LOGGER.debug("MetaCache: sync (file read):"),e.LOGGER.debug(this.values),this}set(s,e){return this._values[s]!==e&&(this._values[s]=e,this.flatCache.setKey(s,e)),this}save(){return e.LOGGER.debug("MetaCache: save()"),this.flatCache.save(),this}getSessionIndex(s){return this._values.sessions.findIndex((e=>e.id===s))}addSessions(s){e.LOGGER.debug(`MetaCache: add sessions ${i.stringify(s)}`);const t=i.stringify(this._values.sessions);return s.forEach((s=>{const e=this.getSessionIndex(s.id);e>-1?this._values.sessions.splice(e,1,s):this._values.sessions.push(s)})),e.LOGGER.debug(`${t}\n=>\n${i.stringify(this._values.sessions)}`),this.flatCache.setKey("sessions",this._values.sessions),this}removeSessionsByIndexes(s){return s.sort(i.descSortFn).forEach((s=>{this._values.sessions.splice(s,1)})),this.flatCache.setKey("sessions",this._values.sessions),this}removeSessionsByIds(s){e.LOGGER.debug(`MetaCache: add sessions ${JSON.stringify(s)}`);const t=i.stringify(this._values.sessions);return s.forEach((s=>{const e=this.getSessionIndex(s);e>-1&&this._values.sessions.splice(e,1)})),e.LOGGER.debug(`${t}\n=>\n${i.stringify(this._values.sessions)}`),this}};
//# sourceMappingURL=MetaCache.js.map