Class: VaultItemCollection
collection.VaultItemCollection
A collection of vault items items, used for consolidating changes made independently across multiple instances through "merging".
Hierarchy
-
↳
VaultItemCollection
Implements
Iterable
<VaultItem
>
Constructors
constructor
• new VaultItemCollection(items?
)
Parameters
Name | Type | Default value |
---|---|---|
items |
VaultItem [] |
[] |
Overrides
Defined in
Properties
_changes
• Private
_changes: Map
<string
, Date
>
Defined in
_items
• Private
_items: Map
<string
, VaultItem
>
Defined in
_propertySerializationOptions
• _propertySerializationOptions:
SerializationOptions
[]
Inherited from
Serializable._propertySerializationOptions
Defined in
Accessors
hasChanges
• get
hasChanges(): boolean
Returns
boolean
Defined in
kind
• get
kind(): string
A string representing the objects "type", useful for segmenting storage, among other things. Defaults to the lowercase class name, but can be overwritten by subclasses
Returns
string
Inherited from
Serializable.kind
Defined in
size
• get
size(): number
Number of items in this VaultItemCollection
Returns
number
Defined in
tags
• get
tags(): string
[]
Aggregated list of tags assigned to the items in this collection
Returns
string
[]
Defined in
Methods
[iterator]
▸ [iterator](): IterableIterator
<VaultItem
>
Returns
IterableIterator
<VaultItem
>
Implementation of
Iterable.__@iterator@78
Defined in
_fromRaw
▸ Protected
_fromRaw(__namedParameters
): void
Restore values from a raw object. The default implementation simply copies over all iterable properties from the base object. Overwrite this method for properties that require special treatment
Parameters
Name | Type |
---|---|
__namedParameters |
any |
Returns
void
Overrides
Defined in
_toRaw
▸ Protected
_toRaw(version
): Object
Transform this object into a raw javascript object used for serialization. The default implementation simply copies all iterable properties not included in the [[exlude]] array and calls toRaw on any properties that are themselfes instances of Serializable. This method should be overwritten by subclasses if certain properties require special treatment.
Parameters
Name | Type |
---|---|
version |
string |
Returns
Object
Name | Type |
---|---|
changes |
[string , Date ][] |
items |
any [] |
Overrides
Defined in
clearChanges
▸ clearChanges(before?
): void
Parameters
Name | Type |
---|---|
before? |
Date |
Returns
void
Defined in
clone
▸ clone(): VaultItemCollection
Creates a deep clone of the object
Returns
Inherited from
Defined in
fromBytes
▸ fromBytes(bytes
):
VaultItemCollection
Deserializes the object from a byte array
Parameters
Name | Type |
---|---|
bytes |
Uint8Array |
Returns
Inherited from
Defined in
fromJSON
▸ fromJSON(json
):
VaultItemCollection
Deserializes the object from a JSON string
Parameters
Name | Type |
---|---|
json |
string |
Returns
Inherited from
Defined in
fromRaw
▸ fromRaw(raw
): VaultItemCollection
Restores propertiers from a raw object of the same form generated by
toRaw. The base implementation
blindly copies over values from the raw object via Object.assign
so subclasses
should explictly process any propertyies that need special treatment.
Also takes are of validation and "upgrading" in case the raw object has an old version. Use the protected _fromRaw method to implement subclass-specific behavior.
Parameters
Name | Type |
---|---|
raw |
any |
Returns
Inherited from
Defined in
get
▸ get(id
): null
| VaultItem
Get an item with a given id
Parameters
Name | Type |
---|---|
id |
string |
Returns
null
| VaultItem
Defined in
merge
▸ merge(coll
): void
Merges in changes from another VaultItemCollection instance.
Parameters
Name | Type |
---|---|
coll |
VaultItemCollection |
Returns
void
Defined in
remove
▸ remove(...items
): void
Removes one or more items based on their id.
Parameters
Name | Type |
---|---|
...items |
VaultItem [] |
Returns
void
Defined in
toBytes
▸ toBytes(): Uint8Array
Returns a serialization of the object in form of a byte array
Returns
Uint8Array
Inherited from
Defined in
toJSON
▸ toJSON(): string
Returns a JSON serialization of the object
Returns
string
Inherited from
Defined in
toRaw
▸ toRaw(version?
): any
Creates a raw javascript object representation of the class, which can be used for storage or data transmission. Also handles "downgrading" to previous versions. Use _toRaw for subclass-specific behavior.
Parameters
Name | Type |
---|---|
version? |
string |
Returns
any
Inherited from
Defined in
update
▸ update(...items
): void
Updates one or more items based on their id. If no item with the same id exists, the item will be added to the collection
Parameters
Name | Type |
---|---|
...items |
VaultItem [] |
Returns
void
Defined in
validate
▸ validate(): boolean
This is called during deserialization and should verify that all properties have been populated with values of the correct type. Subclasses should implement this method based on their class structure.
Returns
boolean