本文整理匯總了TypeScript中underscore.find函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript find函數的具體用法?TypeScript find怎麽用?TypeScript find使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了find函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: build
public async build(executionReport: IExecutionReport): Promise<{ container: Dom; gridOptions: agGridModule.GridOptions }> {
const preprocessQuerySection = find(executionReport.children, child => child.name == EXECUTION_REPORT_SECTION.PREPROCESS_QUERY);
if (!preprocessQuerySection) {
return this.buildFallbackEmptyTable(executionReport);
}
const originalLongQuery = preprocessQuerySection.result.in.lq;
const topClicksSection = find(preprocessQuerySection.children, child => child.name == EXECUTION_REPORT_SECTION.TOP_CLICKS) as
| IExecutionReportITDSection
| undefined;
if (!topClicksSection || !originalLongQuery) {
return this.buildFallbackEmptyTable(executionReport);
}
const { container, agGridElement } = ExecutionReport.standardSectionHeader('Large Query Intelligent Term Detection (ITD)');
let gridOptions: agGridModule.GridOptions;
const dataSource = [
{
'Original large query': this.buildOriginalLongQueryCell(originalLongQuery, topClicksSection.refinedQueries),
'Keyword(s) extracted': this.buildRefinedQueryCell(executionReport, topClicksSection.refinedQueries, preprocessQuerySection)
}
];
const tableBuilder = await new TableBuilder().build(dataSource, agGridElement, {
rowHeight: 300
});
gridOptions = tableBuilder.gridOptions;
return { container, gridOptions };
}
示例2: extractDocumentInfoFromBoost
private async extractDocumentInfoFromBoost(
results: IQueryResult[],
permanentID: string,
rankingExpression: IRankingExpression,
bindings: IComponentBindings
) {
let matchingResult = {
result: null,
returnedByIndexForCurrentQuery: false
};
const resultInResultSet = find(results, result => {
return result.raw.permanentid == permanentID || result.raw.urihash == permanentID;
});
if (resultInResultSet) {
matchingResult = {
result: resultInResultSet,
returnedByIndexForCurrentQuery: true
};
return matchingResult;
}
const queryBuilder = new QueryBuilder();
queryBuilder.advancedExpression.add(rankingExpression.expression);
const resultsFromIndex = await bindings.queryController.getEndpoint().search(queryBuilder.build());
matchingResult = {
result: resultsFromIndex.results[0],
returnedByIndexForCurrentQuery: false
};
return matchingResult;
}
示例3: thumbnail
private thumbnail(result: IQueryResult, bindings: IResultsComponentBindings) {
let dom: Dom;
if (bindings && result) {
const resultLists = bindings.searchInterface.getComponents('ResultList') as ResultListModule.ResultList[];
const firstActiveResultList = find(resultLists, resultList => !resultList.disabled);
if (firstActiveResultList) {
dom = $$('div', {
className: 'coveo-relevance-inspector-result-thumbnail'
});
firstActiveResultList.buildResult(result).then(builtResult => {
dom.append(builtResult);
});
} else {
dom = $$('a', {
className: 'CoveoResultLink'
});
new ResultLink(dom.el, { alwaysOpenInNewWindow: true }, bindings, result);
}
if (this.currentFilter) {
this.highlightSearch(dom.el, this.currentFilter);
}
} else {
dom = $$('div', undefined, '-- NULL --');
}
return dom;
}
示例4: view_validate
manager.set_state(widgetStateObject).then(function(models) {
let tags = element.querySelectorAll('script[type="application/vnd.jupyter.widget-view+json"]');
for (let i=0; i!=tags.length; ++i) {
// TODO: validate view schema
let viewtag = tags[i];
let widgetViewObject = JSON.parse(viewtag.innerHTML);
let valid = view_validate(widgetViewObject);
if (!valid) {
console.error('View state has errors.', view_validate.errors);
}
let model_id = widgetViewObject.model_id;
let model = _.find(models, function(item : WidgetModel) {
return item.model_id == model_id;
});
if (model !== undefined) {
if (viewtag.previousElementSibling &&
viewtag.previousElementSibling.matches('img.jupyter-widget')) {
viewtag.parentElement.removeChild(viewtag.previousElementSibling);
}
let widgetTag = document.createElement('div');
widgetTag.className = 'widget-subarea';
viewtag.parentElement.insertBefore(widgetTag, viewtag);
manager.display_model(undefined, model, { el : widgetTag });
}
}
});
示例5: function
events.forEach(function(e){
var eventName = e.trim();
if(!that.callbacks){
that.callbacks = {};
}
if(!that.callbacks[eventName]){
that.callbacks[eventName] = [];
}
if(!cb){
that.callbacks[eventName].pop();
}
else{
that.callbacks[eventName] = _.without(
that.callbacks[eventName], _.find(
that.callbacks[eventName], function(item){
return item.toString() === cb.toString()
}
)
);
}
var propertiesChain = eventName.split('.');
if(propertiesChain.length > 1){
var prop = propertiesChain[0];
propertiesChain.splice(0, 1);
if(!this[prop] || !this[prop].on){
throw "Property " + prop + " is undefined in " + eventName;
}
this[prop].unbind(propertiesChain.join('.'));
}
}.bind(this));
示例6:
pulls.then((body)=>{
var pull = _.find(JSON.parse(body), (item) =>{
return item.title.indexOf(branchName)>-1 && item.state === "open";
});
if(pull){
var options = {
uri: "https://api.github.com/repos/saulmadi/acklen-slackbot/pulls/" + pull.number+"/merge?access_token=4dcf4b3298bc38faa8bc348ae93fcb4f62aa549b",
method: "PUT",
headers:{
"User-Agent": "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36"
},
body : JSON.stringify({
"commit_message": "merge pull request for" + branchName,
"sha": pull.head.sha
})
};
return this.httpClient(options);
}else{ console.log("la cague");}
})
示例7: return
var valuesToBuildWith = _.map(facetValues, facetValue => {
return (
_.find(this.facet.values.getAll(), (valueAlreadyInFacet: FacetValue) => {
return valueAlreadyInFacet.value == facetValue.value;
}) || facetValue
);
});
示例8: title
title(node: TreeNode): string {
const c = find(this.cache, (i: [TreeNode, string]) => i[0] === node);
if (c) {
return c[1];
}
return '';
}
示例9:
$scope.$watch('$ctrl.item.dimInfo.tag', () => {
if (vm.item.dimInfo) {
vm.selected = _.find(itemTags, (tag) => {
return tag.type === vm.item.dimInfo.tag;
});
}
});
示例10:
vm.$onInit = () => {
vm.hiddenColumns = 0;
if (vm.perksOnly) {
if (_.find(vm.talentGrid.nodes, { hash: infuseHash })) {
vm.hiddenColumns += 1;
}
if (_.find(vm.talentGrid.nodes, { hash: 2133116599 })) {
vm.hiddenColumns += 1;
}
}
if (vm.talentGrid) {
const visibleNodes = vm.talentGrid.nodes.filter((n) => !n.hidden);
vm.numColumns = _.max(visibleNodes, (n) => n.column).column + 1 - vm.hiddenColumns;
vm.numRows = vm.perksOnly ? 2 : _.max(visibleNodes, (n) => n.row).row + 1;
}
};