string.js 422 B

1234567891011
  1. const PluginError = require('plugin-error');
  2. const through = require('through2');
  3. module.exports = function (handle) {
  4. return through.obj(function (file, enc, cb) {
  5. if (file.isNull()) return cb();
  6. if (file.isStream()) return this.emit('error', new PluginError('VM-json', 'Stream is not supported.'));
  7. if (handle) file.contents = new Buffer(handle(String(file.contents), file));
  8. cb(null, file);
  9. });
  10. };