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

@types/catbox

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/catbox - npm Package Compare versions

Comparing version 10.0.1 to 10.0.2

135

catbox/index.d.ts

@@ -7,3 +7,3 @@ // Type definitions for catbox 10.0

// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.4
// TypeScript Version: 2.8

@@ -21,3 +21,3 @@ /**

*/
export class Client implements ClientApi {
export class Client<T> implements ClientApi<T> {
constructor(engine: EnginePrototypeOrObject, options: ClientOptions);

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

*/
get(key: CacheKey): Promise<null | CachedObject>;
get(key: CacheKey): Promise<null | CachedObject<T>>;
/**

@@ -41,3 +41,3 @@ * set(key, value, ttl, callback) - store an item in the cache for a specified length of time, where:

*/
set(key: CacheKey, value: CacheItem, ttl: number): Promise<void>;
set(key: CacheKey, value: T, ttl: number): Promise<void>;
/**

@@ -54,3 +54,3 @@ * drop(key, callback) - remove an item from cache where:

export type EnginePrototypeOrObject = EnginePrototype | ClientApi;
export type EnginePrototypeOrObject = EnginePrototype<any> | ClientApi<any>;

@@ -60,4 +60,4 @@ /**

*/
export interface EnginePrototype {
new(settings: ClientOptions): ClientApi;
export interface EnginePrototype<T> {
new(settings: ClientOptions): ClientApi<T>;
}

@@ -70,3 +70,3 @@

*/
export interface ClientApi {
export interface ClientApi<T> {
/** start() - creates a connection to the cache server. Must be called before any other method is available. */

@@ -80,3 +80,3 @@ start(): Promise<void>;

*/
get(key: CacheKey): Promise<null | CachedObject>;
get(key: CacheKey): Promise<null | CachedObject<T>>;
/**

@@ -88,3 +88,3 @@ * set(key, value, ttl) - store an item in the cache for a specified length of time, where:

*/
set(key: CacheKey, value: CacheItem, ttl: number): Promise<void>;
set(key: CacheKey, value: T, ttl: number): Promise<void>;
/**

@@ -112,5 +112,5 @@ * drop(key) - remove an item from cache where:

/** Cached object contains the following: */
export interface CachedObject {
export interface CachedObject<T> {
/** item - the value stored in the cache using set(). */
item: any;
item: T;
/** stored - the timestamp when the item was stored in the cache (in milliseconds). */

@@ -122,4 +122,2 @@ stored: number;

export type CacheItem = any;
export interface ClientOptions {

@@ -132,85 +130,65 @@ /**

export type PolicyOptionVariants<T> = PolicyOptions<T> | DecoratedPolicyOptions<T>;
/**
* The Policy object provides a convenient cache interface by setting a global policy which is automatically applied to every storage action.
* The Policy object provides a convenient cache interface by setting a
* global policy which is automatically applied to every storage action.
* The object is constructed using new Policy(options, [cache, segment]) where:
* * options - an object with the IPolicyOptions structure
* * cache - a Client instance (which has already been started).
* * segment - required when cache is provided. The segment name used to isolate cached items within the cache partition.
* * segment - required when cache is provided. The segment name used to
* isolate cached items within the cache partition.
* @see {@link https://github.com/hapijs/catbox#policy}
*/
export class Policy implements PolicyAPI {
constructor(options: PolicyOptions, cache: Client, segment: string);
export class Policy<T, O extends PolicyOptionVariants<T>> {
constructor(options: O, cache: Client<T>, segment: string);
/**
* get(id) - retrieve an item from the cache. If the item is not found and the generateFunc method was provided,
* a new value is generated, stored in the cache, and returned. Multiple concurrent requests are queued and processed once. The method arguments are:
* * id - the unique item identifier (within the policy segment). Can be a string or an object with the required 'id' key.
* retrieve an item from the cache. If the item is not
* found and the generateFunc method was provided,
* a new value is generated, stored in the cache, and returned.
* Multiple concurrent requests are queued and processed once. The method arguments are:
* @param id the unique item identifier (within the policy segment).
* Can be a string or an object with the required 'id' key.
*/
get(id: string | { id: string }): Promise<PolicyGetPromiseResult | null>;
get(id: string | { id: string }): Promise<O extends DecoratedPolicyOptions<T> ? DecoratedResult<T> : T | null>;
/**
* set(id, value, ttl) - store an item in the cache where:
* * id - the unique item identifier (within the policy segment).
* * value - the string or object value to be stored.
* * ttl - a time-to-live override value in milliseconds after which the item is automatically removed from the cache (or is marked invalid).
* store an item in the cache where:
* @param id - the unique item identifier (within the policy segment).
* @param value - the string or object value to be stored.
* @param ttl - a time-to-live override value in milliseconds after which the item is automatically
* removed from the cache (or is marked invalid).
* This should be set to 0 in order to use the caching rules configured when creating the Policy object.
*/
set(id: string | { id: string }, value: CacheItem, ttl: number | null): Promise<void>;
set(id: string | { id: string }, value: T, ttl?: number): Promise<void>;
/**
* drop(id) - remove the item from cache where:
* * id - the unique item identifier (within the policy segment).
* remove the item from cache where:
* @param id the unique item identifier (within the policy segment).
*/
drop(id: string | { id: string }): Promise<void>;
/** ttl(created) - given a created timestamp in milliseconds, returns the time-to-live left based on the configured rules. */
ttl(created: number): number;
/** rules(options) - changes the policy rules after construction (note that items already stored will not be affected) */
rules(options: PolicyOptions): void;
/** isReady() - returns true if cache engine determines itself as ready, false if it is not ready or if there is no cache engine set. */
isReady(): boolean;
/** stats - an object with cache statistics */
stats(): CacheStatisticsObject;
}
/**
* Policy API
* The Policy object provides the following methods:
* @see {@link https://github.com/hapijs/catbox#api-1}
*/
export interface PolicyAPI {
/**
* get(id) - retrieve an item from the cache. If the item is not found and the generateFunc method was provided,
* a new value is generated, stored in the cache, and returned. Multiple concurrent requests are queued and processed once. The method arguments are:
* * id - the unique item identifier (within the policy segment). Can be a string or an object with the required 'id' key.
* given a created timestamp in milliseconds, returns the time-to-live left
* based on the configured rules.
*/
get(id: string | { id: string }): Promise<PolicyGetPromiseResult | null>;
ttl(created: number): number;
/** changes the policy rules after construction (note that items already stored will not be affected) */
rules(options: PolicyOptions<T>): void;
/**
* set(id, value, ttl) - store an item in the cache where:
* * id - the unique item identifier (within the policy segment).
* * value - the string or object value to be stored.
* * ttl - a time-to-live override value in milliseconds after which the item is automatically removed from the cache (or is marked invalid).
* This should be set to 0 in order to use the caching rules configured when creating the Policy object.
* returns true if cache engine determines itself as ready, false if it is not ready or if
* here is no cache engine set.
*/
set(id: string | { id: string }, value: CacheItem, ttl: number | null): Promise<void>;
/**
* drop(id) - remove the item from cache where:
* * id - the unique item identifier (within the policy segment).
*/
drop(id: string | { id: string }): Promise<void>;
/** ttl(created) - given a created timestamp in milliseconds, returns the time-to-live left based on the configured rules. */
ttl(created: number): number;
/** rules(options) - changes the policy rules after construction (note that items already stored will not be affected) */
rules(options: PolicyOptions): void;
/** isReady() - returns true if cache engine determines itself as ready, false if it is not ready or if there is no cache engine set. */
isReady(): boolean;
/** stats - an object with cache statistics */
/** an object with cache statistics */
stats(): CacheStatisticsObject;
}
export interface PolicyGetPromiseResult {
value: CacheItem;
cached: PolicyGetCachedOptions;
export interface DecoratedResult<T> {
value: T;
cached: PolicyGetCachedOptions<T>;
report: PolicyGetReportLog;
}
export interface PolicyGetCachedOptions {
export interface PolicyGetCachedOptions<T> {
/** item - the cached value. */
item: CacheItem;
item: T;
/** stored - the timestamp when the item was stored in the cache. */

@@ -227,3 +205,3 @@ stored: number;

*/
export interface PolicyOptions {
export interface PolicyOptions<T> {
/** expiresIn - relative expiration expressed in the number of milliseconds since the item was saved in the cache. Cannot be used together with expiresAt. */

@@ -234,3 +212,3 @@ expiresIn?: number;

/** generateFunc - a function used to generate a new cache item if one is not found in the cache when calling get(). The method's signature is function(id, next) where: */
generateFunc?: GenerateFunc;
generateFunc?: GenerateFunc<T>;
/**

@@ -259,3 +237,3 @@ * staleIn - number of milliseconds to mark an item stored in cache as stale and attempt to regenerate it when generateFunc is provided.

* pendingGenerateTimeout - number of milliseconds while generateFunc call is in progress for a given id, before a subsequent generateFunc call is allowed.
* Defaults to 0, no blocking of concurrent generateFunc calls beyond staleTimeout.
* @default 0, no blocking of concurrent generateFunc calls beyond staleTimeout.
*/

@@ -265,2 +243,9 @@ pendingGenerateTimeout?: number;

export interface DecoratedPolicyOptions<T> extends PolicyOptions<T> {
/**
* @default false
*/
getDecoratedValue?: boolean;
}
export interface GenerateFuncFlags {

@@ -281,3 +266,3 @@ ttl: number;

*/
export type GenerateFunc = (id: string, flags: GenerateFuncFlags) => Promise<CacheItem>;
export type GenerateFunc<T> = (id: string, flags: GenerateFuncFlags) => Promise<T>;

@@ -284,0 +269,0 @@ /**

{
"name": "@types/catbox",
"version": "10.0.1",
"version": "10.0.2",
"description": "TypeScript definitions for catbox",

@@ -24,2 +24,3 @@ "license": "MIT",

"main": "",
"types": "",
"repository": {

@@ -31,4 +32,4 @@ "type": "git",

"dependencies": {},
"typesPublisherContentHash": "aca6ba6c382d66670578b67c7e2027380b5c2ebb08165e24aa91eb2fe2ab2bc3",
"typeScriptVersion": "2.4"
"typesPublisherContentHash": "77ea2106498a40c8c0c63bc6b7b6b511c5b304a9c39fc8cf019238ffa7fede95",
"typeScriptVersion": "2.8"
}

@@ -11,3 +11,3 @@ # Installation

Additional Details
* Last updated: Thu, 09 Aug 2018 01:47:21 GMT
* Last updated: Mon, 22 Oct 2018 19:29:27 GMT
* Dependencies: none

@@ -14,0 +14,0 @@ * Global values: none

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