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


TypeScript lodash.head函數代碼示例

本文整理匯總了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;未經允許,請勿轉載。