> For the complete documentation index, see [llms.txt](https://soufatn.gitbook.io/rxjs-book/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://soufatn.gitbook.io/rxjs-book/summary/observable/observable_instance_methods/tomap.md).

# toMap

Converts the observable sequence to a Map if it exists. Note that this only works in an ES6 environment or polyfilled.

## Arguments

1. `keySelector` *(`Function`)*: A function which produces the key for the Map.
2. `[elementSelector]` *(`Function`)*: An optional function which produces the element for the Map. If not present, defaults to the value from the observable sequence.

## Returns

*(`Observable`)*: An observable sequence with a single value of a Map containing the values from the observable sequence.

## Example
