webdetector/.cache/67/28b293edfa9e453464c9bf90ba7c42.json
2018-12-21 13:36:28 +01:00

1 line
11 KiB
JSON

{"id":"../node_modules/@pushrocks/lik/dist/lik.interestmap.js","dependencies":[{"name":"/Users/philkunz/gitlab/pushrocks_meta/webdetector/node_modules/@pushrocks/lik/ts/lik.interestmap.ts","includedInParent":true,"mtime":499162500000},{"name":"/Users/philkunz/gitlab/pushrocks_meta/webdetector/package.json","includedInParent":true,"mtime":1545395695572},{"name":"/Users/philkunz/gitlab/pushrocks_meta/webdetector/node_modules/@pushrocks/lik/package.json","includedInParent":true,"mtime":1545395355371},{"name":"./lik.plugins","loc":{"line":11,"column":24},"parent":"/Users/philkunz/gitlab/pushrocks_meta/webdetector/node_modules/@pushrocks/lik/dist/lik.interestmap.js","resolved":"/Users/philkunz/gitlab/pushrocks_meta/webdetector/node_modules/@pushrocks/lik/dist/lik.plugins.js"},{"name":"./lik.objectmap","loc":{"line":12,"column":32},"parent":"/Users/philkunz/gitlab/pushrocks_meta/webdetector/node_modules/@pushrocks/lik/dist/lik.interestmap.js","resolved":"/Users/philkunz/gitlab/pushrocks_meta/webdetector/node_modules/@pushrocks/lik/dist/lik.objectmap.js"},{"name":"./lik.interestmap.interest","loc":{"line":13,"column":43},"parent":"/Users/philkunz/gitlab/pushrocks_meta/webdetector/node_modules/@pushrocks/lik/dist/lik.interestmap.js","resolved":"/Users/philkunz/gitlab/pushrocks_meta/webdetector/node_modules/@pushrocks/lik/dist/lik.interestmap.interest.js"}],"generated":{"js":"\"use strict\";\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nconst plugins = require(\"./lik.plugins\");\nconst lik_objectmap_1 = require(\"./lik.objectmap\");\nconst lik_interestmap_interest_1 = require(\"./lik.interestmap.interest\");\nclass InterestMap {\n constructor(comparisonFuncArg) {\n /**\n * stores interests that are currently fullfilled by the cache\n */\n this.interestObjectMap = new lik_objectmap_1.Objectmap();\n // tslint:disable-next-line:member-ordering\n this.interestObservable = new plugins.smartrx.ObservableIntake();\n this.comparisonFunc = comparisonFuncArg;\n }\n /**\n * adds an interest to the InterestMap\n * @param objectArg\n */\n addInterest(objectArg) {\n return __awaiter(this, void 0, void 0, function* () {\n const comparisonString = this.comparisonFunc(objectArg);\n let returnInterest;\n const newInterest = new lik_interestmap_interest_1.Interest(this, objectArg, this.comparisonFunc);\n let interestExists = false;\n yield this.interestObjectMap.forEach(interestArg => {\n if (!interestExists && interestArg.comparisonString === newInterest.comparisonString) {\n console.log('info', `interest already exists for ${newInterest.comparisonString}`);\n interestExists = true;\n returnInterest = interestArg;\n returnInterest.renew();\n }\n });\n if (!returnInterest) {\n returnInterest = newInterest;\n this.interestObjectMap.add(returnInterest);\n }\n this.interestObservable.push(returnInterest);\n return returnInterest;\n });\n }\n /**\n * removes an interest from the interest map\n * @param objectArg removes an interest from the InterestMap\n */\n removeInterest(interestArg) {\n const interestToRemove = this.interestObjectMap.findOneAndRemove(interestArg2 => {\n return interestArg.comparisonString === interestArg2.comparisonString;\n });\n }\n /**\n * check interest\n */\n checkInterest(objectArg) {\n const comparisonString = this.comparisonFunc(objectArg);\n return this.checkInterestByString(comparisonString);\n }\n /**\n * checks an interest\n * @param comparisonStringArg\n */\n checkInterestByString(comparisonStringArg) {\n const foundInterest = this.interestObjectMap.find(interest => {\n return interest.comparisonString === comparisonStringArg;\n });\n if (foundInterest) {\n return true;\n }\n else {\n return false;\n }\n }\n /**\n * inform lost interest\n * @param interestId\n */\n informLostInterest(interestId) {\n const wantedInterest = this.findInterest(interestId);\n if (wantedInterest) {\n wantedInterest.markLost();\n }\n }\n /**\n * finds an interest\n * @param objectArg\n */\n findInterest(objectArg) {\n const comparableString = this.comparisonFunc(objectArg);\n const interest = this.interestObjectMap.find(interest => {\n return interest.comparisonString === comparableString;\n });\n return interest; // if an interest is found, the interest is returned, otherwise interest is null\n }\n}\nexports.InterestMap = InterestMap;\n","map":{"version":3,"file":"lik.interestmap.js","sourceRoot":"","sources":["../ts/lik.interestmap.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,yCAAyC;AACzC,mDAA4C;AAI5C,yEAAsD;AAItD,MAAa,WAAW;IAWtB,YAAY,iBAAwD;QAVpE;;WAEG;QACK,sBAAiB,GAAG,IAAI,yBAAS,EAAkD,CAAC;QA0C5F,2CAA2C;QACpC,uBAAkB,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,gBAAgB,EAA+B,CAAC;QAnC9F,IAAI,CAAC,cAAc,GAAG,iBAAiB,CAAC;IAC1C,CAAC;IAED;;;OAGG;IACU,WAAW,CACtB,SAAuB;;YAEvB,MAAM,gBAAgB,GAAG,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;YACxD,IAAI,cAA8D,CAAC;YACnE,MAAM,WAAW,GAAG,IAAI,mCAAQ,CAC9B,IAAI,EACJ,SAAS,EACT,IAAI,CAAC,cAAc,CACpB,CAAC;YACF,IAAI,cAAc,GAAG,KAAK,CAAC;YAC3B,MAAM,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE;gBACjD,IAAI,CAAC,cAAc,IAAI,WAAW,CAAC,gBAAgB,KAAK,WAAW,CAAC,gBAAgB,EAAE;oBACpF,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,+BAA+B,WAAW,CAAC,gBAAgB,EAAE,CAAC,CAAC;oBACnF,cAAc,GAAG,IAAI,CAAC;oBACtB,cAAc,GAAG,WAAW,CAAC;oBAC7B,cAAc,CAAC,KAAK,EAAE,CAAC;iBACxB;YACH,CAAC,CAAC,CAAC;Y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xD,MAAM,QAAQ,GAAG,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;YACtD,OAAO,QAAQ,CAAC,gBAAgB,KAAK,gBAAgB,CAAC;QACxD,CAAC,CAAC,CAAC;QACH,OAAO,QAAQ,CAAC,CAAC,gFAAgF;IACnG,CAAC;CACF;AAxGD,kCAwGC","sourcesContent":["import * as plugins from './lik.plugins';\nimport { Objectmap } from './lik.objectmap';\n\nimport { Observable } from 'rxjs';\n\nimport { Interest } from './lik.interestmap.interest';\n\nexport type IInterestComparisonFunc<T> = (objectArg: T) => string;\n\nexport class InterestMap<DTInterestId, DTInterestFullfillment> {\n /**\n * stores interests that are currently fullfilled by the cache\n */\n private interestObjectMap = new Objectmap<Interest<DTInterestId, DTInterestFullfillment>>();\n\n /**\n * a function to compare interests\n */\n private comparisonFunc: IInterestComparisonFunc<DTInterestId>;\n\n constructor(comparisonFuncArg: IInterestComparisonFunc<DTInterestId>) {\n this.comparisonFunc = comparisonFuncArg;\n }\n\n /**\n * adds an interest to the InterestMap\n * @param objectArg\n */\n public async addInterest(\n objectArg: DTInterestId\n ): Promise<Interest<DTInterestId, DTInterestFullfillment>> {\n const comparisonString = this.comparisonFunc(objectArg);\n let returnInterest: Interest<DTInterestId, DTInterestFullfillment>;\n const newInterest = new Interest<DTInterestId, DTInterestFullfillment>(\n this,\n objectArg,\n this.comparisonFunc\n );\n let interestExists = false;\n await this.interestObjectMap.forEach(interestArg => {\n if (!interestExists && interestArg.comparisonString === newInterest.comparisonString) {\n console.log('info', `interest already exists for ${newInterest.comparisonString}`);\n interestExists = true;\n returnInterest = interestArg;\n returnInterest.renew();\n }\n });\n if (!returnInterest) {\n returnInterest = newInterest;\n this.interestObjectMap.add(returnInterest);\n }\n this.interestObservable.push(returnInterest);\n return returnInterest;\n }\n\n // tslint:disable-next-line:member-ordering\n public interestObservable = new plugins.smartrx.ObservableIntake<Interest<DTInterestId, any>>();\n\n /**\n * removes an interest from the interest map\n * @param objectArg removes an interest from the InterestMap\n */\n public removeInterest(interestArg: Interest<DTInterestId, DTInterestFullfillment>) {\n const interestToRemove = this.interestObjectMap.findOneAndRemove(interestArg2 => {\n return interestArg.comparisonString === interestArg2.comparisonString;\n });\n }\n\n /**\n * check interest\n */\n public checkInterest(objectArg: DTInterestId): boolean {\n const comparisonString = this.comparisonFunc(objectArg);\n return this.checkInterestByString(comparisonString);\n }\n\n /**\n * checks an interest\n * @param comparisonStringArg\n */\n public checkInterestByString(comparisonStringArg: string): boolean {\n const foundInterest = this.interestObjectMap.find(interest => {\n return interest.comparisonString === comparisonStringArg;\n });\n if (foundInterest) {\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * inform lost interest\n * @param interestId\n */\n public informLostInterest(interestId: DTInterestId) {\n const wantedInterest = this.findInterest(interestId);\n if (wantedInterest) {\n wantedInterest.markLost();\n }\n }\n\n /**\n * finds an interest\n * @param objectArg\n */\n public findInterest(objectArg: DTInterestId): Interest<DTInterestId, DTInterestFullfillment> {\n const comparableString = this.comparisonFunc(objectArg);\n const interest = this.interestObjectMap.find(interest => {\n return interest.comparisonString === comparableString;\n });\n return interest; // if an interest is found, the interest is returned, otherwise interest is null\n }\n}\n"]}},"hash":"33500ecd276bbf72c753c339f1cf9229","cacheData":{"env":{}}}