miter
Version:
A typescript web framework based on ExpressJs based loosely on SailsJs
45 lines • 1.73 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
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) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
class FakeTransaction {
constructor(name, parentTransaction) {
this.parentTransaction = parentTransaction;
this._complete = false;
this._name = name;
}
get name() {
return this._name;
}
get fullName() {
if (!this.parentTransaction)
return this.name;
else
return `${this.parentTransaction.fullName}.${this.name}`;
}
get isComplete() {
return this._complete;
}
rollback() {
return __awaiter(this, void 0, void 0, function* () {
if (this.isComplete)
throw new Error(`Cannot sync a transaction that has completed!`);
this._complete = true;
});
}
commit() {
return __awaiter(this, void 0, void 0, function* () {
if (this.isComplete)
throw new Error(`Cannot sync a transaction that has completed!`);
this._complete = true;
});
}
}
exports.FakeTransaction = FakeTransaction;
//# sourceMappingURL=fake-transaction.js.map