compile(cubes, errorReporter) { super.compile(cubes, errorReporter); const validCubes = this.cubeList.filter(cube => this.cubeValidator.isCubeValid(cube)); this.evaluatedCubes = R.fromPairs(validCubes.map(v => [v.name, v])); this.byFileName = R.groupBy(v => v.fileName, validCubes); this.primaryKeys = R.fromPairs(validCubes.map((v) => { const primaryKeyNameToSymbol = R.compose(R.find(d => d[1].primaryKey), R.toPairs)(v.dimensions || {}); return [ v.name, primaryKeyNameToSymbol && primaryKeyNameToSymbol[0] ]; })); }
removeBlockTransactionsFromTransactions(newBlock) { this.transactions = R.reject((transaction) => { return R.find(R.propEq('id', transaction.id), newBlock.transactions); }, this.transactions); this.transactionsDb.write(this.transactions); }
getBlockByIndex(index) { return R.find(R.propEq('index', index), this.blocks); }
getAddressByIndex(index) { return R.propOr(null, 'publicKey', R.find(R.propEq('index', index), this.keyPairs)); }
getWalletById(walletId) { return R.find((wallet) => { return wallet.id == walletId; }, this.wallets); }
let findInputTransactionInTransactionList = R.find( R.whereEq({ 'transaction': input.transaction,
getTransactionById(id) { return R.find(R.propEq('id', id), this.transactions); }
test('load commands with front matter', async () => { const dir = `${__dirname}/../fixtures/good-plugins/front-matter` const plugin = loadPluginFromDirectory(dir) expect(plugin.commands.length).toBe(1) // test the command const full = find(propEq('name', 'full'), plugin.commands) expect(full.name).toBe('full') expect(full.file).toBe(`${dir}/commands/full.js`) expect(typeof full.run).toBe('function') expect(await full.run()).toBe(123) })
const fromSchemeGetTileNameById = scheme => (id) => { if (id === 0x00) { return 'empty' } const tileName = scheme |> find(({ ids }) => ids.includes(id)) |> defaultTo({ name: 'unknown' }) |> prop('name') return tileName }
// finds if we want a type of the preceding expression // for example // add(2, 3) // :: // will be // add(2, 3) // :: number function findCommentType (s) { const typeStarts = ['::', ' ::'] return R.find(c => s.startsWith(c), typeStarts) }
getBlockByHash(hash) { return R.find(R.propEq('hash', hash), this.blocks); }
getAddressByPublicKey(publicKey) { return R.propOr(null, 'publicKey', R.find(R.propEq('publicKey', publicKey), this.keyPairs)); }
getSecretKeyByAddress(address) { return R.propOr(null, 'secretKey', R.find(R.propEq('publicKey', address), this.keyPairs)); }