Code coverage report for lib/infer/return.js

Statements: 100% (9 / 9)      Branches: 100% (6 / 6)      Functions: 100% (2 / 2)      Lines: 100% (9 / 9)      Ignored: none     

All files » lib/infer/ » return.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29    25                     25 64 139 75   64 64   3       64      
'use strict';
 
var finders = require('./finders'),
  shouldSkipInference = require('./should_skip_inference'),
  flowDoctrine = require('../flow_doctrine');
 
/**
 * Infers returns tags by using Flow return type annotations
 *
 * @name inferReturn
 * @param {Object} comment parsed comment
 * @returns {Object} comment with return tag inferred
 */
module.exports = function () {
  return shouldSkipInference(function inferReturn(comment) {
    if (comment.returns) {
      return comment;
    }
    var fn = finders.findType(comment.context.ast, 'Function');
    if (fn.returnType &&
      fn.returnType.typeAnnotation) {
      comment.returns = [{
        type: flowDoctrine(fn.returnType.typeAnnotation)
      }];
    }
    return comment;
  });
};