Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
loadBundle(name, retryLoad) {
const cachedPromise = this._getFromCache('bundle', name, retryLoad === RETRY_LOAD_SECRET);
if (cachedPromise) {
return cachedPromise;
}
const bundle = this._getBundle(name);
const dependencies = bundle.dependencies || [];
const dependencyPromises = dependencies.map((dependency) => this.loadBundle(dependency, retryLoad));
const assets = bundle.assets || [];
const assetPromises = assets.map((asset) => this.loadAsset(asset, retryLoad));
const bundlePromise = RSVP.allSettled([ ...dependencyPromises, ...assetPromises ]);
const bundleWithFail = bundlePromise.then((promises) => {
const rejects = promises.filter((promise) => promise.state === 'rejected');
const errors = rejects.map((reject) => reject.reason);
if (errors.length) {
// Evict rejected promise.
this._getFromCache('bundle', name, true);
throw new BundleLoadError(this, name, errors);
}
return name;
});
return this._setInCache('bundle', name, bundleWithFail);
},
fetchByQuery(store, query) {
const { id, backend } = query;
const queryAjax = this.ajax(this.urlForTransformations(backend, id), 'GET', this.optionsForQuery(id));
return allSettled([queryAjax]).then(results => {
// query result 404d, so throw the adapterError
if (!results[0].value) {
throw results[0].reason;
}
let resp = {
id,
name: id,
backend,
data: {},
};
results.forEach(result => {
if (result.value) {
if (result.value.data.roles) {
// TODO: Check if this is needed and remove if not
resp.data = assign({}, resp.data, { zero_address_roles: result.value.data.roles });
let store = this.get('clusterStore');
let catalog = this.get('catalog');
let deps = [];
let cluster = this.modelFor('authenticated.cluster').clone();
if ( cluster.systemStacks === null ) {
let def = JSON.parse(this.get(`settings.${C.SETTING.CLUSTER_TEMPLATE}`)) || {};
cluster.set('systemStacks', (def.systemStacks||[]).map((stack) => {
stack.type = 'stackConfiguration';
let extInfo = parseExternalId(stack.externalId);
deps.push(catalog.fetchTemplate(extInfo.templateId, false));
return store.createRecord(stack);
}));
}
return allSettled(deps).then(() => {
return this.get('catalog').fetchTemplates({plusInfra: true}).then((resp) => {
resp.cluster = cluster;
return resp;
});
});
},
});
getAllFavorites: task(function* () {
const anime = get(this, 'getFavorites').perform('Anime');
const manga = get(this, 'getFavorites').perform('Manga');
const chars = get(this, 'getFavorites').perform('Character');
return yield RSVP.allSettled([anime, manga, chars], 'Get Favorites');
}).drop().cancelOn('willDestroyElement'),
removeDependenciesFromProject: function(packages) {
var uninstallText = (packages.length > 1) ? 'uninstall dependencies' : 'uninstall dependency';
var packageArray = packages.map(function(pkg) { return pkg.name; });
this._writeStatusToUI(chalk.green, uninstallText, packageArray.join(', '));
var promises = packageArray.map(function(name) {
return runCommand('npm uninstall --save ' + name)();
});
return RSVP.allSettled(promises);
}
appendTo($element) {
let assets = this.get('assets');
if (this.get('dom')) {
this.get('dom').forEach(node => {
node.remove();
$element[0].appendChild(assets.cloneOrImport(node));
});
return RSVP.resolve();
}
let scriptsPromise = assets.applyScripts(this.get('pieces.scripts'));
Array.from(this.get('pieces.body').childNodes).forEach(child => {
$element[0].appendChild(assets.cloneOrImport(child));
});
return RSVP.allSettled([assets.applyStyles(this.get('pieces.styles'), $element[0]), scriptsPromise]);
}
});
cycleBreaker(function() {
return RSVP.allSettled(
compact(
flatten([
this.get('_contentResults').getEach('_promise'),
this.getEach('_promise')
])
)
);
})
).readOnly(),
getInstalledDevices(platforms) {
let promises = [];
if (platforms.includes('ios')) {
promises.push(listIOSDevices());
promises.push(listIOSEmulators());
}
if (platforms.includes('android')) {
promises.push(listAndroidDevices());
promises.push(listAndroidEmulators());
}
return RSVP.allSettled(promises).then((results) => {
return results.filter((r) => r.state === 'fulfilled')
.reduce((arr, result) => arr.concat(result.value), []);
});
},
const fetchSeverityScores = (anomalyIds) => {
if (anomalyIds.length) {
const anomalyPromiseHash = anomalyIds.map((id) => {
return RSVP.hash({
id,
score: fetch(`/dashboard/anomalies/score/${id}`).then(checkStatus)
});
});
return RSVP.allSettled(anomalyPromiseHash);
} else {
return RSVP.resolve([]);
}
};