本文整理匯總了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;
};