本文整理汇总了TypeScript中lodash.valuesIn函数的典型用法代码示例。如果您正苦于以下问题:TypeScript valuesIn函数的具体用法?TypeScript valuesIn怎么用?TypeScript valuesIn使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了valuesIn函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: fieldMap
export function insertQuery<F> (v: Model<F> | IResourceObject) {
const id = v.id
if (!id) {
throw ErrIDRequired
}
const map = fieldMap(v, { id })
return SqlString.format(
`INSERT INTO ?? (??) VALUES (?);`,
[ tableName(v), _.keysIn(map), _.valuesIn(map) ]
)
}
开发者ID:perpengt,项目名称:jsonapi,代码行数:11,代码来源:query.ts
示例2: it
it("delete Widget", function () {
const store = Store.createEmpty({log: false});
store.dispatch(Widgets.addWidget("my-widget-type", {foo: "bar"}, 1, 2, 3, 4));
assert.equal(_.keysIn(store.getState().widgets).length, 1);
_.valuesIn(store.getState().widgets).forEach((widget: Widgets.IWidgetState) => {
store.dispatch(Widgets.deleteWidget(widget.id));
});
assert.equal(_.keysIn(store.getState().widgets).length, 0);
});
开发者ID:Niondir,项目名称:iot-dashboard,代码行数:13,代码来源:widgets.test.ts
示例3: getParticipantEthFees
async function getParticipantEthFees(db: Knex, augur: Augur, reporter: Address, universe: Address): Promise<Array<ParticipantEthFee>> {
const participantQuery = db
.select([
"participantAddress",
"feeToken.feeWindow",
"feeToken.token as feeToken",
"reporterBalance",
"participantSupply",
"forking",
"reputationToken",
"reputationTokenBalance",
db.raw("IFNULL(feeToken.balance,0) as feeTokenBalance"),
db.raw("IFNULL(feeToken.supply,0) as feeTokenSupply"),
db.raw("IFNULL(cashFeeWindow.balance,0) as cashFeeWindow"),
db.raw("IFNULL(cashParticipant.balance,0) as cashParticipant"),
db.raw("IFNULL(participationTokenSupply.supply,0) as participationTokenSupply"),
"disavowed",
])
.from("all_participants");
participantQuery.join("fee_windows", "all_participants.feeWindow", "fee_windows.feeWindow");
participantQuery.leftJoin("balances_detail as feeToken", function() {
this.on("feeToken.owner", db.raw("all_participants.participantAddress")).andOn("feeToken.symbol", db.raw("?", "FeeToken"));
});
participantQuery.leftJoin("balances AS cashFeeWindow", function() {
this.on("cashFeeWindow.owner", db.raw("feeToken.feeWindow")).on("cashFeeWindow.token", db.raw("?", getCashAddress(augur)));
});
participantQuery.leftJoin("balances AS cashParticipant", function() {
this.on("cashParticipant.owner", db.raw("participantAddress")).andOn("cashParticipant.token", db.raw("?", getCashAddress(augur)));
});
participantQuery.leftJoin("token_supply as participationTokenSupply", "participationTokenSupply.token", "feeToken.feeWindow");
participantQuery.where("all_participants.universe", universe);
participantQuery.where("all_participants.reporter", reporter);
participantQuery.whereNot("all_participants.participantSupply", "0");
participantQuery.whereNot("all_participants.reporterBalance", "0");
participantQuery.whereRaw("(reportingState IN (?, ?) OR ((disavowed != 0 or all_participants.needsDisavowal) AND (fee_windows.state = ? OR reportingState = ?)))", [
ReportingState.AWAITING_FINALIZATION,
ReportingState.FINALIZED,
FeeWindowState.PAST,
ReportingState.AWAITING_FORK_MIGRATION,
]);
const participantEthFeeRows: Array<ParticipantEthFeeRow> = await participantQuery;
const participantEthFeesOnWindow = _.map(
participantEthFeeRows,
(ethFeeRows): ParticipantEthFee => {
const totalFeeTokensInFeeWindow = new BigNumber(ethFeeRows.feeTokenSupply).plus(new BigNumber(ethFeeRows.participationTokenSupply));
const participantShareOfFeeWindow = totalFeeTokensInFeeWindow.isZero() ? ZERO : new BigNumber(ethFeeRows.feeTokenBalance).dividedBy(totalFeeTokensInFeeWindow);
const cashInFeeWindow = new BigNumber(ethFeeRows.cashFeeWindow);
const participantEthFees = participantShareOfFeeWindow.times(cashInFeeWindow);
const reporterShareOfParticipant = new BigNumber(ethFeeRows.reporterBalance).dividedBy(ethFeeRows.participantSupply);
const ethFees = reporterShareOfParticipant.times(participantEthFees);
return {
participantAddress: ethFeeRows.participantAddress,
feeWindow: ethFeeRows.feeWindow,
ethFees,
fork: ethFeeRows.forking,
};
},
);
// keyBy/valuesIn reduces down to a single object per participantAddress
const cashBalanceByParticipant: Array<ParticipantEthFeeRow> = _.valuesIn(_.keyBy(participantEthFeeRows, "participantAddress"));
const participantEthFeesOnParticipant: Array<ParticipantEthFee> = _.map(cashBalanceByParticipant, (ethFeeRows) => {
const reporterShareOfParticipant = new BigNumber(ethFeeRows.reporterBalance).dividedBy(ethFeeRows.participantSupply);
const participantEthFees = new BigNumber(ethFeeRows.cashParticipant);
const ethFees = reporterShareOfParticipant.times(participantEthFees);
return {
participantAddress: ethFeeRows.participantAddress,
feeWindow: null,
ethFees,
fork: ethFeeRows.forking,
};
});
return participantEthFeesOnWindow.concat(participantEthFeesOnParticipant);
}
开发者ID:AugurProject,项目名称:augur_node,代码行数:73,代码来源:get-reporting-fees.ts
注:本文中的lodash.valuesIn函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论