get contextList() { return R.keys(this.contextDefinitions); }
let doubleSpendingList = R.filter((x) => x >= 2, R.map(R.length, R.groupBy(x => x)(listOfTransactionIndexInputs))); if (R.keys(doubleSpendingList).length) { console.error(`There are unspent output transactions being used more than once: unspent output transaction: '${R.keys(doubleSpendingList).join(', ')}'`); throw new BlockAssertionError(`There are unspent output transactions being used more than once: unspent output transaction: '${R.keys(doubleSpendingList).join(', ')}'`);
const getSquashedScore = async (metrics) => ({ lighthouse: R.pipe( R.map((metric) => R.sum(R.values(metric))), R.sum, R.divide(R.__, R.length(metrics) * R.length(R.keys(R.head(metrics)))), R.curry(Math.round), )(metrics), })
// filter :: Object -> Object var filterObjIndexed = function filterObjIndexed(f, x) { return (0, _ramda.compose)((0, _ramda.reduce)(function (acc, k) { acc[k] = x[k];return acc; }, {}), (0, _ramda.filter)(function (k) { return f(x[k], k, x); }), _ramda.keys)(x); }
test('handles files with just a number', () => { const m = loadModule(`${__dirname}/../fixtures/bad-modules/number.js`) expect(typeof m).toBe('number') expect(keys(m)).toEqual([]) })
setInterval(() => { let addresses = R.keys(storage.servers) if (addresses.length) { let address = helper.randomItem(addresses) let server = storage.servers[address] if (server.rating > 0) { this.broadcast(CmdPacker.pack(CmdPacker.CMD_SRV_INFO, {isIpv6: server.isIpv6, port: server.port, address: address})) } } }, 30000)
const htmlReportsToFile = async (htmlReports, outputPath) => htmlReports.map((htmlReport) => { const url = R.head(R.keys(htmlReport)); if (htmlReport[url]) { const filepath = path.join(outputPath, `${urlEscaper(url)}.html`); fs.writeFile(filepath, htmlReport[url], (error) => statusMessage( `Saved report to ${filepath}\n`, `Failed to save report to ${outputPath}`, error, )); } return false; })
// transform data for the client var transformData = function(data) { var totals = totalsByDay(data); var dates = R.keys(totals); return averageForEachDay(dates, totals); }
// Mock i18n as it uses react native stuff // This mock returns the interpolated text from the english.json file in App/I18n // If you are not using '../App/I18n/english.json' for your I18n values, simply replace import english // with the import at the top of this file from '../App/I18n/english.json' with the I18n json file you // want to use, such as "import french from '../App/I18n/fr.json'" and set 'let value = french[key]` mockery.registerMock('react-native-i18n', { t: (key, replacements) => { let value = english[key] if (!value) return key if (!replacements) return value forEach((r) => { value = replace(`{{${r}}}`, replacements[r], value) }, keys(replacements)) return value } })
const unhealthyRules = input => ({ severity: [ [notNil, unhealthyCheckMessage("Severity is required")], [ oneOf(severities), unhealthyCheckMessage( `Severity should be one of ${R.keys(severities).join(", ")}` ) ] ], message: [ [isString, unhealthyCheckMessage("Message should be a string")], [notEmpty, unhealthyCheckMessage("Message is required")] ] })
const processRawLighthouseResult = async (data, url, shouldSaveReport) => { const htmlReport = shouldSaveReport ? ReportGenerator.generateReportHtml(data) : false; const { categories } = data; const scores = R.keys(categories).map((category) => ( { [`lighthouse ${category.toLowerCase()}`]: categories[category].score * 100 } )); const lighthouseMetrics = Object.assign({}, ...scores); return { metrics: lighthouseMetrics, report: { [url]: htmlReport } }; }
const getAverageScore = async (metrics) => R.pipe( R.head, R.keys, R.map((category) => ( { [category]: Math.round(R.sum(R.pluck(category, metrics)) / R.length(metrics)) })), R.mergeAll, )(metrics)
test('handles blank files', () => { const m = loadModule(`${__dirname}/../fixtures/bad-modules/blank.js`) expect(typeof m).toBe('object') expect(keys(m)).toEqual([]) })
test('handles files with an object', () => { const m = loadModule(`${__dirname}/../fixtures/bad-modules/object.js`) expect(typeof m).toBe('object') expect(keys(m)).toEqual([]) })
// filter :: Object -> Object var filterObjIndexed = function filterObjIndexed(f, x) { return (0, _ramda.compose)((0, _ramda.reduce)(function (acc, k) { acc[k] = x[k];return acc; }, {}), (0, _ramda.filter)(function (k) { return f(x[k], k, x); }), _ramda.keys)(x); }