Code coverage report for lib/input/shallow.js

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

All files » lib/input/ » shallow.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 30 31 32 33    26                                     26 9 10 9         1      
'use strict';
 
var fs = require('fs');
 
/**
 * A readable source for content that doesn't do dependency resolution, but
 * simply reads files and pushes them onto a stream.
 *
 * If an array of strings is provided as input to this method, then
 * they will be treated as filenames and read into the stream.
 *
 * If an array of objects is provided, then we assume that they are valid
 * objects with `source` and `file` properties, and don't use the filesystem
 * at all. This is one way of getting documentation.js to run in a browser
 * or without fs access.
 *
 * @param {Array<string|Object>} indexes entry points
 * @param {Object} options parsing options
 * @param {Function} callback called with (err, inputs)
 * @return {undefined} calls callback
 */
module.exports = function (indexes, options, callback) {
  return callback(null, indexes.map(function (index) {
    if (typeof index === 'string') {
      return {
        source: fs.readFileSync(index, 'utf8'),
        file: index
      };
    }
    return index;
  }));
};