本文整理汇总了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);
});
示例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;
}
}
示例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;
});
}
示例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)
}
示例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);
}
示例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';
}
示例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;
});
示例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
]);
}
示例9: rootStateIsClean
function rootStateIsClean(data: RootState): boolean {
return (
data &&
!!data.accessToken &&
remoteDataIsClean<Playlist>(data.playlists) &&
_.every(data.albums, remoteDataIsClean)
);
}
示例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
})
}