Devendra174's picture
Upload folder using huggingface_hub
1e92f2d verified
raw
history blame
580 Bytes
import compact from './compact';
import convertToArrayPayload from './convertToArrayPayload';
import isUndefined from './isUndefined';
function removeAtIndexes<T>(data: T[], indexes: number[]): T[] {
let i = 0;
const temp = [...data];
for (const index of indexes) {
temp.splice(index - i, 1);
i++;
}
return compact(temp).length ? temp : [];
}
export default <T>(data: T[], index?: number | number[]): T[] =>
isUndefined(index)
? []
: removeAtIndexes(
data,
(convertToArrayPayload(index) as number[]).sort((a, b) => a - b),
);