mirror of
https://github.com/webstudio-is/webstudio.git
synced 2026-11-08 04:55:06 +09:00
Ref https://github.com/webstudio-is/webstudio-builder/issues/696 One more diff to support better conflict resolution in breakpoints patches. Breakpoints is now map and patches rely on keys instead of array indexes.
14 lines
336 B
TypeScript
14 lines
336 B
TypeScript
type Predicate<Item> = (value: Item) => boolean;
|
|
|
|
export const removeByMutable = <Item>(
|
|
array: Item[],
|
|
predicate: Predicate<Item>
|
|
) => {
|
|
// reversed order to splice without breaking index
|
|
for (let index = array.length - 1; index >= 0; index -= 1) {
|
|
if (predicate(array[index])) {
|
|
array.splice(index, 1);
|
|
}
|
|
}
|
|
};
|