code: function threshold (threshold, options) {
    if (!is.defined(threshold)) {
      this.options.threshold = 128;
    } else if (is.bool(threshold)) {
      this.options.threshold = threshold ? 128 : 0;
    } else if (is.integer(threshold) && is.inRange(threshold, 0, 255)) {
      this.options.threshold = threshold;
    } else {
      throw new Error('Invalid threshold (0 to 255) ' + threshold);
    }
    if (!is.object(options) || options.greyscale === true || options.grayscale === true) {
      this.options.thresholdGrayscale = true;
    } else {
      this.options.thresholdGrayscale = false;
    }
    return this;
  }
docs: Any pixel value greather than or equal to the threshold value will be set to 255, otherwise it will be set to 0.
  @param {Number} [threshold=128] - a value in the range 0-255 representing the level at which the threshold will be applied.
  @param {Object} [options]
  @param {Boolean} [options.greyscale=true] - convert to single channel greyscale.
  @param {Boolean} [options.grayscale=true] - alternative spelling for greyscale.
  @returns {Sharp}
  @throws {Error} Invalid parameters