Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
getRelationCount(settings, type) {
let counter, details;
const id = this.model.get('id');
if (_.isObject(settings)) {
const {query, label} = settings;
counter = query(id); // query is a function from id -> query
details = c => new CoreModel({parts: [label], id: label, displayName: label, count: c});
} else {
const path = this.schema.makePath(`${ type }.${ settings }`);
if (!__guard__(path.getType(), x => x.attributes.id)) { return Promise.resolve(true); } // Skip if no id.
counter = {select: [settings + '.id'], from: type, where: {id}};
details = c => new DetailsModel({path, count: c});
}
return this.service.count(counter)
.then(details)
.then(d => { if (d.get('count')) { return this.referenceFields.add(d); } });
}
};
end(forced = false) {
// Note: Order matters.
this.tearDown();
return Promise.resolve().then(() => {
if (this.delegate.didFinishTutorial) {
return this.delegate.didFinishTutorial(this, forced);
}
}).then(() => {
this._isActive = false;
});
}
function runTests(filenames, args, retry) {
if (filenames.length === 0) {
// All done!
return Promise.resolve({ pass: 0, fail: 0, pending: 0 });
}
var next = filenames.pop();
var tally = {};
return runTests(filenames, args, retry)
.then(function(results) {
[
'pass',
'fail',
'pending'
].forEach(function(key) {
tally[key] = results[key] || 0;
});
return runTest(next, args, retry);
})
Decision.prototype.execute = function (conversation, message) {
var me = this;
var id = this.decision(message, conversation.context);
var resolve = isPromise(id) ? id : Promise.resolve(id);
return resolve.then(function (id) {
var next = me.choices[id];
if (!next) {
// there is no match, fall back on the default choice
next = me.choices['default'];
}
if (!next) {
throw new Error('Block with id "' + id + '" not found');
}
return {
result: message,
block: next
};
const {Promise} = require('es6-promise');
const Options = require('../options');
const Page = require('../models/page');
const CACHES = {};
const ALREADY_DONE = Promise.resolve(true);
exports.getCache = function(query) {
let name;
const xml = query.toXML();
const { root } = query.service;
return CACHES[name = root + ':' + xml] != null ? CACHES[name] : (CACHES[name] = new ResultCache(query));
};
// TODO - make sure that the caches are informed of list change events.
exports.onListChange = function(listName) {
for (let name in CACHES) {
var needle;
const cache = CACHES[name];
if ((needle = listName, Array.from(listNamesFor(cache.query)).includes(needle))) {
cache.dropRows(); // we cannot rely on this cache if one of its queries has changed.
}
it('should be ok', function () {
return Promise.resolve('should be ok');
});
(content: string) => {
const parser: DOMParser = new DOMParser();
const xml: Document = parser.parseFromString(content, "text/xml");
const doc: IXmlElement = new IXmlElement(xml.documentElement);
return Promise.resolve(doc);
},
(err: any) => {
}
data.push(item);
});
lambda(data);
var nextCursor;
if (reverse) {
nextCursor = page.before;
} else {
nextCursor = page.after;
}
if (nextCursor !== undefined) {
return self._retrieveNextPage(nextCursor, reverse).then(self._consumePages(lambda, reverse));
} else {
return Promise.resolve();
}
};
};
runner.cancel = function () {
if (!task.promise) {
task.promise = Promise.resolve();
}
}
}).then(function(fileObjs){
if (!self.options.minify || self.options.dev) return Promise.resolve();
return self.minify(fileObjs);
});
};