當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。