mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Prefer arrow functions and callbacks (#1210)
This commit is contained in:
parent
33fe223b5d
commit
c427aa3cce
64 changed files with 784 additions and 847 deletions
|
@ -49,35 +49,30 @@ export {
|
|||
} from "./sizeHelpers";
|
||||
export { showSelectedShapeActions } from "./showSelectedShapeActions";
|
||||
|
||||
export function getSyncableElements(elements: readonly ExcalidrawElement[]) {
|
||||
// There are places in Excalidraw where synthetic invisibly small elements are added and removed.
|
||||
export const getSyncableElements = (
|
||||
elements: readonly ExcalidrawElement[], // There are places in Excalidraw where synthetic invisibly small elements are added and removed.
|
||||
) =>
|
||||
// It's probably best to keep those local otherwise there might be a race condition that
|
||||
// gets the app into an invalid state. I've never seen it happen but I'm worried about it :)
|
||||
return elements.filter((el) => el.isDeleted || !isInvisiblySmallElement(el));
|
||||
}
|
||||
elements.filter((el) => el.isDeleted || !isInvisiblySmallElement(el));
|
||||
|
||||
export function getElementMap(elements: readonly ExcalidrawElement[]) {
|
||||
return elements.reduce(
|
||||
export const getElementMap = (elements: readonly ExcalidrawElement[]) =>
|
||||
elements.reduce(
|
||||
(acc: { [key: string]: ExcalidrawElement }, element: ExcalidrawElement) => {
|
||||
acc[element.id] = element;
|
||||
return acc;
|
||||
},
|
||||
{},
|
||||
);
|
||||
}
|
||||
|
||||
export function getDrawingVersion(elements: readonly ExcalidrawElement[]) {
|
||||
return elements.reduce((acc, el) => acc + el.version, 0);
|
||||
}
|
||||
export const getDrawingVersion = (elements: readonly ExcalidrawElement[]) =>
|
||||
elements.reduce((acc, el) => acc + el.version, 0);
|
||||
|
||||
export function getNonDeletedElements(elements: readonly ExcalidrawElement[]) {
|
||||
return elements.filter(
|
||||
export const getNonDeletedElements = (elements: readonly ExcalidrawElement[]) =>
|
||||
elements.filter(
|
||||
(element) => !element.isDeleted,
|
||||
) as readonly NonDeletedExcalidrawElement[];
|
||||
}
|
||||
|
||||
export function isNonDeletedElement<T extends ExcalidrawElement>(
|
||||
export const isNonDeletedElement = <T extends ExcalidrawElement>(
|
||||
element: T,
|
||||
): element is NonDeleted<T> {
|
||||
return !element.isDeleted;
|
||||
}
|
||||
): element is NonDeleted<T> => !element.isDeleted;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue