Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vsm-dictionary-cacher

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vsm-dictionary-cacher - npm Package Compare versions

Comparing version 1.2.0 to 1.2.1

2

dist/vsm-dictionary-cacher.min.js

@@ -1,1 +0,1 @@

var VsmDictionaryCacher=function(e){var t={};function i(c){if(t[c])return t[c].exports;var s=t[c]={i:c,l:!1,exports:{}};return e[c].call(s.exports,s,s.exports,i),s.l=!0,s.exports}return i.m=e,i.c=t,i.d=function(e,t,c){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:c})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var c=Object.create(null);if(i.r(c),Object.defineProperty(c,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var s in e)i.d(c,s,function(t){return e[t]}.bind(null,s));return c},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s=0)}([function(e,t,i){const c=i(1),s=c.callAsync,a=c.getNowTime,h=c.deleteOldestCacheItem;e.exports=function(e,t){return t=t||{},class extends e{constructor(e){super(e),this.cacheMaxItems=t.maxItems||0,this.cacheMOPredictEmpties=void 0===t.predictEmpties||!!t.predictEmpties,this.cacheMO={},this.cacheMOQueue={},this.cacheMOEmpties={},this.cacheRT=!1,this.cacheRTQueue=[],this.cacheDI={},this.cacheDIQueried={},this.cacheDIQueue=[],this.cacheDIGotAll=0,this.cacheFTQueried={},this.cacheFTQueue=[]}clearCache(){this.cacheMO={},this.cacheMOEmpties={},this.cacheRT=!1,this.cacheDI={},this.cacheDIQueried={},this.cacheDIGotAll=0,this.cacheFTQueried={}}getEntryMatchesForString(e,t,i){var c=this._createCacheMOEmptiesKey(t);if(this._getCacheMOEmptiesPrediction(c,e))return s(i,null,{items:[]});super.getEntryMatchesForString(e,t,(t,a)=>(this._updateCacheMOEmpties(c,e,t,a),s(i,t,a)))}getMatchesForString(e,t,i){var c=this._createCacheMOKey(e,t),a=this._getCacheMOItem(c);if(a)return s(i,null,a);var h=this.cacheMOQueue[c]=this.cacheMOQueue[c]||[];h.push(i),h.length>1||super.getMatchesForString(e,t,(e,t)=>{e||this._setCacheMOItem(c,t),h.forEach(i=>s(i,e,t)),delete this.cacheMOQueue[c]})}_createCacheMOKey(e,t){return e+JSON.stringify(t||{})}_getCacheMOItem(e){var t=this.cacheMO[e];return t?(t.lastAccessed=a(),t.value):null}_setCacheMOItem(e,t){this.cacheMO[e]={value:t,lastAccessed:a()},this.cacheMaxItems&&Object.keys(this.cacheMO).length>this.cacheMaxItems&&h(this.cacheMO)}_createCacheMOEmptiesKey(e){return JSON.stringify(e||{})}_updateCacheMOEmpties(e,t,i,c){if(this.cacheMOPredictEmpties&&!i&&c&&c.items&&!c.items.length&&""!==t){var s=this.cacheMOEmpties[e]=this.cacheMOEmpties[e]||[];-1==s.indexOf(t)&&s.push(t)}}_getCacheMOEmptiesPrediction(e,t){if(!this.cacheMOPredictEmpties)return!1;var i=this.cacheMOEmpties[e];return i&&i.findIndex(e=>t.startsWith(e))>=0}getRefTerms(e,t){if("boolean"!=typeof this.cacheRT)return this._getRefTermsFromSortedArray(this.cacheRT,e,t);this.cacheRTQueue.push({options:e,cb:t}),!0!==this.cacheRT&&(this.cacheRT=!0,super.getRefTerms({perPage:Number.MAX_VALUE},(e,t)=>{this.cacheRT=!e&&t.items,this.cacheRTQueue.forEach(t=>{if(e)return s(t.cb,e);this._getRefTermsFromSortedArray(this.cacheRT,t.options,t.cb)}),this.cacheRTQueue=[]}))}getDictInfos(e,t){return e.filter?e.filter.id?void this._handleGetDictInfosByIDs(e,t):super.getDictInfos(e,(e,i)=>{e||i.items.forEach(e=>this.cacheDI[e.id]=e),t(e,i)}):this._handleGetDictInfosAll(e,t)}_handleGetDictInfosByIDs(e,t){var i={items:[...new Set(e.filter.id)].map(e=>({id:e,_q:!1})),options:e,cb:t};if(0!=this._updateDIQObjAndCallbackMaybe(i)&&(this.cacheDIQueue.push(i),.5!=this.cacheDIGotAll)){var c=i.items.filter(e=>!1===e._q).map(e=>e.id);if(c.length)return c.forEach(e=>this.cacheDIQueried[e]=!0),super.getDictInfos({filter:{id:c},perPage:Number.MAX_VALUE},(e,t)=>this._handleDIQueryResult(e,t,c))}}_handleGetDictInfosAll(e,t){var i={items:!0,options:e,cb:t};if(0!=this._updateDIQObjAndCallbackMaybe(i)&&(this.cacheDIQueue.push(i),.5!=this.cacheDIGotAll))return this.cacheDIGotAll=.5,super.getDictInfos({perPage:Number.MAX_VALUE},(e,t)=>this._handleDIQueryResult(e,t,!0))}_handleDIQueryResult(e,t,i){var c;!0===i?(this.cacheDIGotAll=e?0:1,e||(this.cacheDIQueried={},this.cacheDI={},t.items.forEach(e=>this.cacheDI[e.id]=e))):(i.forEach(e=>delete this.cacheDIQueried[e]),e||(t.items.forEach(e=>this.cacheDI[e.id]=e),i.forEach(e=>this.cacheDI[e]=this.cacheDI[e]||"-"))),this.cacheDIQueue=this.cacheDIQueue.map(t=>(c=c||!0===t.items,e?!0===i&&!c||!0!==i&&(c||!t.items.some(e=>i.includes(e.id)))?t:s(t.cb,e)&&0:this._updateDIQObjAndCallbackMaybe(t))).filter(e=>e)}_updateDIQueueObject(e){return e.items=e.items.map(e=>void 0===e._q&&e||this.cacheDI[e.id]||{id:e.id,_q:!!this.cacheDIQueried[e.id]}).filter(e=>"-"!=e)}_updateDIQObjAndCallbackMaybe(e){var t=e.items;if(!0===t){if(1!=this.cacheDIGotAll)return e;t=Object.values(this.cacheDI).filter(e=>"-"!=e)}else if(t=this._updateDIQueueObject(e),1==this.cacheDIGotAll)t=t.filter(e=>void 0===e._q);else if(t.some(e=>void 0!==e._q))return e;var i=e.options.sort||"id",c=e.options.page||1,a=e.options.perPage||Number.MAX_VALUE,h=(c-1)*a;return t=t.sort((e,t)=>(e=e[i].toLowerCase())<(t=t[i].toLowerCase())?-1:e>t?1:0).slice(h,h+a),s(e.cb,null,{items:t}),0}loadFixedTerms(e,t,i){var c=e.map(e=>({key:this._idtToFTCacheKey(e.id,e.str),idt:e})).filter(e=>!this.fixedTermsCache[e.key]&&0!==this.cacheFTQueried[e.key]);if(!c.length)return s(i,null);var a=c.filter(e=>!this.cacheFTQueried[e.key]);this.cacheFTQueue.push({awaitedKeys:c.map(e=>e.key),cb:i}),a.length&&(a.forEach(e=>this.cacheFTQueried[e.key]=!0),super.loadFixedTerms(a.map(e=>e.idt),t,e=>this._handleFTQueryResult(e,a.map(e=>e.key))))}_handleFTQueryResult(e,t){t.forEach(t=>{e||this.fixedTermsCache[t]?delete this.cacheFTQueried[t]:this.cacheFTQueried[t]=0}),this.cacheFTQueue=this.cacheFTQueue.map(i=>{var c=i.awaitedKeys.length;return i.awaitedKeys=i.awaitedKeys.filter(e=>!t.includes(e)),e&&i.awaitedKeys.length==c||!e&&i.awaitedKeys.length?i:s(i.cb,e)&&0}).filter(e=>e)}}}},function(e,t){e.exports={callAsync:function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),c=1;c<t;c++)i[c-1]=arguments[c];setTimeout(()=>e(...i),0)},getNowTime:function(){return(new Date).getTime()},deleteOldestCacheItem:function(e){for(var t=Object.keys(e),i=Number.POSITIVE_INFINITY,c=-1,s=0;s<t.length;s++){var a=e[t[s]].lastAccessed;a<i&&(i=a,c=s)}delete e[t[c]]}}}]);
var VsmDictionaryCacher=function(e){var t={};function i(c){if(t[c])return t[c].exports;var s=t[c]={i:c,l:!1,exports:{}};return e[c].call(s.exports,s,s.exports,i),s.l=!0,s.exports}return i.m=e,i.c=t,i.d=function(e,t,c){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:c})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var c=Object.create(null);if(i.r(c),Object.defineProperty(c,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var s in e)i.d(c,s,function(t){return e[t]}.bind(null,s));return c},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s=0)}([function(e,t,i){var{callAsync:c,getNowTime:s,deleteOldestCacheItem:a}=i(1);e.exports=function(e,t){return t=t||{},class extends e{constructor(e){super(e),this.cacheMaxItems=t.maxItems||0,this.cacheMOPredictEmpties=void 0===t.predictEmpties||!!t.predictEmpties,this.cacheMO={},this.cacheMOQueue={},this.cacheMOEmpties={},this.cacheRT=!1,this.cacheRTQueue=[],this.cacheDI={},this.cacheDIQueried={},this.cacheDIQueue=[],this.cacheDIGotAll=0,this.cacheFTQueried={},this.cacheFTQueue=[]}clearCache(){this.cacheMO={},this.cacheMOEmpties={},this.cacheRT=!1,this.cacheDI={},this.cacheDIQueried={},this.cacheDIGotAll=0,this.cacheFTQueried={}}getEntryMatchesForString(e,t,i){var s=this._createCacheMOEmptiesKey(t);if(this._getCacheMOEmptiesPrediction(s,e))return c(i,null,{items:[]});super.getEntryMatchesForString(e,t,(t,a)=>(this._updateCacheMOEmpties(s,e,t,a),c(i,t,a)))}getMatchesForString(e,t,i){var s=this._createCacheMOKey(e,t),a=this._getCacheMOItem(s);if(a)return c(i,null,a);var h=this.cacheMOQueue[s]=this.cacheMOQueue[s]||[];h.push(i),h.length>1||super.getMatchesForString(e,t,(e,t)=>{e||this._setCacheMOItem(s,t),h.forEach(i=>c(i,e,t)),delete this.cacheMOQueue[s]})}_createCacheMOKey(e,t){return e+JSON.stringify(t||{})}_getCacheMOItem(e){var t=this.cacheMO[e];return t?(t.lastAccessed=s(),t.value):null}_setCacheMOItem(e,t){this.cacheMO[e]={value:t,lastAccessed:s()},this.cacheMaxItems&&Object.keys(this.cacheMO).length>this.cacheMaxItems&&a(this.cacheMO)}_createCacheMOEmptiesKey(e){return JSON.stringify(e||{})}_updateCacheMOEmpties(e,t,i,c){if(this.cacheMOPredictEmpties&&!i&&c&&c.items&&!c.items.length&&""!==t){var s=this.cacheMOEmpties[e]=this.cacheMOEmpties[e]||[];-1==s.indexOf(t)&&s.push(t)}}_getCacheMOEmptiesPrediction(e,t){if(!this.cacheMOPredictEmpties)return!1;var i=this.cacheMOEmpties[e];return i&&i.findIndex(e=>t.startsWith(e))>=0}getRefTerms(e,t){if("boolean"!=typeof this.cacheRT)return this._getRefTermsFromSortedArray(this.cacheRT,e,t);this.cacheRTQueue.push({options:e,cb:t}),!0!==this.cacheRT&&(this.cacheRT=!0,super.getRefTerms({perPage:Number.MAX_VALUE},(e,t)=>{this.cacheRT=!e&&t.items,this.cacheRTQueue.forEach(t=>{if(e)return c(t.cb,e);this._getRefTermsFromSortedArray(this.cacheRT,t.options,t.cb)}),this.cacheRTQueue=[]}))}getDictInfos(e,t){return e.filter?e.filter.id?void this._handleGetDictInfosByIDs(e,t):super.getDictInfos(e,(e,i)=>{e||i.items.forEach(e=>this.cacheDI[e.id]=e),t(e,i)}):this._handleGetDictInfosAll(e,t)}_handleGetDictInfosByIDs(e,t){var i={items:[...new Set(e.filter.id)].map(e=>({id:e,_q:!1})),options:e,cb:t};if(0!=this._updateDIQObjAndCallbackMaybe(i)&&(this.cacheDIQueue.push(i),.5!=this.cacheDIGotAll)){var c=i.items.filter(e=>!1===e._q).map(e=>e.id);if(c.length)return c.forEach(e=>this.cacheDIQueried[e]=!0),super.getDictInfos({filter:{id:c},perPage:Number.MAX_VALUE},(e,t)=>this._handleDIQueryResult(e,t,c))}}_handleGetDictInfosAll(e,t){var i={items:!0,options:e,cb:t};if(0!=this._updateDIQObjAndCallbackMaybe(i)&&(this.cacheDIQueue.push(i),.5!=this.cacheDIGotAll))return this.cacheDIGotAll=.5,super.getDictInfos({perPage:Number.MAX_VALUE},(e,t)=>this._handleDIQueryResult(e,t,!0))}_handleDIQueryResult(e,t,i){var s;!0===i?(this.cacheDIGotAll=e?0:1,e||(this.cacheDIQueried={},this.cacheDI={},t.items.forEach(e=>this.cacheDI[e.id]=e))):(i.forEach(e=>delete this.cacheDIQueried[e]),e||(t.items.forEach(e=>this.cacheDI[e.id]=e),i.forEach(e=>this.cacheDI[e]=this.cacheDI[e]||"-"))),this.cacheDIQueue=this.cacheDIQueue.map(t=>(s=s||!0===t.items,e?!0===i&&!s||!0!==i&&(s||!t.items.some(e=>i.includes(e.id)))?t:c(t.cb,e)&&0:this._updateDIQObjAndCallbackMaybe(t))).filter(e=>e)}_updateDIQueueObject(e){return e.items=e.items.map(e=>void 0===e._q&&e||this.cacheDI[e.id]||{id:e.id,_q:!!this.cacheDIQueried[e.id]}).filter(e=>"-"!=e)}_updateDIQObjAndCallbackMaybe(e){var t=e.items;if(!0===t){if(1!=this.cacheDIGotAll)return e;t=Object.values(this.cacheDI).filter(e=>"-"!=e)}else if(t=this._updateDIQueueObject(e),1==this.cacheDIGotAll)t=t.filter(e=>void 0===e._q);else if(t.some(e=>void 0!==e._q))return e;var i=e.options.sort||"id",s=e.options.page||1,a=e.options.perPage||Number.MAX_VALUE,h=(s-1)*a;return t=t.sort((e,t)=>(e=e[i].toLowerCase())<(t=t[i].toLowerCase())?-1:e>t?1:0).slice(h,h+a),c(e.cb,null,{items:t}),0}loadFixedTerms(e,t,i){var s=e.map(e=>({key:this._idtToFTCacheKey(e.id,e.str),idt:e})).filter(e=>!this.fixedTermsCache[e.key]&&0!==this.cacheFTQueried[e.key]);if(!s.length)return c(i,null);var a=s.filter(e=>!this.cacheFTQueried[e.key]);this.cacheFTQueue.push({awaitedKeys:s.map(e=>e.key),cb:i}),a.length&&(a.forEach(e=>this.cacheFTQueried[e.key]=!0),super.loadFixedTerms(a.map(e=>e.idt),t,e=>this._handleFTQueryResult(e,a.map(e=>e.key))))}_handleFTQueryResult(e,t){t.forEach(t=>{e||this.fixedTermsCache[t]?delete this.cacheFTQueried[t]:this.cacheFTQueried[t]=0}),this.cacheFTQueue=this.cacheFTQueue.map(i=>{var s=i.awaitedKeys.length;return i.awaitedKeys=i.awaitedKeys.filter(e=>!t.includes(e)),e&&i.awaitedKeys.length==s||!e&&i.awaitedKeys.length?i:c(i.cb,e)&&0}).filter(e=>e)}}}},function(e,t){e.exports={callAsync:function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),c=1;c<t;c++)i[c-1]=arguments[c];setTimeout(()=>e(...i),0)},getNowTime:function(){return(new Date).getTime()},deleteOldestCacheItem:function(e){for(var t=Object.keys(e),i=Number.POSITIVE_INFINITY,c=-1,s=0;s<t.length;s++){var a=e[t[s]].lastAccessed;a<i&&(i=a,c=s)}delete e[t[c]]}}}]);
{
"name": "vsm-dictionary-cacher",
"version": "1.2.0",
"version": "1.2.1",
"description": "Wrapper around a VSM-dictionary, that manages a cache of string-match results",

@@ -28,16 +28,16 @@ "main": "src/VsmDictionaryCacher.js",

"devDependencies": {
"@babel/core": "^7.2.2",
"@babel/preset-env": "^7.3.1",
"babel-loader": "^8.0.5",
"@babel/core": "^7.5.5",
"@babel/preset-env": "^7.5.5",
"babel-loader": "^8.0.6",
"chai": "^4.2.0",
"clean-webpack-plugin": "^1.0.1",
"eslint": "^5.13.0",
"eslint": "^5.16.0",
"mocha": "^5.2.0",
"sinon": "^4.5.0",
"terser-webpack-plugin": "^1.2.1",
"vsm-dictionary-local": "^2.6.0",
"webpack": "^4.29.0",
"webpack-cli": "^3.2.1"
"sinon": "^7.3.2",
"terser-webpack-plugin": "^1.4.1",
"vsm-dictionary-local": "^2.6.1",
"webpack": "^4.39.1",
"webpack-cli": "^3.3.6"
},
"dependencies": {}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc