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

think-cache

Package Overview
Dependencies
Maintainers
2
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

think-cache - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

34

cache.js

@@ -14,19 +14,19 @@ const assert = require('assert');

*/
function thinkCache(name, value, config){
function ThinkCache(name, value, config) {
assert(name && helper.isString(name), 'cache.name must be a string');
if(this.config){
if (this.config) {
config = helper.parseAdapterConfig(this.config('cache'), config);
}else{
} else {
config = helper.parseAdapterConfig(config);
}
const handle = config.handle;
assert(helper.isFunction(handle), 'cache.handle must be a function');
const Handle = config.handle;
assert(helper.isFunction(Handle), 'cache.handle must be a function');
delete config.handle;
const instance = new handle(config);
//delete cache
if(value === null){
const instance = new Handle(config);
// delete cache
if (value === null) {
return Promise.resolve(instance.delete(name));
}
//get cache
if(value === undefined){
// get cache
if (value === undefined) {
return debounceInstance.debounce(name, () => {

@@ -36,8 +36,8 @@ return instance.get(name);

}
//get cache when value is function
if(helper.isFunction(value)){
// get cache when value is function
if (helper.isFunction(value)) {
return debounceInstance.debounce(name, () => {
let cacheData;
return instance.get(name).then(data => {
if(data === undefined){
if (data === undefined) {
return value(name);

@@ -47,3 +47,3 @@ }

}).then(data => {
if(data !== undefined){
if (data !== undefined) {
cacheData = data;

@@ -54,9 +54,9 @@ return instance.set(name, data);

return cacheData;
})
});
});
}
//set cache
// set cache
return Promise.resolve(instance.set(name, value));
}
module.exports = thinkCache;
module.exports = ThinkCache;

@@ -16,2 +16,2 @@ const thinkCache = require('./cache.js');

}
}
};
{
"name": "think-cache",
"description": "Cache for ThinkJS",
"version": "1.0.3",
"version": "1.0.4",
"author": {

@@ -10,4 +10,5 @@ "name": "welefen",

"scripts": {
"test": "eslint index.js && nyc ava test/",
"coverage": "nyc ava test/index.js && nyc report --reporter=html"
"lint": "eslint --fix index.js & eslint --fix cache.js",
"test": "npm run lint && nyc ava test/",
"coverage": "npm test && nyc report --reporter=html"
},

@@ -30,3 +31,4 @@ "contributors": [

"coveralls": "^2.11.16",
"eslint": "2.8.0",
"eslint": "~4.2.0",
"eslint-config-think": "~1.0.1",
"nyc": "^7.1.0"

@@ -33,0 +35,0 @@ },

Sorry, the diff of this file is not supported yet

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