• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript lodash.result函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中lodash.result函数的典型用法代码示例。如果您正苦于以下问题:TypeScript result函数的具体用法?TypeScript result怎么用?TypeScript result使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了result函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: explainTransaction

  /**
   * Explain/parse transaction
   * @param params
   * - txBase64: transaction encoded as base64 string
   * @returns {{displayOrder: [string,string,string,string,string], id: *, outputs: Array, changeOutputs: Array}}
   */
  explainTransaction(params) {
    const { txBase64 } = params;
    let tx;

    try {
      tx = new stellar.Transaction(txBase64);
    } catch (e) {
      throw new Error('txBase64 needs to be a valid tx encoded as base64 string');
    }
    const id = tx.hash().toString('hex');
    const explanation: any = {
      displayOrder: ['id', 'outputAmount', 'changeAmount', 'outputs', 'changeOutputs', 'fee', 'memo'],
      id,
      outputs: [],
      changeOutputs: [],
      memo: {}
    };

    // In a Stellar tx, the _memo property is an object with the methods:
    // value() and arm() that provide memo value and type, respectively.
    if (_.result(tx, '_memo.value') && _.result(tx, '_memo.arm')) {
      explanation.memo = {
        value: _.result(tx, '_memo.value').toString(),
        type: _.result(tx, '_memo.arm')
      };
    }

    let spendAmount = new BigNumber(0);
    // Process only operations of the native asset (XLM)
    const operations = _.filter(tx.operations, operation => !operation.asset || operation.asset.getCode() === 'XLM');
    if (_.isEmpty(operations)) {
      throw new Error('missing operations');
    }
    explanation.outputs = _.map(operations, operation => {
      // Get memo to attach to address, if type is 'id'
      const memoId = (_.get(explanation, 'memo.type') === 'id' && ! _.get(explanation, 'memo.value') ? `?memoId=${explanation.memo.value}` : '');
      const output = {
        amount: this.bigUnitsToBaseUnits(operation.startingBalance || operation.amount),
        address: operation.destination + memoId
      };
      spendAmount = spendAmount.plus(output.amount);
      return output;
    });

    explanation.outputAmount = spendAmount.toFixed(0);
    explanation.changeAmount = '0';

    explanation.fee = {
      fee: tx.fee.toFixed(0),
      feeRate: null,
      size: null
    };
    return explanation;
  }
开发者ID:BitGo,项目名称:BitGoJS,代码行数:60,代码来源:xlm.ts


示例2: handleError

  static handleError(err, res, config: Config) {
    var error = new Error(get(res, 'body.description') || get(err, 'response.statusText') || 'No error details available')

    if (res) {
      error['headers']    = res.headers
      error['object']     = res.body
      error['statusCode'] = res.statusCode
      error['statusText'] = res.statusText
      error['url']        = res.req.url
      error['method']     = res.req.method
      error['stack']      = err.stack
    }
    else {
      const errMsg = result(err, 'toString')
      error['statusCode'] = 500
      error['statusText'] = errMsg || 'Unknown error'
    }

    // session timed out, reset cookies and caches
    if (error['statusCode'] === 419) {
      Cache.instance.clear()
      config.clear()
    }

    if (config.settings.errorInterceptor) {
      if (config.settings.errorInterceptor(error)) return [true, error]
    }

    return [false, error]
  }
开发者ID:mediapeers,项目名称:chinchilla,代码行数:30,代码来源:tools.ts


示例3:

            .reduce(function(colorActions: ILineColorAction[], astNode: ILambdaScriptAstNode) {
                const color = colorMap[astNode.type];

                if (color) {
                    const colorFn = chalk[color].bind(chalk),
                        locKey = alternateLocMap[astNode.type] || 'loc',

                        // I'm just using _.result to avoid TS7017
                        loc: ILoc = _.result(astNode, locKey);

                    /**
                     * Originally, I just colored as soon as I found a node. However, this does not work,
                     * because other coloring may have occurred on the line already, which will offset our
                     * column indices. And it is not sufficient just to drop all color from the line and
                     * see what the length difference is, because some of that color could be *after* our
                     * column indices and thus irrelevant. To solve this, we will gather all the colorings
                     * we want to do, and then apply them in sorted order. This makes the offset caclulation trivial.
                     */
                    return colorActions.concat({
                        // I don't know why but jison does not 0-index the line number.
                        lineIndex: loc.first_line - 1,
                        colStart: loc.first_column,
                        colEnd: loc.last_column,
                        colorFn: colorFn
                    });
                }

                return colorActions;
            }, []),
开发者ID:NickHeiner,项目名称:lambdascript,代码行数:29,代码来源:get-highlighted-code.ts


示例4: handlePolling

export function handlePolling(url: string, settings: any, sendRequest: (url: string, settings: any) => any)
: Promise<ApiResponse> {
    const pollingDelay: number = result(settings, 'pollDelay');

    return new Promise((resolve, reject) => {
        setTimeout(() => {
            sendRequest(url, settings).then(resolve, reject);
        }, pollingDelay);
    });
}
开发者ID:gooddata,项目名称:gooddata-js,代码行数:10,代码来源:xhr.ts


示例5: it

	it('hashmap pode ter funçþes como propriedades', () => {
		let hash: any = {
			a: 'algum valor',
			b(): number {
				return 10;
			}
		}

		expect(hash.b()).to.equal(10);
		expect(_.result(hash, 'b')).to.equal(10);
	});
开发者ID:feliperohdee,项目名称:node-meetup-cheatsheet,代码行数:11,代码来源:hashmap.ts


示例6: constructor

 constructor(public appState: AppState) {
   this.currentLang = _.result(appState, "get('lang')", 'en_US');
 }
开发者ID:karnex47,项目名称:iaa,代码行数:3,代码来源:change-lang.component.ts


示例7: return

export const renderWhenTrue = (Component: JSX.Element | (() => JSX.Element)) => (trueStatement) => {
	return (trueStatement ? result({ Component }, 'Component') : null) as JSX.Element | JSX.Element[];
};
开发者ID:3drepo,项目名称:3drepo.io,代码行数:3,代码来源:rendering.ts



注:本文中的lodash.result函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript lodash.reverse函数代码示例发布时间:2022-05-25
下一篇:
TypeScript lodash.replace函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap