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

TypeScript lodash.head函数代码示例

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

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



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

示例1:

 .then(function(addresses) {
   addresses.should.have.property('coin');
   addresses.should.have.property('count');
   addresses.should.have.property('addresses');
   addresses.addresses.length.should.be.greaterThan(2);
   walletAddress = (_.head(addresses.addresses) as any).address;
   walletAddressId = (_.head(addresses.addresses) as any).id;
 });
开发者ID:BitGo,项目名称:BitGoJS,代码行数:8,代码来源:wallet.ts


示例2: predict

const predictAddressNo = address => {
  const pattern = ['เลขที่', 'N'];
  if (predictNo.test(_.head(address))){
    checkSum--;
    return _.head(address);
  } else {
    return  predict(address, pattern);
  }
}
开发者ID:warozz,项目名称:D3VMobiz,代码行数:9,代码来源:address-util.ts


示例3: it

    it('should fill __allRecipeIngredients on instantiation if there are _recipes', () => {

        let recipe = RecipeMock.entity();

        let meal = new Meal({
            _recipes: [recipe]
        });

        expect(meal.__allRecipeIngredients.length).to.equal(recipe._ingredients.length);
        expect(_.head(meal.__allRecipeIngredients).recipeIngredient).to.deep.equal(_.head(recipe._ingredients));

    });
开发者ID:swordman1205,项目名称:angular-typescript-material,代码行数:12,代码来源:mealModel.spec.ts


示例4: yamlStringToDocuments

export function yamlStringToDocuments(yamlString: string): any[] {
  try {
    const yamlDocuments = loadAll(yamlString, null);
    if (Array.isArray(head(yamlDocuments))) {
      // Multi-doc entered as list of maps
      return head(yamlDocuments);
    }
    return yamlDocuments;
  } catch (e) {
    return null;
  }
}
开发者ID:emjburns,项目名称:deck,代码行数:12,代码来源:yamlEditorUtils.ts


示例5: it

    it('verifies spec models', ()=>{
        const models = codegen.processModels(spec);
        expect(models).to.not.be.empty;
        _.forEach(models, (model: codegen.Model)=>{
            expect(model.name).to.not.be.empty;
        });
        const modelQuestionType = models['Revinate.LustroFormServiceBundle.Form.QuestionType'];
        const account = _.head(_.filter(modelQuestionType.properties, (prop: codegen.ModelProperty)=>(prop.name == 'account')));
        expect(account.type).to.be.equal('string');

        const name_translations = _.head(_.filter(modelQuestionType.properties, (prop: codegen.ModelProperty)=>(prop.name == 'name_translations')));
        expect(name_translations.type).to.be.equal('Revinate_LustroFormServiceBundle_Form_TranslationType[]')
    });
开发者ID:Jason-Rev,项目名称:swagger-ts-codegen,代码行数:13,代码来源:codegen_test.ts


示例6: createLineReferenceFromSourceMap

export function createLineReferenceFromSourceMap(refractSourceMap, document: string, documentLines: string[]): any {

  const firstSourceMap = lodash.first(refractSourceMap);

  if (typeof (firstSourceMap) === 'undefined') {
    return {
      endIndex: documentLines[documentLines.length - 1].length,
      endRow: documentLines.length - 1,
      startIndex: 0,
      startRow: 0,
    };
  }

  const sourceMapArray = lodash.map(firstSourceMap.content, (sm) => {
    return {
      charCount: lodash.last(sm),
      charIndex: lodash.head(sm),
    };
  });

  // I didn't find any useful example of multiple sourcemap elements.
  const sourceMap = lodash.head(sourceMapArray);

  const sourceSubstring = document.substring(sourceMap.charIndex, sourceMap.charIndex + sourceMap.charCount);
  const sourceLines = sourceSubstring.split(/\r?\n/g);

  if (sourceSubstring === '\n' || sourceSubstring === '\r') {
    // It's on a newline which I cannot show in the document.
    return {
      endIndex: lodash.last(documentLines).length,
      endRow: documentLines.length,
      startIndex: 0,
      startRow: 0,
    };
  }

  const startRow = document.substring(0, sourceMap.charIndex).split(/\r?\n/g).length - 1;
  const endRow = startRow + sourceLines.length - 1;

  const startIndex = documentLines[startRow].indexOf(lodash.head(sourceLines));
  const endIndex = documentLines[endRow].length;

  return {
    startRow,
    endRow,
    startIndex,
    endIndex,
  };
}
开发者ID:XVincentX,项目名称:vscode-apielements,代码行数:49,代码来源:refractUtils.ts


示例7: getAppropriatePlugin

export function getAppropriatePlugin(queryParam, options: IBaseReaderOptions): IResourceSelectionOptimizer {
  const plugins = [
    new InClauseUnderConjunction(queryParam, options)
  ];

  return head(plugins.filter(plugin => plugin.isMatched()));
}
开发者ID:VS-work,项目名称:vizabi-ddfcsv-reader,代码行数:7,代码来源:index.ts


示例8: cat

function cat(...rest: any[]) {
  const head = _.head(rest)
  if (existy(head)) {
    return Array.prototype.concat.apply(head, _.tail(rest)) // remove apply eg: head.concat.apply(head, _.tail(rest))
  }
  return []
}
开发者ID:galenjiang,项目名称:hexo,代码行数:7,代码来源:base.ts


示例9:

    _.map(regions, region_events => {
      let region_obj = _.head(region_events);
      if (region_events && region_events.length > 1) {
        region_obj.timeEnd = region_events[1].time;
        region_obj.isRegion = true;
        return region_obj;
      } else {
        if (region_events && region_events.length) {
          // Don't change proper region object
          if (!region_obj.time || !region_obj.timeEnd) {
            // This is cut region
            if (isStartOfRegion(region_obj)) {
              region_obj.timeEnd = range.to.valueOf() - 1;
            } else {
              // Start time = null
              region_obj.timeEnd = region_obj.time;
              region_obj.time = range.from.valueOf() + 1;
            }
            region_obj.isRegion = true;
          }

          return region_obj;
        }
      }
    }),
开发者ID:connection-reset,项目名称:grafana,代码行数:25,代码来源:events_processing.ts


示例10: createUser

  async createUser(authID: string, username: string, email: string): Promise<number> {
    let created: Date = new Date();
    let input: UserRow = new UserRow(undefined, authID, username, email, created, created);

    let result: Pick<UserRow, 'id'>[] = await this.db.table(USER_TABLES.USER.name).insert(input).returning([USER_TABLES.USER.schema.id]);

    return _.head(result).id;
  }
开发者ID:cuponthetop,项目名称:bg-hub,代码行数:8,代码来源:user.command.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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