当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript lodash.every函数代码示例

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


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

示例1: test

 test('getTransactions', async () => {
   const api = new BrokerApi('', '');
   const reply = await api.getTransactions({ limit: 20, order: 'desc' });
   expect(reply.data.length === 20).toBe(true);
   expect(reply.pagination.limit).toBe(20);
   expect(typeof reply.data[0].id).toBe('string');
   expect(reply.data[0].created_at.getFullYear()).toBe(2017);
   expect(typeof reply.data[0].rate).toBe('number');
   expect(_.every(reply.data, d => _.inRange(d.rate, 500000, 700000))).toBe(true);
   expect(_.every(reply.data.filter(d => d.side === 'buy'), d => _.inRange(d.funds.btc, 0.001, 1))).toBe(true);
   expect(_.every(reply.data.filter(d => d.side === 'sell'), d => _.inRange(d.funds.btc, -1, -0.001))).toBe(true);
 });
开发者ID:tangkaisky,项目名称:r2,代码行数:12,代码来源:BrokerApi.test.ts

示例2: normalizeRule

function normalizeRule(rule) {
  _.times(3, i => {
    if (i < rule.before.length) {
      rule.before[i] = (rule.before[i] + '   ').substr(0, 3);
      rule.after[i] = (rule.after[i] + '   ').substr(0, 3);
    } else {
      rule.before.push('   ');
      rule.after.push('   ');
    }
  });
  if (_.every(rule.before, b => b === '   ') && _.every(rule.after, a => a === '   ')) {
    rule.before = rule.after = null;
    return;
  }
}
开发者ID:abagames,项目名称:consomaton-game-lib,代码行数:15,代码来源:automaton.ts

示例3: validate

export function validate(result: ReaderResult): boolean {
  if (has(result, 'par') && !includes([70, 71, 72], result.par)) {
    console.log("ERROR - Par invalid:" + result.par);
    return false;
  }

  return every(result.golfers, g => {
    const validScores = every(g.scores, s => isFinite(s) || s === MISSED_CUT);
    let inv = false;

    if (g.golfer === "-") {
      console.log("ERROR - Invalid golfer name");
      inv = true;
    } else if (g.scores.length !== DAYS) {
      console.log("ERROR - Invalid golfer scores length");
      inv = true;
    } else if (!validScores) {
      console.log("ERROR - Invalid golfer scores");
      inv = true;
    } else if (!includes(range(DAYS + 1), g.day)) {
      console.log("ERROR - Invalid golfer day");
      inv = true;
    }

    if (inv) {
      console.log(JSON.stringify(g));
    }
    return !inv;
  });
}
开发者ID:odetown,项目名称:golfdraft,代码行数:30,代码来源:updateScore.ts

示例4: next

 (req: IncomingMessage, res: ServerResponse, next: Function) => {
   if (_.every(config.apiPrefixes, (p) => req.url != null && req.url.indexOf(p) !== 0)) {
     next()
     return
   }
   proxyServer.web(req, res)
 }
开发者ID:whitetrefoil,项目名称:flickr-simple-reorder,代码行数:7,代码来源:backend.ts

示例5: isReadyForNextContext

 isReadyForNextContext(): boolean {
   // XXX: might be more 'correct' to check that no players have their state
   // as `PLAYING` or whatever...
   return _.every(this.players,
     player => !Animal.isAlive(player.character)
       || player.character.hasEscaped);
 }
开发者ID:zthomae,项目名称:xanadu,代码行数:7,代码来源:game.ts

示例6: getCupolaGyrate

export function getCupolaGyrate(polyhedron: Polyhedron, cap: Cap) {
  const isOrtho = _.every(cap.boundary().edges, edge => {
    const [n1, n2] = _.map(edge.adjacentFaces(), 'numSides');
    return (n1 === 4) === (n2 === 4);
  });
  return isOrtho ? 'ortho' : 'gyro';
}
开发者ID:tessenate,项目名称:polyhedra-viewer,代码行数:7,代码来源:cutPasteUtils.ts

示例7: it

    it('should start with every cell hidden', function () {
      const flattenedGrid = _.flatten(characterMap.grid);

      const allUnknown = _.every(flattenedGrid, (cell) => cell.representation === '?');

      expect(allUnknown).to.be.true;
    });
开发者ID:zthomae,项目名称:xanadu,代码行数:7,代码来源:characterMapSpec.ts

示例8: meetsRequirements

export function meetsRequirements(stats: Stats, requirements: PartialStats): boolean {
  return _.every([
    requirements.health ? stats.health >= requirements.health : true,
    requirements.strength ? stats.strength >= requirements.strength : true,
    requirements.intelligence ? stats.intelligence >= requirements.intelligence : true,
    requirements.agility ? stats.agility >= requirements.agility : true
  ]);
}
开发者ID:zthomae,项目名称:xanadu,代码行数:8,代码来源:stats.ts

示例9: rootStateIsClean

function rootStateIsClean(data: RootState): boolean {
  return (
    data &&
    !!data.accessToken &&
    remoteDataIsClean<Playlist>(data.playlists) &&
    _.every(data.albums, remoteDataIsClean)
  );
}
开发者ID:mattbroussard,项目名称:spotify-albums,代码行数:8,代码来源:persist.ts

示例10: checkKeys

  private checkKeys (obj) {
    lodash.every(obj, (_, key) => {
      if (!lodash.includes(VALID_KEYS, key)) {
        throw new Error('Key \'' + key + '\' is not valid.')
      }

      return true
    })
  }
开发者ID:Finciero,项目名称:transaction-builder,代码行数:9,代码来源:transaction.ts


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