Add 'size' getter to Y.Map

This commit is contained in:
Duane Johnson
2020-06-07 07:44:37 -06:00
parent 03faa27787
commit e53c01c6c5
2 changed files with 26 additions and 1 deletions

View File

@@ -115,6 +115,15 @@ export class YMap extends AbstractType {
return map
}
/**
* Returns the size of the YMap (count of key/value pairs)
*
* @return {number}
*/
get size () {
return [...createMapIterator(this._map)].length
}
/**
* Returns the keys for each element in the YMap Type.
*
@@ -143,7 +152,7 @@ export class YMap extends AbstractType {
}
/**
* Executes a provided function on once on overy key-value pair.
* Executes a provided function on once on every key-value pair.
*
* @param {function(T,string,YMap<T>):void} f A function to execute on every element of this YArray.
*/