How to use the kew.resolve function in kew

To help you get started, we’ve selected a few kew 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 volumio / Volumio2 / app / plugins / music_services / mpd / index.js View on Github external
})*/
			.then(libFast.bind(self.parseTrackInfo, self))
			.then(function(trackinfo) {
				collectedState.title = trackinfo.title;
				collectedState.artist = trackinfo.artist;
				collectedState.album = trackinfo.album;
				collectedState.albumart = trackinfo.albumart;
				return libQ.resolve(collectedState);
			});
			// Else return null track info
		} else {
			collectedState.title = null;
			collectedState.artist = null;
			collectedState.album = null;
			collectedState.albumart = null;
			return libQ.resolve(collectedState);
		}
	});
};
github volumio / Volumio2 / app / metadatacache.js View on Github external
.then(function() {
			// Then process the next task
			var curTask = self.arrayTaskStack.shift();
			var sTable = curTask.table;
			var sKey = curTask.key;
			var promisedSubTasks = libQ.resolve();

			if (!(sTable in self.metadataCache)) {
				self.metadataCache[sTable] = {};
			}

			if (!(sKey in self.metadataCache[sTable])) {
				self.metadataCache[sTable][sKey] = {};
			}

			// All objects will first get their MBID (Musicbrainz ID) stored
			var sType = self.musicLibrary.library[sTable][sKey].type;
			var sName = self.musicLibrary.library[sTable][sKey].name;
			if (!('mbid' in self.metadataCache[sTable][sKey])) {
				promisedSubTasks = promisedSubTasks
					.then(function() {
						return self.fetchMbid(sType, sName);
github tschaub / gulp-newer / index.js View on Github external
Newer.prototype._transform = function(srcFile, encoding, done) {
  if (!srcFile || !srcFile.stat) {
    done(new PluginError(PLUGIN_NAME, 'Expected a source file with stats'));
    return;
  }
  var self = this;
  Q.resolve([this._destStats, this._extraStats])
    .spread(function(destStats, extraStats) {
      if ((destStats && destStats.isDirectory()) || self._ext || self._map) {
        // stat dest/relative file
        var relative = srcFile.relative;
        var ext = path.extname(relative);
        var destFileRelative = self._ext
          ? relative.substr(0, relative.length - ext.length) + self._ext
          : relative;
        if (self._map) {
          destFileRelative = self._map(destFileRelative);
        }
        var destFileJoined = self._dest
          ? path.join(self._dest, destFileRelative)
          : destFileRelative;
        return Q.all([Q.nfcall(fs.stat, destFileJoined), extraStats]);
      } else {
github Medium / shepherd / lib / Graph.js View on Github external
function makeLiteralHandler(val) {
  val = val && val._literal ? val._literal : val

  // Wrap undefined in a promise so we know it's there
  var handlerVal = typeof val == 'undefined' ? Q.resolve(val) : val
  var fn = function () {
    return handlerVal
  }

  fn._literal = val
  return fn
}
github Medium / dynamite / test / testTypeUtil.js View on Github external
builder.add(function testAddToNullSet(test) {
  var set = null

  var additions = typeUtil.valueToObject([4])
  test.equal(typeUtil.objectToType(additions), 'NS')

  var modified = typeUtil.addToSet(set, additions)
  test.equal(typeUtil.objectToType(modified), 'NS')
  modified.NS.sort()

  test.deepEqual(modified.NS, [4].map(String))

  return Q.resolve()
})
github Medium / dynamite / test / testLocalUpdater.js View on Github external
"userId": "userA",
    "column": "@",
    "age": 29,
    "someStringSet": ['a', 'b', 'c']
  })

  var updated = localUpdater.update(data, {
    'someStringSet': {
      Action: 'PUT',
      Value: typeUtil.valueToObject(['b','c','d'])
    }
  })

  test.deepEqual(data.someStringSet.SS, ['a', 'b', 'c'], 'someStringSet should not change')
  test.deepEqual(updated.someStringSet.SS, ['b', 'c', 'd'], 'someStringSet should equal [\'b\', \'c\', \'d\']')
  return Q.resolve()
})
github Medium / phantomjs / lib / util.js View on Github external
return checkPhantomjsVersion(resolvedLocation).then(function (matches) {
          if (matches) {
            return kew.resolve(resolvedLocation)
          }
        })
      }
github volumio / Volumio2 / app / statemachine.js View on Github external
CoreStateMachine.prototype.resetVolumioState = function () {
	var self = this;

	return libQ.resolve()
		.then(function () {
			self.commandRouter.pushConsoleMessage('[' + Date.now() + '] ' + 'CoreStateMachine::resetVolumioState');
			self.currentStatus = 'stop';
			self.currentPosition = 0;
			self.currentSeek = 0;
			self.currentDuration = 0;
			self.currentTrackBlock = [];
			self.timeLastServiceStateUpdate = 0;
			this.currentTrackType = null;
			self.timerPlayback = null;
			self.currentTitle = null;
			self.currentArtist = null;
			self.currentAlbum = null;
			self.currentUri = null;
			self.currentAlbumArt = '/albumart';
			self.currentSampleRate = null;
github iotaweb / angular-hapi-couch / app / server.js View on Github external
if (numFiles > 0) {
                var file = payload['file0'];
                var destFile = app.upload.dir + '/' + file.name;
                var defer = Q.defer();
        
                fs.rename(file.path, destFile, function(error) {
                
                    if (error) return defer.reject(error);
                    doc.file.url = '/upload/' + file.name;
                    defer.resolve(doc);
                });
                return defer.promise;
            }
        }
        return Q.resolve(doc);
    };
github Medium / zcache / lib / CacheCluster.js View on Github external
function setValues(valueMap, keys, values) {
  for (var i = 0; i < keys.length; i++) {
    valueMap[keys[i]] = values[i]
  }
  return Q.resolve(values)
}

kew

a lightweight promise library for node

Apache-2.0
Latest version published 9 years ago

Package Health Score

59 / 100
Full package analysis