js-draw
Version:
Draw pictures using a pen, touchscreen, or mouse! JS-draw is a drawing library for JavaScript and TypeScript.
14 lines (13 loc) • 398 B
JavaScript
/** Returns the smallest ID not used by the pointers in the given list. */
const getUniquePointerId = (pointers) => {
let ptrId = 0;
const pointerIds = pointers.map((ptr) => ptr.id);
pointerIds.sort();
for (const pointerId of pointerIds) {
if (ptrId === pointerId) {
ptrId = pointerId + 1;
}
}
return ptrId;
};
export default getUniquePointerId;