function stream(params) {
  // Return stream
  return through2.obj(function (file, enc, cb) {
    if (file.isNull()) {
      return cb(null, file);
    }

    if (file.isStream()) {
      return this.emit('error', new PluginError('critical', 'Streaming not supported'));
    }

    Promise.resolve()
      .then(() => generate({...params, src: file}))
      .then(({css, html}) => {
        // Rename file if not inlined
        if (params.inline) {
          file.contents = Buffer.from(html);
        } else {
          file.path = replaceExtension(file.path, '.css');
          file.contents = Buffer.from(css);
        }

        cb(null, file);
      })
      .catch((error) => cb(new PluginError('critical', error.message)));
  });
}
Streams wrapper for critical

@param {object} params Critical options
@returns {stream} Gulp stream