'use strict'

/**
 * Module dependencies
 */
const Pointer = require('./Pointer')

/**
 * Pointer mode
 */
const RECOVER = 1

/**
 * Mapping
 */
class Mapping extends Map {

  /**
   * Constructor
   */
  constructor (mapping) {
    super()

    // cast JSON Pointer strings to Pointer instances
    Object.keys(mapping).forEach(key => {
      let value = mapping[key]
      this.set(
        new Pointer(key, RECOVER),
        new Pointer(value, RECOVER)
      )
    })
  }

  /**
   * Map
   */
  map (target, source) {
    this.forEach((value, key) => {
      key.add(target, value.get(source))
    })
  }

  /**
   * Project
   */
  project (source, target) {
    this.forEach((value, key) => {
      value.add(target, key.get(source))
    })
  }

}

/**
 * Exports
 */
module.exports = Mapping

@@ -134,16 +134,136 @@
 Mapping%0A
+ *%0A * @class%0A * Defines a means to declaratively translate between object%0A * representations using JSON Pointer syntax.%0A
  */%0Aclas
@@ -318,82 +318,66 @@
    *
-/
 %0A  
-constructor (mapping) %7B%0A    super()%0A%0A    // cast JSON Pointer s
+ * @description Translate pointers from JSON S
 trings 
+in
 to P
@@ -387,17 +387,89 @@
 ter 
-instances
+objects%0A   * @param %7BObject%7D mapping%0A   */%0A  constructor (mapping) %7B%0A    super()%0A
 %0A   
@@ -660,16 +660,179 @@
   * Map%0A
+   *%0A   * @description Assign values from source to target by reading the mapping%0A   * from right to left.%0A   * @param %7BObject%7D target%0A   * @param %7BObject%7D source%0A
    */%0A  
@@ -868,34 +868,35 @@
 is.forEach((
-value, key
+right, left
 ) =%3E %7B%0A     
@@ -896,19 +896,20 @@
 %7B%0A      
-key
+left
 .add(tar
@@ -913,21 +913,21 @@
 target, 
-value
+right
 .get(sou
@@ -963,16 +963,179 @@
 Project%0A
+   *%0A   * @description Assign values from source to target by reading the mapping%0A   * from left to right.%0A   * @param %7BObject%7D source%0A   * @param %7BObject%7D target%0A
    */%0A  
@@ -1183,18 +1183,19 @@
 ch((
-value, key
+right, left
 ) =%3E
@@ -1203,21 +1203,21 @@
 %7B%0A      
-value
+right
 .add(tar
@@ -1221,19 +1221,20 @@
 target, 
-key
+left
 .get(sou

add jsdoc attributes to comments