Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Iterator.prototype.next = function () {
var value = Promise.defer();
var done = Promise.defer();
this.context.value = value;
this.context.done = done;
this.fiber['value'] = value;
this.fiber['done'] = done;
// Run the fiber until it either yields a value or completes
this.fiber.run(this.context);
return { value: value.promise, done: done.promise };
};
export function stripWhitespaceFromFiles(gitStatusResults, stageChanges) {
const notificationDefer = Promise.defer();
const startTime = (new Date()).getTime();
let queue: Promise = Promise.resolve();
gitStatusResults.forEach((fileObj) => {
const isDeleted = fileObj.status.indexOf(Git.FILE_STATUS.DELETED) !== -1;
// strip whitespace if the file was not deleted
if (!isDeleted) {
// strip whitespace only for recognized languages so binary files won't get corrupted
const langId = LanguageManager.getLanguageForPath(fileObj.file).getId();
if (["unknown", "binary", "image", "markdown", "audio"].indexOf(langId) === -1) {
queue = queue.then(() => {
const clearWholeFile = fileObj.status.indexOf(Git.FILE_STATUS.UNTRACKED) !== -1 ||
fileObj.status.indexOf(Git.FILE_STATUS.RENAMED) !== -1;
function fetchProps(props, match) {
var newProps = {};
var deferreds = {};
var promises = {};
var tasks = {};
var name;
for (name in props) {
var m = isPromisePropRe.exec(name);
if (m) {
var promiseName = m[1];
var deferred = Promise.defer();
tasks[promiseName] = makeTask(props[name], deferred);
deferreds[promiseName] = deferred.promise;
} else {
newProps[name] = props[name];
}
}
// not *Promise props, shortcircuit!
if (Object.keys(deferreds).length === 0) {
return Promise.resolve(props);
}
var isFulfilled = true;
for (name in tasks) {
var promise = tasks[name](newProps, deferreds, match);
populated.push(id);
return tr.get(keyPath.concat(id));
}
return Promise.resolve(doc);
})).then(function(docs){
//
// Filter
//
return fns.filter(docs, args);
});
}else{
var tuple = keyPath.concat([args[0]]);
if(indexes.checkIndex(index, tuple)){
var defer = Promise.defer();
tr.operations.push(function(tr, fdb){
tuple.push(args[1]);
defer.resolve(fns.readIndex(fdb, tr, tuple));
return defer.promise;
});
this.selected.push(args[0]);
return defer.promise;
}else{
return tr.get(keyPath).then(function(docs){
_.each(docs, function(doc){
populated.push(doc._id);
});
return fns.filter(docs, args);
});
}
}
function q(output, input, channel, args) {
var deferred = Promise.defer()
, ourId = newId()
, results = []
, mapping = {}
, remaining = 0 // @todo pass expected number to query
function onMessage(theirId, serial, state, data) {
if (compareId(ourId, theirId) === 0) {
serial = serial.toString()
state = state.toString()
var mapped = mapping[serial]
if (!mapped) {
results.push(mapped = mapping[serial] = {
serial: serial
, state: state
Feeds.prototype.__fetchFeed = function (url, options) {
if (this.__abort) { return Promise.reject('aborting job'); }
const defer = Promise.defer();
let error = false,
articles = [],
actor; // queue of articles to buffer and filter before sending out.
let cfg = parseConfig(options);
if (typeof cfg === 'string') {
return Promise.reject(cfg);
}
this.debug('issuing request');
this.debug('FEED URL: ' + url);
try {
request(url)
proto.disconnect = function(){
if(!this.protocol){
return;
}
this.disconnectDeferred = P.defer();
this.protocol.disconnect();
return this.disconnectDeferred.promise;
};
function downloadLogFiles(progress) {
var deferred = Promise.defer(),
logfileProcessor = new LogfileProcessor(config);
log("Downloading logfiles from S3");
var promise = logfileProcessor.downloadLogfiles(tempFolder);
promise.then(function (lastProcessedKey) {
deferred.resolve();
});
if (progress) {
promise.progressed(function (value) {
process.stdout.write(value);
});
}
return deferred.promise;
var getBinaryLocal = function(file, cb) {
var fr = new FileReader();
var p = Promise.defer();
fr.onprogress = function(e) {
cb(e.loaded / e.total, e.loaded);
};
fr.onload = function(e) {
p.resolve(new LASFile(e.target.result));
};
fr.readAsArrayBuffer(file);
return p.promise.cancellable().catch(Promise.CancellationError, function(e) {
fr.abort();
throw e;
});
};
plugin.store = function(type, stream, meta) {
var resolver = Promise.defer()
var args = {
url: url.resolve(options.storageUrl, util.format('s/upload/%s', type))
}
var req = request.post(args, function(err, res, body) {
if (err) {
log.error('Upload to "%s" failed', args.url, err.stack)
resolver.reject(err)
}
else if (res.statusCode !== 201) {
log.error('Upload to "%s" failed: HTTP %d', args.url, res.statusCode)
resolver.reject(new Error(util.format(
'Upload to "%s" failed: HTTP %d'
, args.url
, res.statusCode