Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async processStyles($, mathStyles) {
// Get highlight theme from configuration
const conf = await this.getConfig()
const highlightTheme = conf.highlight || DEFAULT_HIGHLIGHT_THEME
// Process html styles
const styles = await Promise.all([
mathStyles,
fileUtils.readFile(path.join(MARKDOWN_THEME_PATH, 'github.css')),
fileUtils.readFile(path.join(HIGHLIGHT_THEME_PATH, `${highlightTheme}.css`))
])
const styleHtml =
`<style>${styles.join('')}</style>` + `<div class="markdown-body">${$.html()}</div>`
debug('styleHtml: %s', styleHtml)
$.root().html(styleHtml)
// Change html classes to inline styles
const inlineStyleHtml = await inlineCss($.html(), {
url: '/',
removeStyleTags: true,
removeHtmlSelectors: true
})
$.root().html(inlineStyleHtml)
localforage.getItem('migratedPreferences').then(function (value) {
if (!value) {
Promise.all(_.keys(config.defaultPreferences).map(function (property) {
return localforage.getItem(property).then(function (value) {
// Migration from old preferences to new namespaced preferencs.
value = value ? value : config.defaultPreferences[property];
localforage.setItem(preferencesNamespace + property, value);
});
}));
localforage.setItem('migratedPreferences', true);
}
});
drawLabels() {
let texture = new Promise(resolve => {
THREE.ImageUtils.loadTexture('bm-fonts/lato.png', null, resolve);
});
let font = new Promise(resolve => {
loadFont('bm-fonts/Lato-Regular-64.fnt', (err, font) => {
resolve(font);
});
});
// Wait for the texture and font.
return Promise.all([texture, font]).spread((texture, font) => {
for (let c of countryJSON.features) {
if (!c.properties.anchor) continue;
// Get 3D anchor.
let [x, y, z] = utils.lonLatToXYZ(
c.properties.anchor[0],
c.properties.anchor[1]
);
let geometry = createText({
font: font,
text: c.properties.label,
});
let material = new THREE.MeshBasicMaterial({
tilenonsolid: 0,
tiletoobig: 0,
totalsize: 0
};
if (config.xy) {
// Yield all values under the original X,Y square
var mult = Math.pow(2, config.zoom - config.startZoom),
x = config.xy[0] * mult,
y = config.xy[1] * mult;
nextTile = sc.getOptimizedIteratorFunc(config.zoom, util.xyToIndex(x, y), Math.pow(4, config.zoom - config.startZoom));
} else {
nextTile = sc.getOptimizedIteratorFunc(config.zoom);
}
return BBPromise
.all(_.map(_.range(config.threads), renderTileAsync))
.then(function () {
config.reportStats(true);
config.zoom++;
if (config.zoom <= config.endZoom) {
return runZoom();
}
});
}
it('watch() - rename folder', () => {
const box = newBox('test');
const path = 'a/b.txt';
const src = pathFn.join(box.base, path);
const newPath = 'b/b.txt';
const newSrc = pathFn.join(box.base, newPath);
const cacheId = 'test/' + path;
const Cache = box.Cache;
const processor = sinon.spy();
box.addProcessor(processor);
return Promise.all([
fs.writeFile(src, 'a'),
Cache.insert({_id: cacheId})
]).then(() => box.watch()).then(() => fs.rename(pathFn.join(box.base, 'a'), pathFn.join(box.base, 'b'))).delay(500).then(() => {
const lastTwoCalls = processor.args.slice(processor.args.length - 2, processor.args.length);
lastTwoCalls.forEach(args => {
const file = args[0];
switch (file.type) {
case 'create':
file.source.should.eql(newSrc);
file.path.should.eql(newPath);
break;
case 'delete':
file.source.should.eql(src);
before(() => {
var dappName;
transactions = [];
return Promise.all(
_.range(maximum).map(num => {
dappName = randomUtil.applicationName();
var transaction = lisk.transaction.createDapp({
passphrase: accounts[num].passphrase,
options: {
name: dappName,
category: 1,
description: 'desc',
tags: '2',
type: 0,
link: `https://github.com/blocksafe/SDK-notice/${dappName}/master.zip`,
icon: `http://www.blocksafefoundation.com/${dappName}/header.jpg`,
},
});
transactions.push(transaction);
return sendTransactionsPromise([transaction]);
converter.fromFile(filename , (error, result) => {
if (error) reject(error);
else resolve(result);
});
});
while(fileContents.length > 0) {
const promises = fileContents.splice(0, 100).map(object => {
const {path, value} = object;
if (overwrite) {
return ref.child(path).set(value)
} else {
return setIfNull(path, value);
}
});
await Promise.all(promises);
}
}
let relation = this.modelClass.getRelations()[child.name];
if (!relation) {
throw new ValidationError({eager: 'unknown relation "' + child.name + '" in an eager expression'});
}
});
_.each(this.modelClass.getRelations(), relation => {
let nextEager = this.eager.childExpression(relation.name);
if (nextEager) {
promises.push(this._fetchRelation(relation, nextEager));
}
});
this.promise = Promise.all(promises).return(this.models);
return this.promise;
}
var fibonacci = function (n) {
if (n <= 1) {
return Promise.resolve(1);
} else {
return Promise.all([
fibonacci(n - 1),
fibonacci(n - 2)
])
.spread(function (lhs, rhs) {
return Promise.resolve(lhs + rhs);
});
}
}
'id',
'subdomain',
'domain',
'title',
'description',
'heroBackgroundImage',
'heroLogo',
'accentColor',
'accentTextColor',
'createdAt',
'updatedAt',
],
...whereQuery,
});
return Promise.all([getInitialData(req), getActiveCommunities])
.then(([initialData, activeCommunitiesData]) => {
const newInitialData = {
...initialData,
exploreData: { activeCommunities: activeCommunitiesData },
};
return renderToNodeStream(
res,