本文整理汇总了TypeScript中@devexpress/dx-core.slice函数的典型用法代码示例。如果您正苦于以下问题:TypeScript slice函数的具体用法?TypeScript slice怎么用?TypeScript slice使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了slice函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: default
export default (
array: any[] | ReadonlyArray<any>,
compare: CompareFn = (a, b): number => {
if (a < b) return -1;
if (a > b) return 1;
return 0;
},
) => {
const result = slice(array);
const auxiliary = slice(array);
sortAuxiliaryToArray(result, auxiliary, 0, result.length - 1, compare);
return result;
};
示例2: Set
export const tableRowsWithEditing: TableRowsWithEditingFn = (
tableRows, editingRowIds, addedRows, rowHeight,
) => {
const rowIds = new Set(editingRowIds);
const editedTableRows = tableRows
.map(tableRow => (
tableRow.type === TABLE_DATA_TYPE && rowIds.has(tableRow.rowId!)
? {
...tableRow,
type: TABLE_EDIT_TYPE,
height: rowHeight,
}
: tableRow
));
const addedTableRows = addedRows
.map((row, rowIndex) => ({
row,
key: `${TABLE_ADDED_TYPE.toString()}_${rowIndex}`,
type: TABLE_ADDED_TYPE,
rowId: rowIndex,
height: rowHeight,
}));
return [
...slice(addedTableRows).reverse(),
...editedTableRows,
];
};
示例3: getFixedColumnKeys
export const calculateFixedColumnProps: CalculateFixedColumnPropsFn = (
{ tableColumn },
{ leftColumns, rightColumns },
tableColumns,
tableColumnDimensions,
tableHeaderColumnChains,
) => {
const side = tableColumn.fixed!;
const targetArray = side === FIXED_COLUMN_LEFT_SIDE
? getFixedColumnKeys(tableColumns, leftColumns)
: slice(getFixedColumnKeys(tableColumns, rightColumns)).reverse();
const index = tableColumns.findIndex(({ key }) => key === tableColumn.key);
const fixedIndex = targetArray.indexOf(tableColumn.key);
const columnChain = findChainByColumnIndex(tableHeaderColumnChains[0], index)!;
const showLeftDivider = columnChain.start === index && index !== 0;
const showRightDivider = columnChain.start + columnChain.columns.length - 1 === index
&& index < tableColumns.length - 1;
const position = calculatePosition(targetArray, fixedIndex, tableColumnDimensions);
return {
showRightDivider,
showLeftDivider,
position,
side,
};
};
示例4: slice
export const changeColumnOrder: PureReducer<ColumnOrder, ChangeColumnOrderPayload> = (
order, { sourceColumnName, targetColumnName },
) => {
const sourceColumnIndex = order.indexOf(sourceColumnName);
const targetColumnIndex = order.indexOf(targetColumnName);
const newOrder = slice(order);
newOrder.splice(sourceColumnIndex, 1);
newOrder.splice(targetColumnIndex, 0, sourceColumnName);
return newOrder;
};
示例5: slice
export const draftOrder: DraftOrderComputed = (order, sourceColumnIndex, targetColumnIndex) => {
if (sourceColumnIndex === -1
|| targetColumnIndex === -1
|| sourceColumnIndex === targetColumnIndex) {
return order;
}
const result = slice(order);
const sourceColumn = order[sourceColumnIndex];
result.splice(sourceColumnIndex, 1);
result.splice(targetColumnIndex, 0, sourceColumn);
return result;
};