Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function init(configUpdates) {
config.update(configUpdates);
log.debug('Using configuration:', config);
const startTime = Date.now();
// Fetch the current vendor consent before initializing
return Promise.all([
readVendorConsentCookie(),
fetchPubVendorList()
])
.then(([vendorConsentData, pubVendorsList]) => {
const {vendors} = pubVendorsList || {};
// Check config for allowedVendorIds then the pubVendorList
const {allowedVendorIds: configVendorIds} = config;
const allowedVendorIds = configVendorIds instanceof Array && configVendorIds.length ? configVendorIds :
vendors && vendors.map(vendor => vendor.id);
// Initialize the store with all of our consent data
const store = new Store({
cmpVersion: CMP_VERSION,
cmpId: CMP_ID,
cookieVersion: COOKIE_VERSION,
const name = (root.getAttribute('is') || root.tagName).toLowerCase();
promises.push(window.customElements.whenDefined(name));
}
// Check all descending elements
for (let i = 0; i < elements.length; i++) {
const el = elements[i];
if (!el._componentReady) {
const name = (el.getAttribute('is') || el.tagName).toLowerCase();
promises.push(window.customElements.whenDefined(name));
}
}
// Call callback once all defined
if (promises.length) {
Promise.all(promises)
.then(() => {
onDefined(element instanceof HTMLElement && element || window);
})
.catch((err) => {
console.error(err);
});
}
else {
// Call callback by default if all defined already
onDefined(element instanceof HTMLElement && element || window);
}
}
// Notify listeners that the CMP is loaded
log.debug(`Successfully loaded CMP version: ${pack.version} in ${Date.now() - startTime}ms`);
cmp.isLoaded = true;
cmp.notify('isLoaded');
// Render the UI
const App = require('../components/app').default;
render(, document.body);
// Execute any previously queued command
cmp.commandQueue = commandQueue;
cmp.processCommandQueue();
// Request lists
return Promise.all([
fetchGlobalVendorList().then(store.updateVendorList),
fetchPurposeList().then(store.updateCustomPurposeList)
]).then(() => {
cmp.cmpReady = true;
cmp.notify('cmpReady');
}).catch(err => {
log.error('Failed to load lists. CMP not ready', err);
});
})
.catch(err => {
const displayName = element.type.displayName;
if (!displayName){
// TODO: Use Promise.reject and catch()
throw new Error('[React Component Data] When resolving component data recursively each component must have a displayName set.');
}
// Add to finalData array that will be returned
finalData[displayName] = newProps;
// Traverse children
// Component will use newProps returned by the query so we can find any children it might have as a result
return getDataFromTree(element, context, false, newProps);
})
});
return Promise.all(mappedQueries).then((values) => {
// Only return final data at top level
// Not inside recursive getDataFromTree calls
if (isTopLevel){
return finalData;
}
});
}
test('run test twice', function (t) {
var tes = Test('run test twice', function () {
assert(true);
});
Promise.all([
runFn(tes),
runFn(tes)
]).then(function() {
t.end();
});
});
return new Promise((resolve) => {
let result = true;
if (Array.isArray(children)) {
Promise.all(children.map(input => self.checkInput(input, dryRun))).then((data) => {
data.forEach((item) => {
if (!item) {
result = false;
}
});
resolve(result);
});
} else {
self.walk([children], dryRun).then(result => resolve(result));
}
});
}
for (j=0; j < dimensions.height; j += limit) {
phantomJsPage.clipRect = {
left: i,
top: j,
width: Math.min(limit, dimensions.width - i),
height: Math.min(limit, dimensions.height - j)
};
name = tempDir + '/cell_' + i + '_' + j + '.' + format;
phantomJsPage.render(name, format, quality);
filesCells.push(name);
}
filesColumns.push([]);
}
filesColumns.pop();
return Promise.all(filesColumns.map(function (cellFilenames, columnIndex) {
return Promise.all(cellFilenames.map(function (cellFilename) {
return childPromise('convert', [cellFilename, cellFilename + '.mpc']).then(function (code) {
return cellFilename + '.mpc';
});
})).then(function (cellFilenamesMpc) {
var columnFilenameMpc = tempDir + '/column_' + columnIndex + '.mpc';
return childPromise('convert', cellFilenamesMpc.concat(['-append', columnFilenameMpc])).then(function (code) {
return columnFilenameMpc;
});
});
})).then(function (columnFilenamesMpc) {
return childPromise('convert', columnFilenamesMpc.concat(['-quality', '' + quality, '+append', filename])).then(function (code) {
fs.removeTree(tempDir);
callback();
return filename;
});
function _loadDropboxTemplates (dropbox, u) {
const templatesPaths = cfg.get('BACKEND_DROPBOX_TEMPLATES_PATHS');
if (templatesPaths) {
const templatesPromises = [];
Object.keys(templatesPaths).forEach(function (key) {
templatesPromises.push(
dropbox.addTemplate(templatesPaths[key])
);
});
Promise.all(templatesPromises).then(function () {
resolveMode(dropbox, u);
});
} else {
resolveMode(dropbox, u);
}
}
validators.map(validator => (
Promise.all([
this.constructor.getValidator(validator, value, includeRequired),
]).then((data) => {
result.push({ input, result: data && data[0] });
input.validate(input.props.value, true, dryRun);
})
)),
);
new Promise((resolve) => {
const { value, validators } = input.props;
const result = [];
let valid = true;
const validations = Promise.all(
validators.map(validator => (
Promise.all([
this.constructor.getValidator(validator, value, includeRequired),
]).then((data) => {
result.push({ input, result: data && data[0] });
input.validate(input.props.value, true, dryRun);
})
)),
);
validations.then(() => {
result.forEach((item) => {
if (!item.result) {
valid = false;
this.errors.push(item.input);
}
});