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

TypeScript lodash.get类代码示例

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

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



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

示例1:

 return Array.from(input).sort((a: Object, b: Object) => {
   if (get(a, field) < get(b, field)) {
     return desc ? 1 : -1;
   }
   if (get(a, field) > get(b, field)) {
     return desc ? -1 : 1;
   }
   return 0;
 });
开发者ID:SirajAtDPS,项目名称:angular2-tv-tracker,代码行数:9,代码来源:orderBy.ts


示例2: visit

  visit(ast, 'heading', (node: any) => {
    const slug = get(node, 'data.id')
    const depth = get(node, 'depth')

    headings.push({
      depth,
      slug,
      value: humanize(slug),
    })
  })
开发者ID:leslieSie,项目名称:docz,代码行数:10,代码来源:Entry.ts


示例3: get

 fieldsToValidate.forEach((field) => {
   const vmFieldValue = get(vm, field, undefined);
   if (vmFieldValue !== undefined) {
     const fieldValidationResultsPromise = validationFn(vm, field, vmFieldValue);
     fieldValidationResultsPromises.push(fieldValidationResultsPromise);
   }
 });
开发者ID:Lemoncode,项目名称:lcFormValidation,代码行数:7,代码来源:validationsDispatcher.ts


示例4: return

 return (method, ...args) => {
   if (plugins && plugins.length > 0) {
     for (const plugin of plugins) {
       const fn = get(plugin, method)
       isFn(fn) && fn(...args)
     }
   }
 }
开发者ID:leslieSie,项目名称:docz,代码行数:8,代码来源:Plugin.ts


示例5: fromEditorConfig

export function fromEditorConfig(
	config: editorconfig.knownProps,
	defaults: TextEditorOptions
): TextEditorOptions {
	const resolved: TextEditorOptions = {
		tabSize: (config.indent_style === 'tab'
			? get(config, 'tab_width', config.indent_size)
			: get(config, 'indent_size', config.tab_width)
		)
	};
	if (get(resolved, 'tabSize') === 'tab') {
		resolved.tabSize = config.tab_width;
	}
	return {
		insertSpaces: config.indent_style
			? config.indent_style !== 'tab'
			: defaults.insertSpaces,
		tabSize: get(resolved, 'tabSize', defaults.tabSize)
	};
}
开发者ID:Bigous,项目名称:editorconfig-vscode,代码行数:20,代码来源:Utils.ts


示例6: find

const getParsedData = (ast: any) => {
  const node = find(ast, (node: any) => is('yaml', node))
  return get(node, `data.parsedValue`)
}
开发者ID:leslieSie,项目名称:docz,代码行数:4,代码来源:Entry.ts


示例7: get

 return [...(plugins || [])].reduce((obj: any, plugin) => {
   const fn = get(plugin, method)
   return fn && isFn(fn) ? fn(obj) : obj
 }, initial)
开发者ID:leslieSie,项目名称:docz,代码行数:4,代码来源:Plugin.ts


示例8: require

/**
 * Generates a Unicode table and feeds it into configured printer.
 *
 * Top-level arguments:
 *
 * @arg {Object[]} data - the records to format as a table.
 * @arg {Object} options - configuration for the table.
 *
 * @arg {Object[]} [options.columns] - Options for formatting and finding values for table columns.
 * @arg {function(string)} [options.headerAnsi] - Zero-width formattter for entire header.
 * @arg {string} [options.colSep] - Separator between columns.
 * @arg {function(row, options)} [options.after] - Function called after each row is printed.
 * @arg {function(string)} [options.printLine] - Function responsible for printing to terminal.
 * @arg {function(cells)} [options.printHeader] - Function to print header cells as a row.
 * @arg {function(cells)} [options.printRow] - Function to print cells as a row.
 *
 * @arg {function(row)|string} [options.columns[].key] - Path to the value in the row or function to retrieve the pre-formatted value for the cell.
 * @arg {function(string)} [options.columns[].label] - Header name for column.
 * @arg {function(string, row)} [options.columns[].format] - Formatter function for column value.
 * @arg {function(row)} [options.columns[].get] - Function to return a value to be presented in cell without formatting.
 *
 */
function table<T = { height?: number }>(
  out: Output,
  data: any[],
  options: TableOptions<T> = {},
) {
  const ary = require('lodash.ary')
  const defaults = require('lodash.defaults')
  const get = require('lodash.get')
  const identity = require('lodash.identity')
  const partial = require('lodash.partial')
  const property = require('lodash.property')
  const result = require('lodash.result')

  const defaultOptions = {
    colSep: '  ',
    after: () => {
      // noop
    },
    headerAnsi: identity,
    printLine: s => out.log(s),
    printRow(cells) {
      this.printLine(cells.join(this.colSep).trimRight())
    },
    printHeader(cells) {
      this.printRow(cells.map(ary(this.headerAnsi, 1)))
      this.printRow(cells.map(hdr => hdr.replace(/./g, '─')))
    },
  }

  const colDefaults = {
    format: value => (value ? value.toString() : ''),
    width: 0,
    label() {
      return this.key.toString()
    },

    get(row) {
      const path = result(this, 'key')
      const value = !path ? row : get(row, path)
      return this.format(value, row)
    },
  }

  function calcWidth(cell) {
    const lines = stripAnsi(cell).split(/[\r\n]+/)
    const lineLengths = lines.map(property('length'))
    return Math.max.apply(Math, lineLengths)
  }

  function pad(str: string, length: number) {
    const visibleLength = stripAnsi(str).length
    const diff = length - visibleLength

    return str + ' '.repeat(Math.max(0, diff))
  }

  function render() {
    let columns: Array<TableColumn<T>> =
      options!.columns || (Object.keys((data[0] as any) || {}) as any)

    if (typeof columns[0] === 'string') {
      columns = (columns as any).map(key => ({ key }))
    }

    let defaultsApplied = false
    for (const row of data) {
      row.height = 1
      for (const col of columns) {
        if (!defaultsApplied) {
          defaults(col, colDefaults)
        }

        const cell = col.get(row)

        col.width = Math.max(
          result(col, 'label').length,
          col.width || 0,
          calcWidth(cell),
//.........这里部分代码省略.........
开发者ID:dhruvcodeword,项目名称:prisma,代码行数:101,代码来源:table.ts


示例9: objPath

 return string.replace(/\{\{(.+?)\}\}/g, function () {
     return objPath(data, arguments[1], '');
 });
开发者ID:b-cuts,项目名称:browser-sync-core,代码行数:3,代码来源:404.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript lodash.includes类代码示例发布时间:2022-05-25
下一篇:
TypeScript takeRight.default函数代码示例发布时间: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