本文整理汇总了TypeScript中underscore.size函数的典型用法代码示例。如果您正苦于以下问题:TypeScript size函数的具体用法?TypeScript size怎么用?TypeScript size使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了size函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: dataStats
export function dataStats(data) {
const taggedItemsD1 = sum(
Object.keys(data)
.filter((k) => k.startsWith('dimItemInfo') && k.endsWith('-d1'))
.map((k) => _.size(data[k])),
(v) => v
);
const taggedItemsD2 = sum(
Object.keys(data)
.filter((k) => k.startsWith('dimItemInfo') && k.endsWith('-d2'))
.map((k) => _.size(data[k])),
(v) => v
);
const loadoutsD1 = count(
data['loadouts-v3.0'] || [],
(loadoutId: string) => data[loadoutId] && data[loadoutId].destinyVersion !== 2
);
const loadoutsD2 = count(
data['loadouts-v3.0'] || [],
(loadoutId: string) => data[loadoutId] && data[loadoutId].destinyVersion === 2
);
return {
LoadoutsD1: loadoutsD1,
LoadoutsD2: loadoutsD2,
TagNotesD1: taggedItemsD1,
TagNotesD2: taggedItemsD2,
Settings: _.size(data['settings-v1.0']),
IgnoredUsers: _.size(data.ignoredUsers)
};
}
示例2: function
this.us.getUsers().subscribe(users => {
let participants: number [] = [0, 0, 0, 0];
participants[0] = _.size(_.filter(users, function(user){ return +user.job === 1; }));
participants[1] = _.size(_.filter(users, function(user){ return +user.job === 2; }));
participants[2] = _.size(_.filter(users, function(user){ return +user.job === 3; }));
participants[3] = _.size(_.filter(users, function(user){ return +user.job === 4; }));
this.chart.data = participants;
});
示例3: dataStats
function dataStats(data) {
const taggedItems = sum(Object.keys(data)
.filter((k) => k.startsWith('dimItemInfo'))
.map((k) => _.size(data[k])), (v) => v);
return {
Loadouts: _.size(data['loadouts-v3.0']),
TagNotes: taggedItems,
Settings: _.size(data['settings-v1.0']),
IgnoredUsers: _.size(data.ignoredUsers)
};
}
示例4: getLastLevel
private getLastLevel(type) {
let numLevels = _.size(this.levels);
if(numLevels != 0) {
let lastLevel = this.levels[numLevels-1];
return lastLevel[type];
} else {
return null;
}
}
示例5: Error
.then((response) => {
// TODO: what does it actually look like to not have an account?
if (_.size(response.Response) === 0) {
throw new Error(t('BungieService.NoAccountForPlatform', {
platform: platform.platformLabel
}));
}
return response.Response;
}) as IPromise<DestinyProfileResponse>;
示例6:
.switchMap(term => {
var temp;
var trimmed = term.toString().trim();
if (_.size(trimmed) > 0) {
temp = this.rawSearch(trimmed);
} else {
temp = Observable.of([]);
}
return temp;
});
示例7: function
this.vs.getVotes().subscribe(votes => {
let satisfactions: number [] = [0, 0, 0, 0];
satisfactions[0] = _.size(_.filter(votes, function(vote){ return +vote.satisfaction === 0; }));
satisfactions[1] = _.size(_.filter(votes, function(vote){ return +vote.satisfaction === 25; }));
satisfactions[2] = _.size(_.filter(votes, function(vote){ return +vote.satisfaction === 50; }));
satisfactions[3] = _.size(_.filter(votes, function(vote){ return +vote.satisfaction === 75; }));
satisfactions[4] = _.size(_.filter(votes, function(vote){ return +vote.satisfaction === 100; }));
let data = {
data: satisfactions,
label: 'Satisfaction globale',
backgroundColor: [
'rgba(255, 0, 0, 0.2)'
],
borderColor: [
'rgba(255,99,132,1)'
],
borderWidth: 1
};
this.chart.data = [data];
});
示例8: trimHistory
export function trimHistory(ti: TabInstance): TabInstance {
if (!ti || !ti.history) {
return ti;
}
const historySize = size(ti.history);
if (historySize <= maxHistorySize) {
return ti;
}
let offset = maxHistorySize - historySize;
let newIndex = ti.currentIndex - offset;
let newHistory = ti.history.slice(offset);
if (newIndex < 0 || newIndex >= size(newHistory)) {
newIndex = size(newHistory) - 1;
}
return {
...ti,
currentIndex: newIndex,
history: newHistory,
};
}
示例9: processBnetCharactersRequest
function processBnetCharactersRequest(response) {
if (!response.data || _.size(response.data.Response) === 0) {
throw error(t('BungieService.NoAccountForPlatform', {
platform: platform.label
}), 1601);
}
return _.map(response.data.Response.data.characters, (c: any) => {
c.inventory = response.data.Response.data.inventory;
return {
id: c.characterBase.characterId,
base: c
};
});
}
示例10:
function getByIds<T>(records: RecordMap<T>, ids: string[] | number[]): T[] {
if (size(ids) === 0) {
return emptyArr;
}
if (!records) {
return emptyArr;
}
const result = [];
for (const id of ids) {
const record = records[id];
if (record) {
result.push(record);
}
}
return result;
}