本文整理汇总了TypeScript中lodash.findIndex函数的典型用法代码示例。如果您正苦于以下问题:TypeScript findIndex函数的具体用法?TypeScript findIndex怎么用?TypeScript findIndex使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了findIndex函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: getFactors
panelUpgrades.push(panel => {
if (panel.minSpan) {
const max = GRID_COLUMN_COUNT / panel.minSpan;
const factors = getFactors(GRID_COLUMN_COUNT);
// find the best match compared to factors
// (ie. [1,2,3,4,6,12,24] for 24 columns)
panel.maxPerRow =
factors[
_.findIndex(factors, o => {
return o > max;
}) - 1
];
}
delete panel.minSpan;
});
开发者ID:CorpGlory,项目名称:grafana,代码行数:15,代码来源:DashboardMigrator.ts
示例2: mergeTablesIntoModel
transform: (data: any[], panel, model) => {
if (!data || data.length === 0) {
return;
}
const noTableIndex = _.findIndex(data, d => d.type !== 'table');
if (noTableIndex > -1) {
throw {
message: `Result of query #${String.fromCharCode(
65 + noTableIndex
)} is not in table format, try using another transform.`,
};
}
mergeTablesIntoModel(model, ...data);
},
开发者ID:johntdyer,项目名称:grafana,代码行数:16,代码来源:transformers.ts
示例3: replacePanel
replacePanel(newPanel, oldPanel) {
let dashboard = this.dashboard;
let index = _.findIndex(dashboard.panels, panel => {
return panel.id === oldPanel.id;
});
let deletedPanel = dashboard.panels.splice(index, 1);
this.dashboard.events.emit('panel-removed', deletedPanel);
newPanel = new PanelModel(newPanel);
newPanel.id = oldPanel.id;
dashboard.panels.splice(index, 0, newPanel);
dashboard.sortPanelsByGridPos();
dashboard.events.emit('panel-added', newPanel);
}
开发者ID:arcolife,项目名称:grafana,代码行数:16,代码来源:panel_ctrl.ts
示例4: destroyConnection
private destroyConnection(connection: MessageConnection) {
const index = _.findIndex(this.connections_,
x => { return x.connection == connection; });
if (index == -1) {
return;
}
const entry = this.connections_[index];
if (entry.handler != null) {
entry.handler.onDestroy();
}
entry.disposable.dispose();
this.diposable_.remove(entry.disposable);
this.connections_.splice(index, 1);
}
开发者ID:omochi,项目名称:national-economy,代码行数:16,代码来源:Engine.ts
示例5: updateLookupOption
function updateLookupOption(state: Array<LookupOptions>, action: { payload: { lookupOptions: LookupOptions } }) {
let newstate = _.clone(state);
let index = _.findIndex<LookupOptions>(newstate, x =>
(x.lookupField === action.payload.lookupOptions.lookupField) &&
(x.lookupListId === action.payload.lookupOptions.lookupListId) &&
(x.lookupSite === action.payload.lookupOptions.lookupSite) &&
(x.lookupWebId === action.payload.lookupOptions.lookupWebId));
if (index !== -1) {
newstate[index] = action.payload.lookupOptions;
}
else {
newstate.push(action.payload.lookupOptions);
}
Log.info("getLookupOptions", "Updated Header Record");
return newstate;
}
开发者ID:,项目名称:,代码行数:17,代码来源:
示例6: changeUnit
public changeUnit(): void {
if (this.fixedUnit) return;
this.unitIndex++;
if (this.unitIndex >= this.availableUnits.length) this.unitIndex = 0;
if (this.availableUnits[this.unitIndex].isFiat) {
// Always return to BTC... TODO?
this.altUnitIndex = 0;
} else {
this.altUnitIndex = _.findIndex(this.availableUnits, {
isFiat: true
});
}
this.updateUnitUI();
}
开发者ID:bitjson,项目名称:copay,代码行数:17,代码来源:amount.ts
示例7:
deepCopyShelve.map((obj, idx) => {
// 선택한 데이터 정보가 있을 경우에만 차원값필드와 맵핑
if (!_.isNull(params)) {
if (_.eq(key, ShelveType.ROWS)) return;
targetValues = colValues;
}
// 해당 차원값에 선택 데이터 값을 맵핑, null값인경우 데이터가 들어가지 않게 설정
if (!_.isEmpty(targetValues) && targetValues[idx]) {
// object 형식으로 returnData 설정
if (-1 === _.findIndex(returnDataList, {name: obj.name})) {
returnDataList.push(obj);
}
returnDataList[returnDataList.length - 1].data = [targetValues[idx]];
}
});
开发者ID:bchin22,项目名称:metatron-discovery,代码行数:18,代码来源:boxplot-chart.component.ts
示例8: createLineReferenceFromSourceMap
export function createLineReferenceFromSourceMap(refractSourceMap, document : string, documentLines : string[]) : any {
const firstSourceMap = lodash.first(refractSourceMap);
if (typeof(firstSourceMap) === 'undefined') {
return {};
}
const sourceMapArray = lodash.map(firstSourceMap.content, (sm) => {
return {
charIndex: lodash.head(sm),
charCount: lodash.last(sm)
}
});
// I didn't find any useful example of multiple sourcemap elements.
const sourceMap = lodash.head(sourceMapArray);
const sourceSubstring = document.substring(sourceMap.charIndex, sourceMap.charIndex + sourceMap.charCount);
const sourceLines = sourceSubstring.split(/\r?\n/g);
if (sourceSubstring === '\n' || sourceSubstring === '\r') {
// It's on a newline which I cannot show in the document.
return {
startRow: 0,
endRow: documentLines.length,
startIndex: 0,
endIndex: lodash.last(documentLines).length
};
}
const startRow = lodash.findIndex(documentLines, (line) => line.indexOf(lodash.head(sourceLines)) > -1);
const endRow = startRow + (sourceLines.length > 1 ? sourceLines.length - 1 : sourceLines.length) - 1; // - 1 for the current line, - 1 for the last nextline
const startIndex = documentLines[startRow].indexOf(lodash.head(sourceLines));
const endIndex = documentLines[endRow].length;
return {
startRow: startRow,
endRow: endRow,
startIndex: startIndex,
endIndex: endIndex
};
}
开发者ID:smizell,项目名称:vscode-apielements,代码行数:44,代码来源:refractUtils.ts
示例9: function
ctrl.unstar = async function() {
ctrl.submitting = true;
try {
await $http.delete(
config.apiUrl +
'/documents/' + ctrl.documentId + '/star'
);
} catch (err) {
ctrl.submitting = false;
notificationService.httpError('could not star document');
}
ctrl.submitting = false;
const idx = findIndex(ctrl.stars, {id: ctrl.user.id});
if (idx > -1) { ctrl.stars.splice(idx, 1); }
ctrl.doesUserStar = false;
// This is an async function, so unless we $apply, angular won't
// know that values have changed.
$scope.$apply();
};
开发者ID:carolinagc,项目名称:paperhive-frontend,代码行数:19,代码来源:star-button.ts
示例10: setDownstream
setDownstream(id: ID, connection: any, destructor: () => void) {
const existing = _.findIndex(this.switchboard, ['id', id]);
if (existing !== -1) {
this.switchboard[existing].downstream = {
connection: connection,
destructor: destructor
};
} else {
this.switchboard.push({
id: id,
tabClosed: false,
upstream: null,
downstream: {
connection: connection,
destructor: destructor
}
});
}
}
开发者ID:banacorn,项目名称:lookup,代码行数:19,代码来源:operator.ts
示例11: calculateDeletedSubIdxs
/**
* Calculates the sub path indices that will be removed after unsplitting subIdx.
* targetCs is the command state object containing the split segment in question.
*/
private calculateDeletedSubIdxs(subIdx: number, targetCs: CommandState) {
const splitSegId = targetCs.getSplitSegmentId();
const psps = this.findSplitSegmentParentNode(splitSegId);
const pssps = psps.getSplitSubPaths();
const splitSubPathIdx1 = _.findIndex(pssps, sps => {
return sps.getCommandStates().some(cs => cs.getSplitSegmentId() === splitSegId);
});
const splitSubPathIdx2 = _.findLastIndex(pssps, sps => {
return sps.getCommandStates().some(cs => cs.getSplitSegmentId() === splitSegId);
});
const pssp1 = pssps[splitSubPathIdx1];
const pssp2 = pssps[splitSubPathIdx2];
const deletedSps = [...flattenSubPathStates([pssp1]), ...flattenSubPathStates([pssp2])];
const spss = flattenSubPathStates(this.subPathStateMap);
return deletedSps
.slice(1)
.map(sps => this.subPathOrdering[spss.indexOf(sps)])
.sort((a, b) => b - a);
}
开发者ID:arpitsaan,项目名称:ShapeShifter,代码行数:23,代码来源:Path.ts
示例12: return
return _.map(metrics, metricData => {
if (tsdbVersion === 3) {
return metricData.query.index;
} else {
return _.findIndex(options.targets, target => {
if (target.filters && target.filters.length > 0) {
return target.metric === metricData.metric;
} else {
return (
target.metric === metricData.metric &&
_.every(target.tags, (tagV, tagK) => {
interpolatedTagValue = this.templateSrv.replace(tagV, options.scopedVars, 'pipe');
arrTagV = interpolatedTagValue.split('|');
return _.includes(arrTagV, metricData.tags[tagK]) || interpolatedTagValue === '*';
})
);
}
});
}
});
开发者ID:acedrew,项目名称:grafana,代码行数:20,代码来源:datasource.ts
示例13: shouldShowItem
export function shouldShowItem(item: InventoryItem.Fragment, activeFilters: ActiveFilters) {
const hasFilter = hasActiveFilterButtons(activeFilters);
// Active filters compared to item gearSlots
const doActiveFiltersIncludeItem = _.findIndex(_.values(activeFilters), (filter) => {
return inventoryFilterButtons[filter.name].filter(item);
}) > -1;
if (hasFilter) {
// Do active filters and search include item?
return doActiveFiltersIncludeItem;
} else if (hasFilter) {
// Do active filters include item?
return doActiveFiltersIncludeItem;
} else {
// If there are no filters or searchValue, every item should be shown.
return true;
}
}
开发者ID:Mehuge,项目名称:Camelot-Unchained,代码行数:21,代码来源:utils.ts
示例14: generateNewTitle
generateNewTitle(oldTitle, aes, titleName){
let newTitle;
if (_.endsWith(oldTitle, '_CLONE')){
newTitle = oldTitle + '(1)';
}else{
if (_.endsWith(oldTitle, ')')){
let split = _.split(oldTitle, '(');
let index = _.last(split);
split.pop();
index = _.replace(index, ')', '');
let indexInt = _.parseInt(index);
newTitle = split + '(' + _.add(indexInt, 1) + ')';
}else{
newTitle = oldTitle + '_CLONE';
}
}
if(aes && _.findIndex(aes, function(o) { return (_.hasIn(o,titleName) && o[titleName] == newTitle); }) > -1){
return this.generateNewTitle(newTitle, aes, titleName);
}else{
return newTitle;
}
}
开发者ID:PyJava1984,项目名称:dcm4chee-arc-light,代码行数:22,代码来源:devices.service.ts
示例15: checkUsers
public checkUsers()
{
if (!this._userbox)
return;
var nodes = this._userbox.querySelectorAll("[data-uname]");
var i = nodes.length;
var lists = this._save.data.lists;
while (i--)
{
var userName = (nodes[i].getAttribute("data-uname") || "").trim().toLowerCase();
if (!userName)
continue;
if (lists.black.indexOf(userName) !== -1)
{
nodes[i].setAttribute("emes-user", "banned");
}
else if (lists.quarantine.indexOf(userName) !== -1)
{
nodes[i].setAttribute("emes-user", "quarantine");
}
else if (_.findIndex(lists.windows, (a => a.indexOf(userName) !== -1)) !== -1)
{
nodes[i].setAttribute("emes-user", "window");
}
else if (lists.white.indexOf(userName) !== -1)
{
nodes[i].setAttribute("emes-user", "white");
}
else
{
nodes[i].setAttribute("emes-user", "noname");
}
}
}
开发者ID:kunkawindow,项目名称:emes,代码行数:38,代码来源:userbox.ts
示例16:
layoutResult.forEach(result => {
if (newLayoutResult.length === 0) {
newLayoutResult.push(result);
} else {
const currentDimensionObject = _.find(newLayoutResult, ['dimension', result.dimension]);
const currentDimensionIndex = _.findIndex(newLayoutResult, currentDimensionObject);
if (currentDimensionObject) {
let newItemList: any = [];
/**
* Get list from current array
*/
const arrayItems: any[] = result.items;
if (arrayItems) {
arrayItems.forEach(item => {
newItemList.push(item);
});
}
;
/**
* Add more item list from already added list
*/
const existingItems = newLayoutResult[currentDimensionIndex].items;
if (existingItems) {
existingItems.forEach(item => {
newItemList.push(item);
});
}
newLayoutResult[currentDimensionIndex].items = newItemList;
} else {
newLayoutResult.push(result);
}
}
});
开发者ID:hisptz,项目名称:scorecard,代码行数:38,代码来源:favorite.service.ts
示例17: rootReducer
export function rootReducer(previousState = initialState, action) {
const { type } = action;
switch(type) {
case ActionTypes.CHANGE_SCHEMA:
return {
...previousState,
schema: action.payload.introspection,
displayOptions: _.defaults(action.payload.displayOptions, initialState.displayOptions),
svgCache: [],
currentSvgIndex: null,
graphView: initialState.graphView,
selected: initialState.selected,
};
case ActionTypes.CHANGE_DISPLAY_OPTIONS:
let displayOptions = {...previousState.displayOptions, ...action.payload};
let cacheIdx = _.findIndex(previousState.svgCache, cacheItem => {
return _.isEqual(cacheItem.displayOptions, displayOptions)
});
return {
...previousState,
displayOptions,
currentSvgIndex: cacheIdx >= 0 ? cacheIdx : null,
graphView: initialState.graphView,
selected: initialState.selected,
};
case ActionTypes.SVG_RENDERING_FINISHED:
return {
...previousState,
svgCache: previousState.svgCache.concat([{
displayOptions: previousState.displayOptions,
svg: action.payload
}]),
currentSvgIndex: previousState.svgCache.length
};
case ActionTypes.SELECT_NODE:
const currentNodeId = action.payload;
if (currentNodeId === previousState.selected.currentNodeId)
return previousState;
return {
...previousState,
selected: {
...previousState.selected,
previousTypesIds: pushHistory(currentNodeId, previousState),
currentNodeId,
currentEdgeId: null,
scalar: null
},
};
case ActionTypes.SELECT_EDGE:
let currentEdgeId = action.payload;
// deselect if click again
if (currentEdgeId === previousState.selected.currentEdgeId) {
return {
...previousState,
selected: {
...previousState.selected,
currentEdgeId: null,
scalar: null
}
};
}
let nodeId = extractTypeId(currentEdgeId);
return {
...previousState,
selected: {
...previousState.selected,
previousTypesIds: pushHistory(nodeId, previousState),
currentNodeId: nodeId,
currentEdgeId,
scalar: null
},
};
case ActionTypes.SELECT_PREVIOUS_TYPE:
return {
...previousState,
selected: {
...previousState.selected,
previousTypesIds: _.initial(previousState.selected.previousTypesIds),
currentNodeId: _.last(previousState.selected.previousTypesIds),
currentEdgeId: null,
scalar: null
},
};
case ActionTypes.CLEAR_SELECTION:
return {
...previousState,
selected: initialState.selected,
};
case ActionTypes.FOCUS_ELEMENT:
return {
...previousState,
graphView: {
...previousState.graphView,
focusedId: action.payload,
},
};
case ActionTypes.FOCUS_ELEMENT_DONE:
//.........这里部分代码省略.........
开发者ID:codeaudit,项目名称:graphql-voyager,代码行数:101,代码来源:index.ts
示例18:
const fieldsSortOrder = fieldOptions.map(fieldOption => {
return _.findIndex(data[0], dataLabel => {
return dataLabel === fieldOption.internalName
})
})
开发者ID:viccom,项目名称:influxdb,代码行数:5,代码来源:tableGraph.ts
示例19: filterForLayer
function filterForLayer(item: InventoryItem.Fragment, layer: 'outer' | 'under') {
return item &&
_.findIndex(item.staticDefinition.gearSlotSets, set =>
_.find(set.gearSlots, slot => _.includes(slot.id.toLowerCase(), layer))) > -1;
}
开发者ID:Mehuge,项目名称:Camelot-Unchained,代码行数:5,代码来源:constants.ts
示例20:
return _.filter(datas, (item) => {
return _.findIndex(['#ConstraintViolation', '#ConstraintViolationList'], (needle => needle === item['@id'])) === -1;
});
开发者ID:Simperfit,项目名称:hm-admin,代码行数:3,代码来源:entrypointHelper.ts
注:本文中的lodash.findIndex函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论