Class
StoreModule | import { Store } from "@tsed/core" |
---|---|
Source | /packages/core/src/class/Store.ts |
Overview
class Store {
constructor(args: any[]);
readonly size: number;
static from(...args: any[]): Store;
static fromMethod(target: any, propertyKey: string): Store;
static decorate(fn: (store: Store, parameters: DecoratorParameters) =>; void): Function;
get(key: any): any;
has(key: any): boolean;
set(key: any, metadata: any): Store;
entries(): IterableIterator<;[string, any]>;;
keys(): IterableIterator<;string>;;
clear(): void;
delete(key: string): boolean;
forEach(callbackfn: (value: any, key: string, map: Map<;string, any>;) =>; void, thisArg?: any): void;
values(): IterableIterator<;any>;;
merge(key: any, value: any): Store;
storeValues(options: {
[key: string]: any;
}): void;
}
Members
readonly size: number
Return the size of the collection.
static from(...args: any[]): Store
Create or get a Store from args {target + methodName + descriptor}
static fromMethod(target: any, propertyKey: string): Store
Create store on the method.
static decorate(fn: (store: Store, parameters: DecoratorParameters) =>; void): Function
Create a store correctly configured from the parameters given by the decorator.
The fn
can return a decorator that will be initialized with the parameters (target, propertyKey, descriptor).
get(key: any): any
Param | Type | Description |
---|---|---|
key | any | Required. The key of the element to return from the Map object. |
The get() method returns a specified element from a Map object.
has(key: any): boolean
The has() method returns a boolean indicating whether an element with the specified key exists or not.
set(key: any, metadata: any): Store
Param | Type | Description |
---|---|---|
key | any | Required. The key of the element to add to the Map object. metadata |
The set() method adds or updates an element with a specified key and value to a Map object.
entries(): IterableIterator<;[string, any]>;
The entries() method returns a new Iterator object that contains the [key, value] pairs for each element in the Map object in insertion order.
keys(): IterableIterator<;string>;
The keys() method returns a new Iterator object that contains the keys for each element in the Map object in insertion order.
clear(): void
The clear() method removes all elements from a Map object.
delete(key: string): boolean
Param | Type | Description |
---|---|---|
key | string | Required. The key of the element to remove from the Map object. |
The delete() method removes the specified element from a Map object.
forEach(callbackfn: (value: any, key: string, map: Map<;string, any>;) =>; void, thisArg?: any): void
Param | Type | Description |
---|---|---|
callbackfn | (value: any | Function to execute for each element. thisArg |
The forEach() method executes a provided function once per each key/value pair in the Map object, in insertion order.
The forEach method executes the provided callback once for each key of the map which actually exist. It is not invoked for keys which have been deleted. However, it is executed for values which are present but have the value undefined. callback is invoked with three arguments:
- the element value
- the element key
- the Map object being traversed
If a thisArg parameter is provided to forEach, it will be passed to callback when invoked, for use as its this value. Otherwise, the value undefined will be passed for use as its this value. The this value ultimately observable by callback is determined according to the usual rules for determining the this seen by a function.
Each value is visited once, except in the case when it was deleted and re-added before forEach has finished. callback is not invoked for values deleted before being visited. New values added before forEach has finished will be visited. forEach executes the callback function once for each element in the Map object; it does not return a value.
values(): IterableIterator<;any>;
The values() method returns a new Iterator object that contains the values for each element in the Map object in insertion order.
merge(key: any, value: any): Store
storeValues(options: {
[key: string]: any;
}): void;
Store all keys contains in the options object.