var through = require('through')
  , streamline = require('streamline/lib/callbacks/transform')
  , SourceMapConsumer = require('source-map').SourceMapConsumer
  , SourceMapGenerator = require('source-map').SourceMapGenerator
  , path = require('path')

var re = /\._js$/

module.exports = function (file, options) {
  if (!re.test(file)) return through()

  options = options || {}

  var transformOptions =
    { 'callback': options.cb || options.callback
    , 'oldStyleFutures': options['old-style-futures'] || options.oldStyleFutures
    , 'promise': options.promise
    , 'sourceName': file
    , 'lines': 'sourcemap'
    }

  var buf = []
    , stream = through(write, end)

  return stream

  function write(chunk) {
    buf.push(chunk)
  }

  function end() {
    var source = buf.join('')
      , transformed = streamline.transform(source, transformOptions)
      , compiled = transformed.toStringWithSourceMap({ file: file })
      , consumer = new SourceMapConsumer(compiled.map.toString())
      , generator = new SourceMapGenerator({ file: file })

    generator.setSourceContent(file, source)

    consumer.eachMapping(function (mapping) {
      mapping.source = path.normalize(mapping.source || '')

      // Ignore mappings that are not from our source file
      if (!mapping.source || file !== mapping.source) return

      generator.addMapping(
        { original:
          { column: mapping.originalColumn
          , line: mapping.originalLine
          }
        , generated:
          { column: mapping.generatedColumn
          , line: mapping.generatedLine
          }
        , source: file
        , name: mapping.name
        }
      )
    })

    stream.queue(compiled.code)
    stream.queue('\n//@ sourceMappingURL=data:application/json;base64,')
    stream.queue(new Buffer(generator.toString()).toString('base64'))
    stream.queue(null)
  }
}

@@ -861,23 +861,199 @@
 ptions)%0A
+%0A
     
-  ,
+// https://github.com/Sage/streamlinejs/issues/251%0A    if (typeof transformed === 'string') %7B%0A      stream.queue(transformed)%0A      stream.queue(null)%0A      return%0A    %7D%0A%0A    var
  compile

Fix inconsistent transform behavior in streamline