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

cache-conf

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cache-conf - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

27

index.js
'use strict';
const path = require('path');
const Conf = require('conf');
const pkgUp = require('pkg-up');
const parentDir = path.dirname(module.parent.filename);
class CacheConf extends Conf {
constructor(options) {
const pkgPath = pkgUp.sync(parentDir);
options = Object.assign({
projectName: pkgPath && require(pkgPath).name // eslint-disable-line import/no-dynamic-require
}, options);
super(options);
this.version = options.version;
}
get(key) {

@@ -26,2 +42,3 @@ if (this.isExpired(key)) {

timestamp: opts.maxAge && Date.now() + opts.maxAge,
version: this.version,
data: key[k]

@@ -33,2 +50,3 @@ });

timestamp: opts.maxAge && Date.now() + opts.maxAge,
version: this.version,
data: val

@@ -55,3 +73,10 @@ });

return Boolean(item && item.timestamp && item.timestamp < Date.now());
if (!item) {
return false;
}
const invalidTimestamp = item.timestamp && item.timestamp < Date.now();
const invalidVersion = item.version !== this.version;
return Boolean(invalidTimestamp || invalidVersion);
}

@@ -58,0 +83,0 @@ }

5

package.json
{
"name": "cache-conf",
"version": "0.2.0",
"version": "0.3.0",
"description": "Simple cache config handling for your app or module",

@@ -42,3 +42,4 @@ "license": "MIT",

"dependencies": {
"conf": "^0.11.2"
"conf": "^0.11.2",
"pkg-up": "^1.0.0"
},

@@ -45,0 +46,0 @@ "devDependencies": {

@@ -65,2 +65,8 @@ # cache-conf [![Build Status](https://travis-ci.org/SamVerschueren/cache-conf.svg?branch=master)](https://travis-ci.org/SamVerschueren/cache-conf)

###### version
Type: `string`
Version number of the data. If the version provided is not the same as the version of the cached data, the data will be invalid.
#### isExpired(key)

@@ -67,0 +73,0 @@

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