Socket
Socket
Sign inDemoInstall

simple-in-memory-cache

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

simple-in-memory-cache - npm Package Compare versions

Comparing version 0.3.0 to 0.3.1

dist/cache.test.d.ts

12

dist/cache.d.ts

@@ -14,4 +14,14 @@ export interface SimpleInMemoryCache<T> {

}
export declare const createCache: <T>({ defaultSecondsUntilExpiration }?: {
export declare const createCache: <T>({ seconds, defaultSecondsUntilExpiration: defaultSecondsUntilExpirationInput, }?: {
/**
* the number of seconds items in the cache expire after
*/
defaultSecondsUntilExpiration?: number | undefined;
/**
* a shorthand alias for `defaultSecondsUntilExpiration`
*
* note
* - if both options are set, `defaultSecondsUntilExpirationInput` takes precedence
*/
seconds?: number | undefined;
}) => SimpleInMemoryCache<T>;

8

dist/cache.js

@@ -5,7 +5,10 @@ "use strict";

const getMseNow = () => new Date().getTime();
exports.createCache = ({ defaultSecondsUntilExpiration = 5 * 60 } = {}) => {
const createCache = ({ seconds, defaultSecondsUntilExpiration: defaultSecondsUntilExpirationInput, } = {}) => {
var _a;
// resolve input alias
const defaultSecondsUntilExpiration = (_a = defaultSecondsUntilExpirationInput !== null && defaultSecondsUntilExpirationInput !== void 0 ? defaultSecondsUntilExpirationInput : seconds) !== null && _a !== void 0 ? _a : 5 * 60;
// initialize a fresh in-memory cache object
const cache = {};
// define how to set an item into the cache
const set = (key, value, { secondsUntilExpiration = defaultSecondsUntilExpiration } = {}) => {
const set = (key, value, { secondsUntilExpiration = defaultSecondsUntilExpiration, } = {}) => {
// handle cache invalidation

@@ -36,2 +39,3 @@ if (value === undefined) {

};
exports.createCache = createCache;
//# sourceMappingURL=cache.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createCache = void 0;
var cache_1 = require("./cache");
Object.defineProperty(exports, "createCache", { enumerable: true, get: function () { return cache_1.createCache; } });
//# sourceMappingURL=index.js.map
{
"name": "simple-in-memory-cache",
"version": "0.3.0",
"author": "ehmpathy",
"description": "A simple in-memory cache, for nodejs and the browser, with time based expiration policies.",
"author": "UladKasach @uladkasach",
"license": "MIT",
"repository": "uladkasach/simple-in-memory-cache",
"version": "0.3.1",
"repository": "ehmpathy/simple-in-memory-cache",
"homepage": "https://github.com/ehmpathy/simple-in-memory-cache",

@@ -32,34 +31,57 @@ "keywords": [

"scripts": {
"build:clean": "rm -rf ./dist",
"build:ts": "tsc -p ./tsconfig.build.json",
"build": "npm run build:clean && npm run build:ts",
"test:types": "tsc --noEmit",
"test:format": "prettier --parser typescript --check 'src/**/*.ts' --config ./prettier.config.js",
"test:lint": "eslint -c ./.eslintrc.js src/**/*.ts",
"test:unit": "jest --forceExit --verbose --passWithNoTests",
"test:integration": "jest -c ./jest.integration.config.js --forceExit --verbose --passWithNoTests",
"test": "npm run test:types && npm run test:lint && npm run test:unit && npm run test:integration",
"commit:with-cli": "npx cz",
"fix:format:prettier": "prettier --write '**/*.ts' --config ./prettier.config.js",
"fix:format": "npm run fix:format:prettier",
"fix:lint": "eslint -c ./.eslintrc.js src/**/*.ts --fix",
"build:clean": "rm dist/ -rf",
"build:compile": "tsc -p ./tsconfig.build.json",
"build": "npm run build:clean && npm run build:compile",
"test:commits": "LAST_TAG=$(git describe --tags --abbrev=0 @^ 2> /dev/null || git rev-list --max-parents=0 HEAD) && npx commitlint --from $LAST_TAG --to HEAD --verbose",
"test:types": "tsc -p ./tsconfig.build.json --noEmit",
"test:format:prettier": "prettier --parser typescript --check 'src/**/*.ts' --config ./prettier.config.js",
"test:format": "npm run test:format:prettier",
"test:lint:deps": "npx depcheck -c ./depcheckrc.yml",
"test:lint:eslint": "eslint -c ./.eslintrc.js src/**/*.ts",
"test:lint": "npm run test:lint:eslint && npm run test:lint:deps",
"test:unit": "jest -c ./jest.unit.config.ts --forceExit --verbose --passWithNoTests",
"test:integration": "jest -c ./jest.integration.config.ts --forceExit --verbose --passWithNoTests",
"test:acceptance:locally": "npm run build && LOCALLY=true jest -c ./jest.acceptance.config.ts --forceExit --verbose --runInBand --passWithNoTests",
"test": "npm run test:commits && npm run test:types && npm run test:format && npm run test:lint && npm run test:unit && npm run test:integration && npm run test:acceptance:locally",
"test:acceptance": "npm run build && jest -c ./jest.acceptance.config.ts --forceExit --verbose --runInBand --passWithNoTests",
"prepush": "npm run test && npm run build",
"prepublish": "npm run build",
"preversion": "npm run prepublish && npm run test",
"postversion": "git push origin master --tags --no-verify"
"preversion": "npm run prepush",
"postversion": "git push origin HEAD --tags --no-verify"
},
"devDependencies": {
"@types/jest": "^24.0.18",
"@types/uuid": "^3.4.5",
"@typescript-eslint/eslint-plugin": "2.19.0",
"@typescript-eslint/parser": "2.19.0",
"eslint": "6.1.0",
"eslint-config-airbnb-base": "14.0.0",
"eslint-config-airbnb-typescript": "7.0.0",
"eslint-config-prettier": "6.10.0",
"eslint-plugin-import": "2.20.1",
"eslint-plugin-prettier": "3.1.2",
"husky": "^1.3.1",
"jest": "^25.5.4",
"prettier": "^2.0.4",
"ts-jest": "^25.4.0",
"typescript": "^3.8.3",
"uuid": "^3.3.3"
"@commitlint/config-conventional": "13.1.0",
"@trivago/prettier-plugin-sort-imports": "2.0.4",
"@tsconfig/node-lts-strictest": "18.12.1",
"@types/jest": "29.2.4",
"@typescript-eslint/eslint-plugin": "5.46.1",
"@typescript-eslint/parser": "5.46.1",
"commitlint": "^17.6.7",
"core-js": "3.26.1",
"cz-conventional-changelog": "3.3.0",
"declapract": "^0.11.2",
"declapract-typescript-ehmpathy": "^0.25.1",
"depcheck": "1.4.3",
"eslint": "8.30.0",
"eslint-config-airbnb-typescript": "17.0.0",
"eslint-config-prettier": "8.5.0",
"eslint-plugin-import": "2.26.0",
"eslint-plugin-prettier": "4.2.1",
"husky": "7.0.2",
"jest": "29.3.1",
"prettier": "2.8.1",
"ts-jest": "29.0.3",
"ts-node": "10.9.1",
"typescript": "4.9.4"
},
"dependencies": {}
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
}
}

Sorry, the diff of this file is not supported yet

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