Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const visitor: SpecificVisitor = (compiler, node) => {
let index = node.children.length
compiler.context.inTable = true
const result: string[][] = []
while (index--) {
result[index] = compiler.all(node.children[index])
}
compiler.context.inTable = false
const start = compiler.options.looseTable
? ''
: compiler.options.spacedTable ? '| ' : '|'
return table(result, {
align: node.align,
start,
end: start.split('').reverse().join(''),
delimiter: compiler.options.spacedTable ? ' | ' : '|',
})
}
const updateReadme = async () => {
let content = ''
for (const { document, sketchVersions } of [...versions].reverse()) {
content += `### Document ${document}\n\n`
content += `> Sketch versions: ${sketchVersions
.map(versionTuple => versionTuple[0])
.join(', ')}\n\n`
const repoUri = `https://github.com/sketch-hq/sketch-reference-files/tree/v${pkg.version}/files`
content += mdTable([
['Feature', 'Document', 'Pages', 'Meta', 'User'],
...features.map(feature => {
const exists = existsSync(`./files/${document}/${feature.id}`)
return exists
? [
feature.name,
`[🔗](${repoUri}/${document}/${feature.id}/document.json)`,
`[🔗](${repoUri}/${document}/${feature.id}/pages)`,
`[🔗](${repoUri}/${document}/${feature.id}/meta.json)`,
`[🔗](${repoUri}/${document}/${feature.id}/user.json)`,
]
: [feature.name, '-', '-', '-', '-']
}),
])
content += '\n\n'
}
suite.on('complete', function () {
const benchesByKey = this.reduce((result, bench) => {
result[testsByName[bench.name].key] = bench;
return result;
}, {});
const table = markdownTable([
['Test', 'Ops/Sec'],
...this.map(bench =>
[bench.name, Number(Math.round(bench.hz)).toLocaleString()]
)
], {
align: ['l', 'r']
});
output.push(table + '\n');
const comparisons = fp.flatten(Object.keys(benchesByKey)
.map(key => {
const test = testsByKey[key];
const bench = benchesByKey[key];
if (test.compare) {
return Object.keys(test.compare)
.map(otherKey => {
const compareBench = benchesByKey[otherKey];
handleClickCopyAsMarkdown() {
this.setState({ openShareFlyout: false });
electron.clipboard.writeText(markdownTable(this.getTableData()));
}
const child = childProcess.spawn('node', [_targetPath], {
stdio: 'inherit',
});
await sleep(2000)
benchmarksMDStream.write('\n')
benchmarksMDStream.write(`### ${lib}\n`)
benchmarksMDStream.write('\n')
const { requests, throughput } = await autocannon({
...opt,
url,
})
child.kill()
benchmarksMDStream.write(table([
['Stat', 'Avg', 'Stdev', 'Min'],
['Req/Sec', requests.average, requests.stddev, requests.min],
['Bytes/Sec', size(throughput.average), size(requests.stddev), size(requests.min)]
]))
benchmarksMDStream.write('\n')
benchmarksMDStream.write('\n')
}
toString() {
return markdownTable(this.table, this.options);
}
.map(({name, description}) => {
const mdHeader = `### ${description}`
const data = packagesByCategory.get(name) || []
const rawTable = [
['Package', 'Version', 'Dependencies'],
...data.map(pkg => [
`[\`${pkg.name}\`](${pkg.name})`,
npmVersionBadge(pkg.name),
npmDepsBadge(pkg.name),
]),
]
const mdTable = table(rawTable, {align: 'c'})
return `
${mdHeader}
${mdTable}
`
})
.join('\n')}
function getGithubCheckInfo(report) {
if (!report.checks.length) {
return {
title: 'No size check',
summary:
'There is no size check configured on the project. See [documentation to learn how to configure size checks](https://docs.bundle-analyzer.com).',
}
}
const table = markdownTable([
['Asset', 'Size', 'Max size', 'Status'],
...report.checks.map(check => [
check.name,
`${filesize(check.compareSize)} (${getCompressionLabel(
check.compareCompression,
)})`,
`${filesize(check.compareMaxSize)} (${getCompressionLabel(
check.compareCompression,
)}`,
check.conclusion,
]),
])
const title =
report.conclusion === 'success' ? 'Assets all good.' : 'Assets too big.'
return { title, summary: table }
}
const createMarkdownTable = (
perExamplePerfMeasures: PerExamplePerfMeasures,
metricName: MeasuredValues = 'actualTime',
fields: NumberPropertyNames[] = ['min', 'avg', 'median', 'max'],
) => {
const exampleMeasures = _.mapValues(
perExamplePerfMeasures,
exampleMeasure => exampleMeasure[metricName],
)
const fieldLabels: string[] = _.map(fields, _.startCase)
const fieldValues = _.mapValues(exampleMeasures, exampleMeasure =>
_.flatMap(fields, field => exampleMeasure[field]),
)
return markdownTable([
['Example', ...fieldLabels],
..._.map(exampleMeasures, (exampleMeasure, exampleName) => [
exampleName,
...fieldValues[exampleName],
]),
])
}
import mdtable from 'markdown-table'
import fs from 'fs'
import path from 'path'
import integrations from './integration-list'
const YES = ':white_check_mark:'
const NO = ':x:'
const table: string = mdtable([
['Name', 'iOS', 'Android', 'npm package'],
...integrations
.sort((a, b) => a.name.localeCompare(b.name))
.map(({ name, npm, android, ios }) => [
`[${name}](https://www.npmjs.com/package/${npm.package})`,
ios.disabled ? NO : YES,
android.disabled ? NO : YES,
'`' + npm.package + '`'
])
])
const readme = path.resolve(__dirname, '../../../README.md')
fs.writeFileSync(
readme,
fs