// Generated by dts-bundle v0.7.3 declare module 'memd' { import { deco_memoize } from 'memd/deco/memoize'; import { deco_debounce } from 'memd/deco/debounce'; import { deco_throttle } from 'memd/deco/throttle'; import { deco_queued } from 'memd/deco/queued'; import { fn_clearMemoized, fn_memoize } from 'memd/fn/memoize'; import { Cache } from 'memd/Cache'; import { FsTransport } from 'memd/persistence/FsTransport'; import { LocalStorageTransport } from 'memd/persistence/LocalStorageTransport'; import { CachedWorker } from 'memd/workers/CachedWorker'; import { fn_queued } from 'memd/fn/queued'; class Memd { static Cache: typeof Cache; static fn: { memoize: typeof fn_memoize; queued: typeof fn_queued; clearMemoized: typeof fn_clearMemoized; }; static deco: { memoize: typeof deco_memoize; throttle: typeof deco_throttle; debounce: typeof deco_debounce; queued: typeof deco_queued; }; static FsTransport: typeof FsTransport; static LocalStorageTransport: typeof LocalStorageTransport; static CachedWorker: typeof CachedWorker; static default: typeof Memd; } export = Memd; } declare module 'memd/deco/memoize' { import { ICacheOpts } from 'memd/Cache'; import { IMemoizeOpts } from 'memd/fn/memoize'; export function deco_memoize any, TThis = any>(opts?: ICacheOpts & IMemoizeOpts): (target: any, propertyKey: any, descriptor?: any) => any; } declare module 'memd/deco/debounce' { /** * * @param timeoutMs ms to wait before calling inner fn */ export function deco_debounce(timeoutMs?: number): (target: any, propertyKey: any, descriptor?: any) => any; } declare module 'memd/deco/throttle' { interface IThrottleOptions { /** Regarding the 1 fn call. The fn will be called at the end of the throttle frame */ shouldCallLater?: boolean; /** Use arguments as throttled key */ perArguments?: boolean; } /** * Calls function maximal each time window frame * @param timeWindow how often, in ms, should the function be called * @param shouldCallLater start calling fn on frame start */ export function deco_throttle(timeWindow: number, shouldCallLater?: boolean): any; export function deco_throttle(timeWindow: number, options?: IThrottleOptions): any; export {}; } declare module 'memd/deco/queued' { export function deco_queued(opts?: { trimQueue?: boolean; timeout?: number; throttle?: number; }): (target: any, propertyKey: any, descriptor?: any) => any; } declare module 'memd/fn/memoize' { import { IMemoizeWrapper } from 'memd/model/IMemoizeWrapper'; import { ICacheOpts } from 'memd/Cache'; export interface IMemoizeOpts any = any, TThis = any> { /** Default: false - we cache result for the prototyped method, means the cache is for all instances. Set this to "true", to make the cache for each entity */ perInstance?: boolean; /** Default: false - cache is active only during the promise is in progress */ clearOnReady?: boolean; /** Default: false - remove cached result if promise is rejected */ clearOnReject?: boolean; /** Method to check if cached result, should be removed from cache */ clearOn?: (val: any) => boolean; thisArg?: TThis; /** Override key resolver */ key?: (options: { this?: TThis; }, ...args: Parameters) => string; /** Gets the prefix for a key, for example to distinguish keys per instances */ keyPfx?: (self: TThis) => string; keyOptions?: { deep?: number; serialize?: { [selector: string]: (val: any) => string; }; }; } export function fn_memoize any, TThis = any>(fn: TMethod, opts?: ICacheOpts & IMemoizeOpts, key?: string): IMemoizeWrapper & TMethod; export function fn_clearMemoized(fn: Function, ...args: any[]): void; } declare module 'memd/Cache' { import { ITransport } from 'memd/persistence/ITransport'; import { IStore } from "memd/persistence/IStore"; export interface ICacheOpts { /** In Seconds */ maxAge?: number; monitors?: ICacheChangeEventMonitor[]; keyResolver?: (...args: any[]) => string; persistence?: ITransport; store?: IStore; doNotWaitSave?: boolean; trackRef?: boolean; } export interface ICacheChangeEventMonitor { on(event: 'change', fn: Function): any; off(event: 'change', fn: Function): any; } export interface ICacheEntry { timestamp?: number; value: T; } export interface ICacheEntryCollection { [key: string]: ICacheEntry; } export class Cache { options: ICacheOpts; static caches: Cache[]; isAsync: boolean; constructor(options?: ICacheOpts); resolveKey(args: any[], keyOptions?: any): string; get(key: string, ...args: any[]): T; getAsync(key: string, ...args: any[]): Promise; set(key: string, val: T): T; setAsync(key: string, val: T): Promise; setRestored(coll: ICacheEntryCollection): void; clear(key?: string): void; clearAsync(key?: string): Promise; destroy(): void; flushAsync(force?: boolean): Promise; static flushAllAsync(): Promise; static resolve(cache: Cache, resolver: () => Promise, key?: string): Promise; } } declare module 'memd/persistence/FsTransport' { import { ITransport } from 'memd/persistence/ITransport'; import { ICacheEntryCollection } from 'memd/Cache'; export interface IFsTransportOpts { path: string; browser?: { localStorage?: boolean; }; } export class FsTransport implements ITransport { opts: IFsTransportOpts; isAsync: boolean; constructor(opts: IFsTransportOpts); restoreAsync(): Promise; flushAsync(coll: ICacheEntryCollection): Promise; } } declare module 'memd/persistence/LocalStorageTransport' { import { ITransport } from 'memd/persistence/ITransport'; import { ICacheEntryCollection } from 'memd/Cache'; export interface ILocalStorageTransport { key: string; } export class LocalStorageTransport implements ITransport { opts: ILocalStorageTransport; isAsync: boolean; constructor(opts: ILocalStorageTransport); restore(): any; flush(coll: ICacheEntryCollection): void; } } declare module 'memd/workers/CachedWorker' { import { IFsTransportOpts } from 'memd/persistence/FsTransport'; import { ILocalStorageTransport } from 'memd/persistence/LocalStorageTransport'; import { ICacheOpts } from 'memd/Cache'; export interface ICachedWorkerOptions { transport: IFsTransportOpts | ILocalStorageTransport; worker: () => (T | Promise); } export class CachedWorker { constructor(opts: ICachedWorkerOptions & ICacheOpts); run(): T; runAsync(): Promise; static run(opts: ICachedWorkerOptions & ICacheOpts): T; static runAsync(opts: ICachedWorkerOptions & ICacheOpts): Promise; } } declare module 'memd/fn/queued' { interface IQueueOpts { /** When the fn is active all further calls will receive active promise */ single?: boolean; /** When the fn is called and the queue has already waiters - remove them */ trimQueue?: boolean; timeout?: number; /** the fn call frequence */ throttle?: number; } /** For original async method - ensure it is called one after another */ export function fn_queued(fn: T, opts?: IQueueOpts): T; export {}; } declare module 'memd/model/IMemoizeWrapper' { export interface IMemoizeWrapper { clearArgs(...args: any[]): any; clearAll(): any; } } declare module 'memd/persistence/ITransport' { import { ICacheEntryCollection } from 'memd/Cache'; export interface ITransport { isAsync: boolean; debounceMs?: number; restore?(): ICacheEntryCollection; restoreAsync?(): Promise>; flush?(data: ICacheEntryCollection): any; flushAsync?(data: ICacheEntryCollection): any; } } declare module 'memd/persistence/IStore' { import { ICacheEntry } from 'memd/Cache'; export interface IStore { get?(key: string, ...args: any[]): ICacheEntry; getAsync?(key: string, ...args: any[]): Promise>; save?(key: string, entry: ICacheEntry): void; saveAsync?(key: string, entry: ICacheEntry): Promise; clear?(key: string): void; clearAsync?(key: string): Promise; } }