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

@keyvhq/core

Package Overview
Dependencies
Maintainers
2
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@keyvhq/core - npm Package Compare versions

Comparing version 1.6.26 to 2.0.0-beta.0

LICENSE.md

12

package.json

@@ -5,3 +5,3 @@ {

"homepage": "https://keyv.js.org",
"version": "1.6.26",
"version": "2.0.0-beta.0",
"main": "src/index.js",

@@ -16,6 +16,6 @@ "author": {

"type": "git",
"url": "git+https://github.com/microlinkhq/keyv.git"
"url": "git+https://github.com/microlinkhq/keyvhq.git"
},
"bugs": {
"url": "https://github.com/microlinkhq/keyv/issues"
"url": "https://github.com/microlinkhq/keyvhq/issues"
},

@@ -25,2 +25,3 @@ "keywords": [

"key",
"keyv",
"store",

@@ -42,3 +43,3 @@ "ttl",

"engines": {
"node": ">= 14"
"node": ">= 16"
},

@@ -60,3 +61,4 @@ "files": [

},
"types": "./src/index.d.ts"
"types": "./src/index.d.ts",
"gitHead": "0dd985847a08f779bbc1845f46e0388be62e02b6"
}

@@ -1,11 +0,2 @@

// Type definitions for keyv 3.1
// Project: https://github.com/lukechilds/keyv
// Definitions by: AryloYeung <https://github.com/Arylo>
// BendingBender <https://github.com/BendingBender>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
import { EventEmitter } from 'events'
declare class Keyv<TValue = any> extends EventEmitter {
declare class Keyv<TValue = any> {
constructor (opts?: Keyv.Options<TValue>)

@@ -33,3 +24,3 @@

/** Delete all entries in the current namespace. */
clear (): Promise<void>
clear (options?: Record<string, any>): Promise<void>
/**

@@ -36,0 +27,0 @@ * Yields an iterator with all the key, value entries in the namespace.

'use strict'
const EventEmitter = require('events')
const JSONB = require('json-buffer')
class Keyv extends EventEmitter {
class Keyv {
constructor (options = {}) {
super()
Object.entries(
Object.assign(
{
serialize: JSONB.stringify,
deserialize: JSONB.parse,
store: new Map()
},
options
)
).forEach(([key, value]) => (this[key] = value))
Object.entries(Object.assign(
{
serialize: JSONB.stringify,
deserialize: JSONB.parse,
store: new Map()
},
options
)).forEach(([key, value]) => (this[key] = value))
if (typeof this.store.on === 'function') {
this.store.on('error', error => this.emit('error', error))
}
const generateIterator = iterator =>

@@ -28,3 +23,4 @@ async function * () {

: iterator) {
const data = typeof raw === 'string' ? await this.deserialize(raw) : raw
const data =
typeof raw === 'string' ? await this.deserialize(raw) : raw
if (this.namespace && !key.includes(this.namespace)) {

@@ -55,3 +51,5 @@ continue

_getKeyPrefix (key) {
return this.namespace ? `${this.namespace}:${key}` : (key && key.toString()) || key
return this.namespace
? `${this.namespace}:${key}`
: (key && key.toString()) || key
}

@@ -78,3 +76,5 @@

async has (key) {
return typeof this.store.has === 'function' ? this.store.has(this._getKeyPrefix(key)) : (await this.store.get(this._getKeyPrefix(key))) !== undefined
return typeof this.store.has === 'function'
? this.store.has(this._getKeyPrefix(key))
: (await this.store.get(this._getKeyPrefix(key))) !== undefined
}

@@ -96,6 +96,6 @@

async clear () {
return this.store.clear(this.namespace)
async clear (options) {
return this.store.clear(this.namespace, options)
}
}
module.exports = Keyv
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