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

keyv

Package Overview
Dependencies
Maintainers
2
Versions
63
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

keyv - npm Package Compare versions

Comparing version 4.2.1 to 4.2.2

2

package.json
{
"name": "keyv",
"version": "4.2.1",
"version": "4.2.2",
"description": "Simple key-value storage with support for multiple backends",

@@ -5,0 +5,0 @@ "main": "src/index.js",

import {EventEmitter} from 'events';
declare class Keyv<T = any> extends EventEmitter {
constructor(uri: string, options: Keyv.Options);
get(key: string, options?: any): Promise<T>;
set(key: string, value: T, ttl?: number): Promise<boolean>;
type WithRequiredProperties<T, K extends keyof T> = T & Required<Pick<T, K>>;
declare class Keyv<Value = any, Options extends Record<string, any> = Record<string, unknown>> extends EventEmitter {
/**
* `this.opts` is an object containing at least the properties listed
* below. However, `Keyv.Options` allows arbitrary properties as well.
* These properties can be specified as the second type parameter to `Keyv`.
*/
opts: WithRequiredProperties<
Keyv.Options<Value>,
'deserialize' | 'namespace' | 'serialize' | 'store' | 'uri'
> &
Options;
/**
* @param opts The options object is also passed through to the storage adapter. Check your storage adapter docs for any extra options.
*/
constructor(options?: Keyv.Options<Value> & Options);
/**
* @param uri The connection string URI.
*
* Merged into the options object as options.uri.
* @param opts The options object is also passed through to the storage adapter. Check your storage adapter docs for any extra options.
*/
constructor(uri?: string, options?: Keyv.Options<Value> & Options);
/** Returns the value. */
get<Raw extends boolean = false>(key: string, options?: {raw?: Raw}):
Promise<(Raw extends false
? Value
: Keyv.DeserializedData<Value>) | undefined>;
/**
* Set a value.
*
* By default keys are persistent. You can set an expiry TTL in milliseconds.
*/
set(key: string, value: Value, ttl?: number): Promise<true>;
/**
* Deletes an entry.
*
* Returns `true` if the key existed, `false` if not.
*/
delete(key: string): Promise<boolean>;
/** Delete all entries in the current namespace. */
clear(): Promise<void>;
has(key: string): Promise<boolean>;
}
declare namespace Keyv {
interface Options {
interface Options<Value> {
[key: string]: any;
/** Namespace for the current instance. */
namespace?: string | undefined;
serialize?: ((data: any) => string) | undefined;
deserialize?: ((data: string) => any | undefined) | undefined;
/** A custom serialization function. */
serialize?: ((data: DeserializedData<Value>) => string) | undefined;
/** A custom deserialization function. */
deserialize?: ((data: string) => DeserializedData<Value> | undefined) | undefined;
/** The connection string URI. */
uri?: string | undefined;
/** The storage adapter instance to be used by Keyv. */
store?: Store<Value> | undefined;
/** Default TTL. Can be overridden by specififying a TTL on `.set()`. */
ttl?: number | undefined;
/** Specify an adapter to use. e.g `'redis'` or `'mongodb'`. */
adapter?: 'redis' | 'mongodb' | 'mongo' | 'sqlite' | 'postgresql' | 'postgres' | 'mysql' | undefined;
}
type Store<T> = Keyv<T>;
interface DeserializedData<Value> {
value: Value; expires: number | undefined;
}
interface Store<Value> {
get(key: string): Value | Promise<Value | undefined> | undefined;
set(key: string, value: Value, ttl?: number): any;
delete(key: string): boolean | Promise<boolean>;
clear(): void | Promise<void>;
}
}
export = 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