UNPKG

@odoo/o-spreadsheet

Version:
53 lines (52 loc) 1.5 kB
/** * Registry * * The Registry class is basically just a mapping from a string key to an object. * It is really not much more than an object. It is however useful for the * following reasons: * * 1. it let us react and execute code when someone add something to the registry * (for example, the FunctionRegistry subclass this for this purpose) * 2. it throws an error when the get operation fails * 3. it provides a chained API to add items to the registry. */ export declare class Registry<T> { content: { [key: string]: T; }; /** * Add an item to the registry, you can only add if there is no item * already present in the registery with the given key * * Note that this also returns the registry, so another add method call can * be chained */ add(key: string, value: T): this; /** * Replace (or add) an item to the registry * * Note that this also returns the registry, so another add method call can * be chained */ replace(key: string, value: T): this; /** * Get an item from the registry */ get(key: string): T; /** * Check if the key is already in the registry */ contains(key: string): boolean; /** * Get a list of all elements in the registry */ getAll(): T[]; /** * Get a list of all keys in the registry */ getKeys(): string[]; /** * Remove an item from the registry */ remove(key: string): void; }