本文整理汇总了TypeScript中underscore.object函数的典型用法代码示例。如果您正苦于以下问题:TypeScript object函数的具体用法?TypeScript object怎么用?TypeScript object使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了object函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: parse
var parser = parse({ delimiter: ',' }, (err, data) => {
if (err) {
rej(err);
return;
}
var cols = data[0];
for (var index = 1; index < data.length; index++) {
var newPlaque: any = _.object(cols, data[index]);
if (!newPlaque.main_photo
|| !newPlaque.erected
|| newPlaque.erected.startsWith('16')
|| newPlaque.erected.startsWith('17')
|| newPlaque.erected.startsWith('18')) {
continue;
}
newPlaque.search_key = getSearchKey(newPlaque);
newPlaque.erected_decade = newPlaque.erected.substring(0, 3) + '0';
plaqueList.push(newPlaque);
};
res(plaqueList);
});
示例2: object
const parseTermsWeights = (termsWeight: RegExpExecArray | null): IListOfTermsWeights | null => {
const REGEX_EXTRACT_GROUP_OF_TERMS = /((?:[^:]+: [0-9]+, [0-9]+; )+)\n((?:\w+: [0-9]+; )+)/g;
const REGEX_EXTRACT_SINGLE_TERM = /([^:]+): ([0-9]+), ([0-9]+); /g;
if (termsWeight && termsWeight[1]) {
let terms = StringUtils.match(termsWeight[1], REGEX_EXTRACT_GROUP_OF_TERMS);
return object(
map(terms, term => {
let words = object(
map(StringUtils.match(term[1], REGEX_EXTRACT_SINGLE_TERM), word => {
return [
word[1],
{
Correlation: Number(word[2]),
'TF-IDF': Number(word[3])
}
];
})
);
const weights = parseWeights(term[2]);
return [
keys(words).join(', '),
{
terms: words,
Weights: weights
}
];
})
) as IListOfTermsWeights;
}
return null;
};
示例3: parseWeights
private parseWeights(value: string) {
let listOfWeight = value.match(/(\w+(?:\s\w+)*): ([-0-9]+)/g);
return _.object(
_.map(listOfWeight, weight => {
let weightGroup = weight.match(/^(\w+(?:\s\w+)*): ([-0-9]+)$/);
return [weightGroup[1], Number(weightGroup[2])];
})
);
}
示例4: parseRankingInfo
private parseRankingInfo(value: string) {
let rankingInfo = {};
if (value) {
let documentWeights = /Document weights:\n((?:.)*?)\n+/g.exec(value);
let termsWeight = /Terms weights:\n((?:.|\n)*)\n+/g.exec(value);
let totalWeight = /Total weight: ([0-9]+)/g.exec(value);
if (documentWeights && documentWeights[1]) {
rankingInfo['Document weights'] = this.parseWeights(documentWeights[1]);
}
if (totalWeight && totalWeight[1]) {
rankingInfo['Total weight'] = Number(totalWeight[1]);
}
if (termsWeight && termsWeight[1]) {
let terms = StringUtils.match(termsWeight[1], /((?:[^:]+: [0-9]+, [0-9]+; )+)\n((?:\w+: [0-9]+; )+)/g);
rankingInfo['Terms weights'] = _.object(
_.map(terms, term => {
let words = _.object(
_.map(StringUtils.match(term[1], /([^:]+): ([0-9]+), ([0-9]+); /g), word => {
return [
word[1],
{
Correlation: Number(word[2]),
'TF-IDF': Number(word[3])
}
];
})
);
let weights = this.parseWeights(term[2]);
return [
_.keys(words).join(', '),
{
terms: words,
Weights: weights
}
];
})
);
}
}
return rankingInfo;
}
示例5: loadProgress
async function loadProgress(account: DestinyAccount): Promise<ProgressProfile | undefined> {
try {
const defsPromise = getDefinitions();
const profileInfo = await getProgression(account);
const characterIds = Object.keys(profileInfo.characters.data);
let vendors: DestinyVendorsResponse[] = [];
try {
vendors = await Promise.all(
characterIds.map((characterId) => getVendors(account, characterId))
);
} catch (e) {
console.error('Failed to load vendors', e);
}
const defs = await defsPromise;
return {
defs,
profileInfo,
vendors: _.object(_.zip(characterIds, vendors)) as ProgressProfile['vendors'],
get lastPlayedDate() {
return Object.values((this.profileInfo as DestinyProfileResponse).characters.data).reduce(
(memo, character: DestinyCharacterComponent) => {
const d1 = new Date(character.dateLastPlayed);
return memo ? (d1 >= memo ? d1 : memo) : d1;
},
new Date(0)
);
}
};
} catch (e) {
toaster.pop(bungieErrorToaster(e));
console.error('Error loading progress', e);
reportException('progressService', e);
// It's important that we swallow all errors here - otherwise
// our observable will fail on the first error. We could work
// around that with some rxjs operators, but it's easier to
// just make this never fail.
return undefined;
} finally {
D2ManifestService.loaded = true;
}
}
示例6: Number
_.map(terms, term => {
let words = _.object(
_.map(StringUtils.match(term[1], /([^:]+): ([0-9]+), ([0-9]+); /g), word => {
return [
word[1],
{
Correlation: Number(word[2]),
'TF-IDF': Number(word[3])
}
];
})
);
let weights = this.parseWeights(term[2]);
return [
_.keys(words).join(', '),
{
terms: words,
Weights: weights
}
];
})
示例7: map
map(terms, term => {
let words = object(
map(StringUtils.match(term[1], REGEX_EXTRACT_SINGLE_TERM), word => {
return [
word[1],
{
Correlation: Number(word[2]),
'TF-IDF': Number(word[3])
}
];
})
);
const weights = parseWeights(term[2]);
return [
keys(words).join(', '),
{
terms: words,
Weights: weights
}
];
})
示例8: function
return function (err: Error, ...args: any[]) { // function that takes err and any number of additional arguments
var obj = _.object(argNames, args)
defer( err, obj )
}
示例9: getDefinitions
getDefinitions().then((defs) => {
extend(vm, {
active: 'titan',
i18nClassNames: _.object(
['titan', 'hunter', 'warlock'],
_.sortBy(Object.values(defs.Class), (classDef) => classDef.classType).map(
(c) => c.className
)
),
i18nItemNames: _.object(
['Helmet', 'Gauntlets', 'Chest', 'Leg', 'ClassItem', 'Artifact', 'Ghost'],
[45, 46, 47, 48, 49, 38, 39].map((key) => defs.ItemCategory.get(key).title)
),
activesets: '5/5/2',
type: 'Helmet',
scaleType: 'scaled',
progress: 0,
fullMode: false,
includeVendors: false,
showBlues: false,
showExotics: true,
showYear1: false,
allSetTiers: [],
hasSets: true,
highestsets: {},
activeHighestSets: [],
ranked: {},
activePerks: {},
excludeditems: [],
collapsedConfigs: [false, false, false, false, false, false, false, false, false, false],
lockeditems: {
Helmet: null,
Gauntlets: null,
Chest: null,
Leg: null,
ClassItem: null,
Artifact: null,
Ghost: null
},
lockedperks: {
Helmet: {},
Gauntlets: {},
Chest: {},
Leg: {},
ClassItem: {},
Artifact: {},
Ghost: {}
},
setOrderValues: ['-str_val', '-dis_val', '-int_val'],
lockedItemsValid(droppedId: string, droppedType: ArmorTypes) {
droppedId = getId(droppedId);
if (alreadyExists(vm.excludeditems, droppedId)) {
return false;
}
const item = getItemById(droppedId, droppedType)!;
const startCount: number = item.isExotic && item.type !== 'ClassItem' ? 1 : 0;
return (
startCount +
(droppedType !== 'Helmet' && vm.lockeditems.Helmet && vm.lockeditems.Helmet.isExotic
? 1
: 0) +
(droppedType !== 'Gauntlets' &&
vm.lockeditems.Gauntlets &&
vm.lockeditems.Gauntlets.isExotic
? 1
: 0) +
(droppedType !== 'Chest' && vm.lockeditems.Chest && vm.lockeditems.Chest.isExotic
? 1
: 0) +
(droppedType !== 'Leg' && vm.lockeditems.Leg && vm.lockeditems.Leg.isExotic ? 1 : 0) <
2
);
},
excludedItemsValid(droppedId: string, droppedType: ArmorTypes) {
const lockedItem = vm.lockeditems[droppedType];
return !(lockedItem && alreadyExists([lockedItem], droppedId));
},
onSelectedChange(prevIdx, selectedIdx) {
if (vm.activeCharacters[prevIdx].class !== vm.activeCharacters[selectedIdx].class) {
vm.active = vm.activeCharacters[selectedIdx].class;
vm.onCharacterChange();
vm.selectedCharacter = selectedIdx;
}
},
onCharacterChange() {
vm.ranked = getActiveBuckets(
buckets[vm.active],
vendorBuckets[vm.active],
vm.includeVendors
);
vm.activeCharacters = D1StoresService.getStores().filter((s) => !s.isVault);
const activeStore = D1StoresService.getActiveStore()!;
vm.selectedCharacter = _.findIndex(
vm.activeCharacters,
(char) => char.id === activeStore.id
);
vm.activePerks = getActiveBuckets(
perks[vm.active],
vendorPerks[vm.active],
//.........这里部分代码省略.........