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

TypeScript lodash.findKey函数代码示例

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

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



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

示例1: getMatchRequest

/**
 * 返回匹配的请求后缀和请求类型
 * ① 通过扩展名匹配,优先返回与扩展名匹配的`后缀`和`请求类型`
 * ② 未匹配到,默认是`.js 后缀` 和`REQUEST_JS 请求类型`
 *
 * @param {string} request
 * @param {RequestType} [requestType]
 * @returns {{exts: string[], requestType: RequestType}}
 */
function getMatchRequest (request: string, requestType?: RequestType): {lookupExts: string[], requestType: RequestType} {
  let ext = path.extname(request)
  let exts: string[] = []

  // 非白名单内的扩展名,默认通过 requestType 来获取 ext 扩展名
  if (ext) {
    ext = _.findKey(config.ext, value => value === ext) ? ext : ''
  }

  if (!ext && !requestType) {
    throw new Error(`Ext 和 RequestType 不能同时为空`)
  }

  if (ext && requestType) {
    if (getRequestType(ext) !== requestType) {
      throw new Error(`Ext 和 RequestType 同时存在,但通过 Ext 找到的 RequestType 与实际的不符合`)
    }
  } else if (!ext && requestType) {
    exts = [
      ...exts,
      ...getRequestLookupExts(requestType)
    ]
  } else if (ext && !requestType) {
    requestType = getRequestType(ext)
  }

  if (!requestType) {
    throw new Error('没有找到匹配的 RequestType,请确认是否将 Ext 与 RequestType 进行关联')
  }

  return {
    lookupExts: exts,
    requestType
  }
}
开发者ID:bbxyard,项目名称:bbxyard,代码行数:44,代码来源:resolveDep.ts


示例2: parse

export function parse(
  schema: JSONSchema | JSONSchema4Type,
  options: Options,
  rootSchema = schema as JSONSchema,
  keyName?: string,
  isSchema = true,
  processed: Processed = new Map<JSONSchema | JSONSchema4Type, AST>(),
  usedNames = new Set<string>()
): AST {

  // If we've seen this node before, return it.
  if (processed.has(schema)) {
    return processed.get(schema)!
  }

  const definitions = getDefinitions(rootSchema)
  const keyNameFromDefinition = findKey(definitions, _ => _ === schema)

  // Cache processed ASTs before they are actually computed, then update
  // them in place using set(). This is to avoid cycles.
  // TODO: Investigate alternative approaches (lazy-computing nodes, etc.)
  let ast = {} as AST
  processed.set(schema, ast)
  const set = (_ast: AST) => Object.assign(ast, _ast)

  return isSchema
    ? parseNonLiteral(schema as SchemaSchema, options, rootSchema, keyName, keyNameFromDefinition, set, processed, usedNames)
    : parseLiteral(schema, keyName, keyNameFromDefinition, set)
}
开发者ID:bcherny,项目名称:json-schema-to-typescript,代码行数:29,代码来源:parser.ts


示例3: formatType

 private formatType(status: string): NotificationType {
   const types = {
     error: ['firing', 'active'],
     info: ['suppressed', 'unprocessed'],
     success: ['resolved']
   };
   return NotificationType[_.findKey(types, (type) => type.includes(status))];
 }
开发者ID:ceph,项目名称:ceph,代码行数:8,代码来源:prometheus-alert-formatter.ts


示例4: function

PluginManager.registerPreexecPlugin(async function (job: Job): Promise<void> {
    const input = job.prompt.value;
    const key = _.findKey(await Aliases.all(), value => value === input);

    if (key && key.length < input.length) {
        /* tslint:disable:no-unused-expression */
        new Notification("Alias Reminder", { body: `You have an alias "${key}" for "${input}".` });
    }
});
开发者ID:Culttm,项目名称:black-screen,代码行数:9,代码来源:AliasSuggestions.ts


示例5: constructor

  /**
   * Creates an instance of RequestExtend.
   * @param {Request.Options} options
   * @memberof RequestExtend
   */
  constructor (options: Request.Options) {
    super(options)

    // 通过扩展名,取得key值
    let key = _.findKey(config.ext, value => value === this.ext)
    if (key) {
      // 通过 key 值,设置实例中对应字段的真值,其余都为假值
      this[`is${changeCase.pascalCase(key)}`] = true
    }
  }
开发者ID:bbxyard,项目名称:bbxyard,代码行数:15,代码来源:Request.ts


示例6: adjacentEdges

 adjacentEdges() {
   // find an edge with this as a source
   const v2 = parseInt(
     _.findKey(this.polyhedron.edgeToFaceGraph()[this.index])!,
   );
   const e0 = new Edge(this, this.polyhedron.vertices[v2]);
   let e = e0;
   const result = [];
   let count = 0;
   do {
     count++;
     result.push(e);
     e = e.prev().twin();
     if (count > 10) throw new Error('we done messed up');
   } while (!e.equals(e0));
   return result;
 }
开发者ID:tessenate,项目名称:polyhedra-viewer,代码行数:17,代码来源:Vertex.ts


示例7:

      .map(target => {
        if (target.id && target.id.length > 0 && target.expression && target.expression.length > 0) {
          return [target];
        }

        const variableIndex = _.keyBy(templateSrv.variables, 'name');
        const dimensionKey = _.findKey(target.dimensions, v => {
          const variableName = templateSrv.getVariableName(v);
          return templateSrv.variableExists(v) && !_.has(scopedVars, variableName) && variableIndex[variableName].multi;
        });

        if (dimensionKey) {
          const multiVariable = variableIndex[templateSrv.getVariableName(target.dimensions[dimensionKey])];
          return this.getExpandedVariables(target, dimensionKey, multiVariable, templateSrv);
        } else {
          return [target];
        }
      })
开发者ID:johntdyer,项目名称:grafana,代码行数:18,代码来源:datasource.ts


示例8: return

      .map(target => {
        const dimensionKey = _.findKey(target.dimensions, v => {
          return templateSrv.variableExists(v) && !_.has(scopedVars, templateSrv.getVariableName(v));
        });

        if (dimensionKey) {
          const multiVariable = _.find(templateSrv.variables, variable => {
            return (
              templatingVariable.containsVariable(target.dimensions[dimensionKey], variable.name) && variable.multi
            );
          });
          const variable = _.find(templateSrv.variables, variable => {
            return templatingVariable.containsVariable(target.dimensions[dimensionKey], variable.name);
          });
          return this.getExpandedVariables(target, dimensionKey, multiVariable || variable, templateSrv);
        } else {
          return [target];
        }
      })
开发者ID:acedrew,项目名称:grafana,代码行数:19,代码来源:datasource.ts


示例9: findKey

    myZWave.onValueChange(function(node, commandClass, value) {
      if (node.nodeId === 3) {
        Logger.error(
          "ERROR: Main switch is now probably ignored by OpenZWave. Exiting process so it can be restarted."
        );

        throw "Main switch erroneously ignored. Exiting!";
      }

      const lightName = findKey(lights, function(light) {
        return light.id === node.nodeId;
      });

      if (!lightName) {
        Logger.error(`Unknown light with nodeId ${node.nodeId}. Command class: ${commandClass}, value: "${value}"`);

        return;
      } else if (!lights[lightName]) {
        Logger.error(
          `Unknown light with name "${lightName}" (id: ${
            node.nodeId
          }). Command class: ${commandClass}, value: "${value}"`
        );

        return;
      }

      if (!lights[lightName].values) {
        lights[lightName].values = {};
      }
      lights[lightName].values[commandClass] = value;

      Logger.debug(`Received value change from ${node.nodeId}`);

      const valueToString = `${value.value_id}, ${value.label}`;
      Logger.debug(`New value for node ${node.nodeId}: ${valueToString}`);
    });
开发者ID:lmeijvogel,项目名称:my_node_openzwave,代码行数:37,代码来源:Main.ts


示例10: getNameByValue

 getNameByValue(value: string): string | undefined {
     return _.findKey(this.storage, storageValue => storageValue === value);
 }
开发者ID:Alubatm,项目名称:black-screen,代码行数:3,代码来源:Aliases.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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