2024-03-14 21:14:21 +08:00
|
|
|
import type { TransferKey } from '../transfer/interface';
|
|
|
|
|
|
|
|
export const groupKeysMap = (keys: TransferKey[]) => {
|
|
|
|
const map = new Map<TransferKey, number>();
|
2022-12-25 15:21:21 +08:00
|
|
|
keys.forEach((key, index) => {
|
|
|
|
map.set(key, index);
|
|
|
|
});
|
|
|
|
return map;
|
|
|
|
};
|
2022-12-29 18:33:13 +08:00
|
|
|
|
2022-12-25 15:21:21 +08:00
|
|
|
export const groupDisabledKeysMap = <RecordType extends any[]>(dataSource: RecordType) => {
|
2024-03-14 21:14:21 +08:00
|
|
|
const map = new Map<TransferKey, number>();
|
2022-12-25 15:21:21 +08:00
|
|
|
dataSource.forEach(({ disabled, key }, index) => {
|
|
|
|
if (disabled) {
|
|
|
|
map.set(key, index);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return map;
|
|
|
|
};
|