How to use the deferred.gate function in deferred

To help you get started, we’ve selected a few deferred examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github JamieMason / image-optimisation-tools-comparison / src / images.js View on Github external
exports.setLoss = function(results) {
    var measureImages = deferred.map(
        results.images,
        deferred.gate(function(result) {
            var original = results.imagesByToolByName.photoshop[result.name];
            return result.compareTo(original);
        }, 50)
    );
    return measureImages().then(function() {
        return results;
    });
};
github ebaauw / homebridge-hue / lib / HueBridge.js View on Github external
'%s: %s %s v%s, api v%s', this.name, this.manufacturer,
        this.model, obj.swversion, obj.apiversion
      )
      this.version = obj.apiversion
      this.config.nativeHomeKitLights = false
      this.config.nativeHomeKitSensors = false
      this.username = 'homebridgehue'
      break
    default:
      this.log.warn(
        '%s: warning: ignoring unknown bridge/gateway %j',
        this.name, obj
      )
      throw new Error('unknown bridge')
  }
  this.request = deferred.gate(
    this._request,
    this.platform.config.parallelRequests || this.config.parallelRequests
  )
  this.infoService = new Service.AccessoryInformation()
  this.serviceList.push(this.infoService)
  this.infoService
    .updateCharacteristic(Characteristic.Manufacturer, this.manufacturer)
    .updateCharacteristic(Characteristic.Model, this.model)
    .updateCharacteristic(Characteristic.SerialNumber, this.serialNumber)
    .updateCharacteristic(Characteristic.FirmwareRevision, this.version)
  this.obj = obj

  this.service = new my.Services.HueBridge(this.name)
  this.serviceList.push(this.service)
  this.service.getCharacteristic(my.Characteristics.Heartrate)
    .updateValue(this.state.heartrate)

deferred

Modular and fast Promises implementation

ISC
Latest version published 5 years ago

Package Health Score

65 / 100
Full package analysis