code: function encodeBuffer(buf, options, cb) {
    if (typeof options === 'function') {
      cb = options;
      options = {};
    }
  
    try {
      buf = bufferUtils.toArrayLike(buf);
  
      if (!options.hasOwnProperty('width') || !options.hasOwnProperty('height')) {
        return cb(new Error('Provide width & height of the buffer'));
      }
  
      if (_hasWorker.hasWorker) {
        const wr = require('webworkify')(_encodeWorker2.default);
  
        wr.onmessage = ({ data: msg }) => {
          const err = msg.err ? new Error(msg.err) : undefined;
          cb(err, msg.result);
        };
  
        const msg = {
          buf: buf,
          options: options
        };
  
        if (options.transferable) {
          wr.postMessage(msg, [buf]);
        } else {
          wr.postMessage(msg);
        }
      } else {
        (0, _encode2.default)(buf, options, cb);
      }
    } catch (err) {
      cb(err);
    }
  }
docs: Encode
  
  @param {Buffer|ArrayBuffer|Uint8Array} buf
  @param {object} options Params { width: number, height: number, quality: number }
  @param {function} cb Callback to invoke on completion
  
  @callback { width: number, height: number, data: Uint8Array }