UNPKG

react-native-drawing

Version:

A React Native library that provides a canvas to perform drawing actions

31 lines (30 loc) 831 B
/** * Manages availability of odentificators */ export class IdAllocator { constructor(checkAvailability) { Object.defineProperty(this, "checkAvailability", { enumerable: true, configurable: true, writable: true, value: checkAvailability }); Object.defineProperty(this, "maxLinealAssigned", { enumerable: true, configurable: true, writable: true, value: Number.MIN_SAFE_INTEGER }); } getFree() { let id; while (id === undefined) { const idCandidate = ++this.maxLinealAssigned; const isAvailable = this.checkAvailability(idCandidate); if (isAvailable) { id = idCandidate; } } return id; } }