@hangtime/grip-connect
Version:
Griptonite Motherboard, Tindeq Progressor, PitchSix Force Board, WHC-06, Entralpi, Climbro, mySmartBoard: Bluetooth API Force-Sensing strength analysis for climbers
22 lines • 717 B
JavaScript
export class BaseModel {
id;
createdAt;
updatedAt;
constructor(base) {
this.id = base.id ?? globalThis.crypto?.randomUUID?.() ?? BaseModel.generateUUID();
this.createdAt = base.createdAt ?? new Date();
this.updatedAt = base.updatedAt ?? new Date();
}
/**
* Generates a UUID using a simple algorithm.
* @returns A string representing a UUID.
*/
static generateUUID() {
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
const r = Math.floor(Math.random() * 16);
const v = c === "x" ? r : (r & 0x3) | 0x8;
return v.toString(16);
});
}
}
//# sourceMappingURL=base.model.js.map