js-draw
Version:
Draw pictures using a pen, touchscreen, or mouse! JS-draw is a drawing library for JavaScript and TypeScript.
16 lines (15 loc) • 478 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
/** 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;
};
exports.default = getUniquePointerId;
;