New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@peerbit/cache

Package Overview
Dependencies
Maintainers
1
Versions
123
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@peerbit/cache - npm Package Compare versions

Comparing version 2.0.5 to 2.0.6-a4f88b6

dist/src/index.d.ts

115

package.json
{
"name": "@peerbit/cache",
"version": "2.0.5",
"description": "Simple cache",
"type": "module",
"publishConfig": {
"access": "public"
},
"files": [
"lib",
"src",
"!src/**/__tests__",
"!lib/**/__tests__",
"LICENSE"
],
"module": "lib/esm/index.js",
"types": "lib/esm/index.d.ts",
"exports": {
"import": "./lib/esm/index.js",
"require": "./lib/cjs/index.js"
},
"repository": {
"type": "git",
"url": "https://github.com/dao-xyz/peerbit"
},
"homepage": "https://github.com/dao-xyz/peerbit",
"bugs": "https://github.com/dao-xyz/peerbit/issues",
"scripts": {
"clean": "shx rm -rf lib/*",
"build": "yarn clean && tsc -p tsconfig.json",
"test": "node ../../../node_modules/.bin/jest test -c ../../../jest.config.ts --runInBand --forceExit",
"test:unit": "node ../../../node_modules/.bin/jest test -c ../../../jest.config.unit.ts --runInBand --forceExit",
"test:integration": "node ../node_modules/.bin/jest test -c ../../../jest.config.integration.ts --runInBand --forceExit"
},
"license": "MIT",
"devDependencies": {
"@peerbit/time": "2.0.5",
"@types/yallist": "^4.0.1"
},
"dependencies": {
"yallist": "^4.0.0"
},
"localMaintainers": [
"dao.xyz"
],
"gitHead": "180a8c4e6ab6f713134c949d2d7ce9fc5648a4ce"
"name": "@peerbit/cache",
"version": "2.0.6-a4f88b6",
"description": "Simple cache",
"type": "module",
"types": "./dist/src/index.d.ts",
"typesVersions": {
"*": {
"*": [
"*",
"dist/*",
"dist/src/*",
"dist/src/*/index"
],
"src/*": [
"*",
"dist/*",
"dist/src/*",
"dist/src/*/index"
]
}
},
"files": [
"src",
"dist",
"!dist/test",
"!**/*.tsbuildinfo"
],
"exports": {
".": {
"types": "./dist/src/index.d.ts",
"import": "./dist/src/index.js"
}
},
"eslintConfig": {
"extends": "ipfs",
"parserOptions": {
"project": true,
"sourceType": "module"
},
"ignorePatterns": [
"!.aegir.js",
"test/ts-use",
"*.d.ts"
]
},
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "https://github.com/dao-xyz/peerbit"
},
"homepage": "https://github.com/dao-xyz/peerbit",
"bugs": "https://github.com/dao-xyz/peerbit/issues",
"scripts": {
"clean": "aegir clean",
"build": "aegir build --no-bundle",
"test": "aegir test"
},
"license": "MIT",
"devDependencies": {
"@peerbit/time": "2.0.6-a4f88b6",
"@types/yallist": "^4.0.4"
},
"dependencies": {
"yallist": "^4.0.0"
},
"localMaintainers": [
"dao.xyz"
]
}

@@ -5,6 +5,7 @@ // Fifo

export type CacheData<T> = { value?: T | null; time: number; size: number };
type Key = string | bigint | number;
export class Cache<T = undefined> {
private _map: Map<string, CacheData<T>>;
private deleted: Set<string>;
private list: yallist<string>;
private _map: Map<Key, CacheData<T>>;
private deleted: Set<Key>;
private list: yallist<Key>;
currentSize: number;

@@ -23,3 +24,3 @@ deletedSize: number;

}
has(key: string) {
has(key: Key) {
this.trim();

@@ -32,7 +33,7 @@ if (this.deleted.has(key)) {

get map(): Map<string, CacheData<T>> {
get map(): Map<Key, CacheData<T>> {
return this._map;
}
get(key: string): T | null | undefined {
get(key: Key): T | null | undefined {
this.trim();

@@ -68,3 +69,3 @@ if (this.deleted.has(key)) {

del(key: string) {
del(key: Key) {
const cacheValue = this._map.get(key)!;

@@ -79,3 +80,3 @@ if (cacheValue && !this.deleted.has(key)) {

add(key: string, value?: T, size = 1) {
add(key: Key, value?: T, size = 1) {
this.deleted.delete(key);

@@ -82,0 +83,0 @@ const time = +new Date();

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