Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default async function (optionsStr = '') {
const splittedOptions = optionsStr.split(OPTIONS_SEPARATOR);
if (!splittedOptions.length)
return null;
const parsedOptions = {};
await Promise.all(splittedOptions.map(async item => {
const keyValuePair = item.split(OPTION_KEY_VALUE_SEPARATOR);
const key = keyValuePair[0];
let value = keyValuePair[1];
if (!key || !value)
return;
value = await ensureOptionValue(key, value);
parsedOptions[key] = value;
}));
return parsedOptions;
}
async function getAutomationApiInfo (automationApi) {
var automationApiData = await getAssetData([automationApi]);
var devicesData = await Promise.all(automationApiData.map(data => getDeviceData(automationApi, data)));
automationApiData = automationApiData
.map((data, index) => concatDeviceData(data, devicesData[index]))
.filter(data => data.length);
automationApiData = flatten(automationApiData);
return automationApiData
.map(data => formatAutomationApiData(automationApi, data))
.filter(data => data);
}
return this._delegateSyncBetweenWindowsToTop(cookies);
const windowsForSync = this._getWindowsForSync(initiator);
const syncMessages = [];
for (const win of windowsForSync) {
const cookieSandbox = WindowSync._getCookieSandbox(win);
if (cookieSandbox)
cookieSandbox.syncWindowCookie(cookies);
else
syncMessages.push(this._sendSyncMessage(win, SYNC_COOKIE_START_CMD, cookies));
}
if (syncMessages.length)
Promise.all(syncMessages).then(() => this._removeSyncCookie(cookies));
else
this._removeSyncCookie(cookies);
}
batchUpdate (): Promise {
const storedMessages = Transport._getStoredMessages();
if (storedMessages.length) {
const tasks = [];
nativeMethods.winLocalStorageGetter.call(window).removeItem(settings.get().sessionId);
for (const storedMessage of storedMessages)
tasks.push(this.queuedAsyncServiceMsg(storedMessage));
return Promise.all(tasks);
}
return Promise.resolve();
}
async _fetchPlatformInfoAndAliases () {
var automationApiInfoPromises = AUTOMATION_APIS.map(automationApi => getAutomationApiInfo(automationApi));
var platformsInfo = await Promise.all(automationApiInfoPromises);
this.platformsInfo = flatten(platformsInfo);
var unstructuredBrowserNames = this.platformsInfo
.map(platformInfo => this._createAliasesForPlatformInfo(platformInfo));
this.availableBrowserNames = flatten(unstructuredBrowserNames);
},
var resolve,
promise = new Pinkie(function(_resolve) {
resolve = _resolve;
});
Pinkie.all(data[key].map(function(val) {
return new Pinkie(function(_resolve) {
toResolve.push({ resolve : _resolve, val : val });
});
}))
.then(function(val) {
resolve(val);
});
topPromises.push(promise);
});
Pinkie.all(topPromises).then(function() {
deferred.resolve();
});
toResolve.forEach(function(obj) {
obj.resolve(obj.val);
});
},
Object.keys(data).forEach(function(key) {
var resolve,
promise = new Pinkie(function(_resolve) {
resolve = _resolve;
});
Pinkie.all(data[key].map(function(val) {
return new Pinkie(function(_resolve) {
toResolve.push({ resolve : _resolve, val : val });
});
}))
.then(function(val) {
resolve(val);
});
topPromises.push(promise);
});