UNPKG

typeorm-pglite

Version:
46 lines (45 loc) 1.96 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.PGliteInstance = void 0; exports.getPGliteInstance = getPGliteInstance; const pglite_1 = require("@electric-sql/pglite"); class PGliteInstance { static getInstance() { return __awaiter(this, void 0, void 0, function* () { if (!PGliteInstance.instance) { if (!PGliteInstance.options) { console.warn("PGlite constructor options are not provided. Creating instance with default options."); } PGliteInstance.instance = yield pglite_1.PGlite.create(PGliteInstance.options); } return PGliteInstance.instance; }); } static setOptions(options) { PGliteInstance.options = options; } static close() { return __awaiter(this, void 0, void 0, function* () { if (PGliteInstance.instance) { yield PGliteInstance.instance.close(); PGliteInstance.instance = null; } }); } } exports.PGliteInstance = PGliteInstance; PGliteInstance.instance = null; function getPGliteInstance() { return __awaiter(this, void 0, void 0, function* () { return PGliteInstance.getInstance(); }); }