var SMConsumer  =  require('source-map').SourceMapConsumer;

/**
 * @name mappingsFromMap
 * @function
 * @param map {Object} the JSON.parse()'ed map
 * @return {Array} array of mappings
 */
module.exports = function (map) {
  var consumer = new SMConsumer(map);
  var mappings = [];

  consumer.eachMapping(function (mapping) {
    // only set source if we have original position to handle edgecase (see inline-source-map tests)
    mappings.push({
      original: {
        column: mapping.originalColumn
      , line: mapping.originalLine
      }
    , generated: {
        column: mapping.generatedColumn
      , line: mapping.generatedLine
      }
    , source: mapping.originalColumn != null ? mapping.source : undefined
    , name: mapping.name
    });
  });

  return mappings;
}

var SMConsumer  =  require('source-map').SourceMapConsumer;

/**
 * @name mappingsFromMap
 * @function
 * @param map {Object} the JSON.parse()'ed map
 * @return {Array} array of mappings
 */
module.exports = function (map) {
  var consumer = new SMConsumer(map);
  var mappings = [];

  consumer.eachMapping(function (mapping) {
    // only set source if we have original position to handle edgecase (see inline-source-map tests)
    mappings.push({
      original: mapping.originalColumn != null ? {
        column: mapping.originalColumn
      , line: mapping.originalLine
      } : undefined
    , generated: {
        column: mapping.generatedColumn
      , line: mapping.generatedLine
      }
    , source: mapping.originalColumn != null ? mapping.source : undefined
    , name: mapping.name
    });
  });

  return mappings;
}

Fix original in map to pass validation.
Fix original in map to pass validation.

The generator _validateMapping function does not expect a mapping to contain `original` when `source` is undefined, but the code was passing in `{}`. This corrects the problem by ensuring original not defined when there is no source.
