本文整理汇总了TypeScript中co.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了default函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: co
let getData = () => co(function *() {
try {
let current = yield remuWallet.getCurrentBlock();
let data1 = yield top1;
let data2 = yield top2;
let data3 = yield topgifts;
yield lastBlocks.map((b: any) => co(function *() {
const idty = yield remuWallet.getUID(b.issuer)
b.uid = (idty && idty.uid) || b.issuer.substr(0, 10)
return b;
}));
(current as any).uid = (yield remuWallet.getUID(current.issuer)).uid;
let remains = yield remuWallet.remains();
return {
key: remuWallet.pubkey,
current,
issuersCount: current.issuersCount,
issuersWeek: data2.length,
issuersFrame: current.issuersFrame,
remains: remains,
remains_days: (Math.floor(remains / (remuWallet.pay_per_block * Math.pow(10, current.unitbase))) * duniterServer.conf.avgGenTime / (3600 * 24)).toFixed(1),
pay_per_block: remuWallet.pay_per_block,
unitbase: current.unitbase,
blocks: lastBlocks,
top1: data1,
top2: data2,
topgifts: data3,
unit: PAY_UNIT
};
} catch (e) {
console.error(e);
}
});
开发者ID:duniter,项目名称:remuniter,代码行数:33,代码来源:webserver.ts
示例2: before
before(() => co(function*() {
s1 = NewTestingServer({
currency: 'currency_one',
pair: {
pub: 'HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd',
sec: '51w4fEShBk1jCMauWu4mLpmDVfHksKmWcygpxriqCEZizbtERA6de4STKRkQBpxmMUwsKXRjSzuQ8ECwmqN1u2DP'
}
});
s2 = NewTestingServer({
currency: 'currency_two',
pair: {
pub: 'DKpQPUL4ckzXYdnDRvCRKAm1gNvSdmAXnTrJZ7LvM5Qo',
sec: '64EYRvdPpTfLGGmaX5nijLXRqWXaVz8r1Z1GtaahXwVSJGQRn7tqkxLb288zwSYzELMEG5ZhXSBYSxsTsz1m9y8F'
}
});
cat1 = user('cat', { pub: 'HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd', sec: '51w4fEShBk1jCMauWu4mLpmDVfHksKmWcygpxriqCEZizbtERA6de4STKRkQBpxmMUwsKXRjSzuQ8ECwmqN1u2DP'}, { server: s1 });
tac1 = user('tac', { pub: '2LvDg21dVXvetTD9GdkPLURavLYEqP3whauvPWX4c2qc', sec: '2HuRLWgKgED1bVio1tdpeXrf7zuUszv1yPHDsDj7kcMC4rVSN9RC58ogjtKNfTbH1eFz7rn38U1PywNs3m6Q7UxE'}, { server: s1 });
toc2 = user('toc', { pub: 'DKpQPUL4ckzXYdnDRvCRKAm1gNvSdmAXnTrJZ7LvM5Qo', sec: '64EYRvdPpTfLGGmaX5nijLXRqWXaVz8r1Z1GtaahXwVSJGQRn7tqkxLb288zwSYzELMEG5ZhXSBYSxsTsz1m9y8F'}, { server: s2 });
tic2 = user('tic', { pub: 'DNann1Lh55eZMEDXeYt59bzHbA3NJR46DeQYCS2qQdLV', sec: '468Q1XtTq7h84NorZdWBZFJrGkB18CbmbHr9tkp9snt5GiERP7ySs3wM8myLccbAAGejgMRC9rqnXuW3iAfZACm7'}, { server: s2 });
yield s1.prepareForNetwork();
yield s2.prepareForNetwork();
// Publishing identities
yield cat1.createIdentity();
yield tac1.createIdentity();
yield cat1.join();
yield tac1.join();
yield toc2.createIdentity();
yield tic2.createIdentity();
yield toc2.join();
yield tic2.join();
}));
开发者ID:Kalmac,项目名称:duniter,代码行数:35,代码来源:documents-currency.ts
示例3: it
it('Transaction with wrong currency should be rejected', () => co(function*() {
try {
yield cat1.cert(tac1);
yield tac1.cert(cat1);
yield s1.commit();
yield s1.commit();
const current = yield s1.get('/blockchain/current');
const tx = cat1.makeTX(
[{
src: "1500:1:D:DKpQPUL4ckzXYdnDRvCRKAm1gNvSdmAXnTrJZ7LvM5Qo:1",
unlock: "SIG(0)"
}],
[{
qty: 1500,
base: 1,
lock: "XHX(8AFC8DF633FC158F9DB4864ABED696C1AA0FE5D617A7B5F7AB8DE7CA2EFCD4CB)"
}],
{
currency: "wrong_currency",
blockstamp: [current.number, current.hash].join('-')
});
yield s1.postRawTX(tx);
throw "Transaction should not have been accepted, since it has an unknown currency name";
} catch (e) {
should.exist(e.error);
e.should.be.an.Object();
e.error.message.should.match(/Signature from a transaction must match/);
}
}));
开发者ID:Kalmac,项目名称:duniter,代码行数:29,代码来源:documents-currency.ts
示例4: function
ws.on('message', function(message: any) {
console.log('received: %s', message);
co(function *() {
let toSend = yield getData();
ws.send(JSON.stringify(toSend));
});
});
开发者ID:duniter,项目名称:remuniter,代码行数:7,代码来源:webserver.ts
示例5: done
it('serial processing', (done) => {
const field: IField = {
id: 1,
name: 'test01'
};
co(function *() {
yield db.save(table, field);
const res1 = yield db.find(table, ['id = 1']);
expect(res1.id).to.be.eq(1);
expect(res1.name).to.be.eq('test01');
yield db.update(table, { name: 'updated' }, ['id = 1']);
const res2 = yield db.find(table, ['id = 1']);
expect(res2.id).to.be.eq(1);
expect(res2.name).to.be.eq('updated');
yield db.del(table, []);
yield done();
});
});
开发者ID:BcRikko,项目名称:node-sqliter,代码行数:25,代码来源:test.ts
示例6: it
it('should answer within 50ms for a basic PoW (warm)', () => co(function*(){
const start = Date.now()
yield master.proveByWorkers({
newPoW: {
block: {
number: 0
},
zeros: 0,
highMark: 'F',
conf: {
medianTimeBlocks: 1,
avgGenTime: 100,
cpu: 0.8,
prefix: '8'
},
pair: {
pub: 'HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd',
sec: '51w4fEShBk1jCMauWu4mLpmDVfHksKmWcygpxriqCEZizbtERA6de4STKRkQBpxmMUwsKXRjSzuQ8ECwmqN1u2DP'
},
turnDuration: 100
}
})
const delay = Date.now() - start
delay.should.be.below(50)
}))
开发者ID:duniter,项目名称:duniter,代码行数:25,代码来源:pow-1-cluster.ts
示例7: connection
wssBlock.on('connection', function connection(ws:any) {
co(function *() {
try {
currentBlock = yield server.dal.getCurrentBlockOrNull();
if (currentBlock) {
const blockDTO:BlockDTO = BlockDTO.fromJSONObject(currentBlock)
ws.send(JSON.stringify(block2HttpBlock(blockDTO)))
}
} catch (e) {
logger.error(e);
}
});
});
开发者ID:duniter,项目名称:duniter,代码行数:13,代码来源:bma.ts
注:本文中的co.default函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论