當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript lodash.partialRight函數代碼示例

本文整理匯總了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);
}
開發者ID:convoyinc,項目名稱:redux-interactions,代碼行數:23,代碼來源:reducer.ts

示例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'
     }]);
 });
開發者ID:QuBaR,項目名稱:ng-table,代碼行數:18,代碼來源:tableDynamic.spec.ts

示例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);
開發者ID:BitGo,項目名稱:BitGoJS,代碼行數:44,代碼來源:recovery.ts

示例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)
開發者ID:bcherny,項目名稱:regress,代碼行數:31,代碼來源:index.ts


注:本文中的lodash.partialRight函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。