A JavaScript function that associates or "maps" a value with a key and emits the key and value pair.

The map function has the following requirements:

  *  In the map function, reference the current document as this within the function.

  *  The map function should not access the database for any reason.

  *  The map function should be pure, or have no impact outside of the function (i.e. side effects.)

  *  A single emit can only hold half of MongoDB's maximum BSON document size.

  *  The map function may optionally call emit(key,value) any number of times to create an output document associating key with value.
