lib/utils.js
function streamify (opts, transform) {
  return through2.obj(
    // (vfile: VinylFile, enc: String, cb: Function)
    (vfile, enc, cb) => {
      var contents = vfile.contents.toString(enc);
      var result;
      var onSuccess = (contents) => {
        vfile.contents = new Buffer(contents, enc); // eslint-disable-line node/no-deprecated-api
        // TODO: drop Node.js 4.x support, use `Buffer.from()` instead
        cb(null, vfile);
      };
      var onError = (err) => {
        cb(err);
      };
      try {
        result = transform({
          contents: contents,
          fetcher: opts.fetcher,
          filePath: vfile.path,
          index: opts.index
        });
      } catch (err) {
        onError(err);
        return;
      }
      if (isPromise(result)) {
        result
          .then(onSuccess)
          .catch(onError);
        return;
      }
      onSuccess(result);
    }
  );
}
function streamify (opts, transform) {
  return through2.obj(
    // (vfile: VinylFile, enc: String, cb: Function)
    (vfile, enc, cb) => {
      var contents = vfile.contents.toString(enc);
      var result;
      var onSuccess = (contents) => {
        vfile.contents = new Buffer(contents, enc); // eslint-disable-line node/no-deprecated-api
        // TODO: drop Node.js 4.x support, use `Buffer.from()` instead
        cb(null, vfile);
      };
      var onError = (err) => {
        cb(err);
      };
      try {
        result = transform({
          contents: contents,
          fetcher: opts.fetcher,
          filePath: vfile.path,
          index: opts.index
        });
      } catch (err) {
        onError(err);
        return;
      }
      if (isPromise(result)) {
        result
          .then(onSuccess)
          .catch(onError);
        return;
      }
      onSuccess(result);
    }
  );
}
streamify ({ index: FetcherIndex }, transform: Function) => Stream