本文整理汇总了TypeScript中lodash.partialRight函数的典型用法代码示例。如果您正苦于以下问题:TypeScript partialRight函数的具体用法?TypeScript partialRight怎么用?TypeScript partialRight使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了partialRight函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: reducer
// TODO: https://github.com/Microsoft/TypeScript/issues/4881
/**
* Shorthand for calling `addInteractionReducer` on an `Interactions`.
*
* For example:
*
* class Todos extends Interactions {
* initialState = []
*
* @reducer
* add(state, text, completed = false) {
* return [...state, {text, completed}];
* }
* }
*
*/
export default function reducer(target:any, key?:string, descriptor?:PropertyDescriptor):any {
if (typeof target === 'string') {
return _.partialRight(_applyReducer, target);
}
_applyReducer(target, key, descriptor);
}
示例2: it
it('should render select list return as an array', () => {
const inputs = tableElm.find('thead').find('tr').eq(1).find('th').eq(2).find('select');
const select = inputs.eq(0) as IAugmentedJQuery;
expect((select[0] as HTMLSelectElement).options.length).toBeGreaterThan(0);
const $column = (select.scope() as ColumnFieldContext).$column;
const plucker = _.partialRight(_.pick, ['id', 'title']);
const actual = _.map($column.data as SelectOption[], plucker);
expect(actual).toEqual([{
'id': '',
'title': ''
}, {
'id': 20,
'title': 'Christian'
}, {
'id': 21,
'title': 'Simon'
}]);
});
示例3: co
return co(function *() {
if (!this.txInfo) {
throw new Error('Could not find txInfo. Please build a transaction');
}
const incomplete = this.recoveryTx.buildIncomplete();
const txInfo: any = {
nP2SHInputs: 0,
nSegwitInputs: 0
};
for (const input of this.txInfo.inputs) {
if (input.chain === 10 || input.chain === 11) {
txInfo.nSegwitInputs++;
} else {
txInfo.nP2SHInputs++;
}
}
txInfo.nOutputs = 1;
txInfo.unspents = _.map(this.txInfo.inputs, _.partialRight(_.pick, ['chain', 'index', 'redeemScript', 'id', 'address', 'value']));
txInfo.changeAddresses = [];
txInfo.walletAddressDetails = {};
const feeInfo: any = {};
feeInfo.size = VirtualSizes.txOverheadSize + (VirtualSizes.txP2shInputSize * this.txInfo.inputs.length) +
VirtualSizes.txP2pkhOutputSize;
feeInfo.feeRate = this.feeRates[this.sourceCoin.type];
feeInfo.fee = Math.round(feeInfo.size / 1000 * feeInfo.feeRate);
feeInfo.payGoFee = 0;
feeInfo.payGoFeeString = '0';
return {
txHex: incomplete.toHex(),
txInfo: txInfo,
feeInfo: feeInfo,
walletId: this.wallet.id(),
amount: this.recoveryAmount,
address: this.recoveryAddress,
coin: this.sourceCoin.type
};
}).call(this).asCallback(callback);
示例4: fn
import {mean, partialRight, sum, unzip} from 'lodash'
export interface Result {
fn(x: number): number|void
r2: number|void
}
export interface LinearResult extends Result {
b: number|void
m: number|void
}
const square = partialRight(Math.pow, 2)
export function linear(...as: [number, number][]): LinearResult {
if (!as.length) {
return {
b: undefined,
m: undefined,
fn: () => undefined,
r2: undefined
}
}
const [xs, ys] = unzip(as)
const [sum_x, sum_y] = [xs, ys].map(sum)
const sum_x2 = sum(xs.map(_ => _*_))
const sum_xy = sum(as.map(([a, b]) => a * b))
const n = as.length
const mean_y = mean(ys)