本文整理汇总了TypeScript中filter-object类的典型用法代码示例。如果您正苦于以下问题:TypeScript filter-object类的具体用法?TypeScript filter-object怎么用?TypeScript filter-object使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了filter-object类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: getPREPostOBJ
async function getPREPostOBJ() {
const curRound = roundsLogic.calcRound(blocksModule.lastBlock.height);
const preOBJ = await getmappedDelObj();
const toMine = roundsLogic.lastInRound(curRound) - blocksModule.lastBlock.height;
for (let i = 0; i < toMine - 1; i++) {
await initializer.rawMineBlocks(1);
expect(filterObject(preOBJ, ['!*.mb', '!*.pb']))
.to.be.deep.eq(filterObject(await getmappedDelObj(), ['!*.mb', '!*.pb']));
}
const preLastBlock = await getmappedDelObj();
await initializer.rawMineBlocks(1);
const postOBJ = await getmappedDelObj();
// should contain same delegates (even if sorted in another order)
expect(Object.keys(preOBJ).sort()).to.be.deep.eq(Object.keys(postOBJ).sort());
expect(preOBJ).to.not.be.deep.eq(postOBJ);
expect(preLastBlock).to.not.be.deep.eq(postOBJ);
return { preOBJ, preLastBlock, postOBJ };
}
开发者ID:RiseVision,项目名称:rise-node,代码行数:20,代码来源:rounds.spec.ts
示例2: createRandomAccountWithFunds
it('should account them properly', async () => {
await createRandomAccountWithFunds();
const curRound = roundsLogic.calcRound(blocksModule.lastBlock.height);
const lastHeight = roundsLogic.lastInRound(curRound);
const delegatesObj = await getmappedDelObj();
// on pre everything is still the same.
await initializer.rawMineBlocks(lastHeight - blocksModule.lastBlock.height - 1);
expect(filterObject(await getmappedDelObj(), ['!*.pb'])).deep.eq(filterObject(delegatesObj, ['!*.pb']));
await initializer.rawMineBlocks(1);
const lastGeneratorPublic = blocksModule.lastBlock.generatorPublicKey.toString('hex');
const afterApply = await getmappedDelObj();
const feeDecimal = Math.floor(1e7 / 101);
const feeReminder = 1e7 - Math.floor(1e7 / 101) * 101;
let delegateReplaced = null;
for (let i = 1; i <= 101; i++) {
const delegate = `genesisDelegate${i}`;
let totalAmount = delegatesObj[delegate].bala + 15 * 1e8 + feeDecimal;
if (afterApply[delegate].pk === lastGeneratorPublic) {
totalAmount += feeReminder;
}
if (afterApply[delegate].bala !== totalAmount ) {
if (delegateReplaced) {
throw new Error('A delegate was replaced already by outsider');
}
delegateReplaced = delegate;
}
}
if (delegateReplaced) {
expect(afterApply['outsider'].bala).eq(delegatesObj.outsider.bala + 15 * 1e8 + feeDecimal);
}
// It should re-store object as it was before mining last block in round
await initializer.rawDeleteBlocks(1);
expect(filterObject(await getmappedDelObj(), ['!*.pb'])).deep.eq(filterObject(delegatesObj, ['!*.pb']));
});
开发者ID:RiseVision,项目名称:rise-node,代码行数:38,代码来源:dposv2.spec.ts
示例3: it
it('should return an array of accounts', async () => {
sandbox.stub(accounts2multisignaturesModel, 'findAll').resolves([{ accountId: '1' }, { accountId: '2' }, { accountId: '3' }]);
result = await instance.getAccounts({ publicKey: '123' });
const accounts = [];
accounts.push(filterObject({ ...account1.toPOJO(), ...{ multisigaccounts: [filterObject(account3.toPOJO(), '!secondPublicKey')] } }, ['!publicKey', '!secondPublicKey']));
accounts.push(filterObject({ ...account2.toPOJO(), ...{ multisigaccounts: [filterObject(account4.toPOJO(), '!secondPublicKey')] } }, ['!publicKey', '!secondPublicKey']));
expect(result).to.deep.equal({ accounts });
expect(accountsModuleStub.stubs.getAccounts.callCount).to.equal(3);
expect(accountsModuleStub.stubs.getAccounts.args[0][0]).to.deep.equal({
address: { $in: ['1', '2', '3'] },
sort : 'balance',
});
expect(accountsModuleStub.stubs.getAccounts.args[0][1]).to.deep.equal([
'address',
'balance',
'multisignatures',
'multilifetime',
'multimin',
]);
expect(accountsModuleStub.stubs.getAccounts.args[1][0]).to.deep.equal({
address: { $in: [1000, 1000, 1000] },
});
expect(accountsModuleStub.stubs.getAccounts.args[1][1]).to.deep.equal([
'address',
'publicKey',
'balance',
]);
expect(accountsModuleStub.stubs.getAccounts.args[1][0]).to.deep.equal({
address: { $in: [1000, 1000, 1000] },
});
expect(accountsModuleStub.stubs.getAccounts.args[1][1]).to.deep.equal([
'address',
'publicKey',
'balance',
]);
});
开发者ID:RiseVision,项目名称:rise-node,代码行数:38,代码来源:multisignatureAPI.spec.ts
示例4: expect
expect(ret.delegates.map((d) => filterObject(d, ['approval', 'rank', 'rate'])))
开发者ID:RiseVision,项目名称:rise-node,代码行数:1,代码来源:delegatesAPI.spec.ts
注:本文中的filter-object类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论