Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
* setVal(key, val) {
return co.withSharedContext((context) => {
context[key] = val;
});
}
* getVal(key) {
* registerRollbackListenerAndThrow(listener) {
return co.withSharedContext((context) => {
context.currentTransaction.addRollbackListener(listener);
throw new Error('Exception thrown');
});
}
}
* runMethod1InReadWrite() {
return co.withSharedContext((context) => {
demand(context).is.not.undefined();
demand(context.currentTransaction).is.not.undefined();
context.currentTransaction.isReadonly().must.be.false();
});
}
* setVal(key, val) {
* runMethod1InReadonly() {
return co.withSharedContext((context) => {
demand(context).is.not.undefined();
demand(context.currentTransaction).is.not.undefined();
context.currentTransaction.isReadonly().must.be.true();
});
}
* runMethod1InReadWrite() {
* getVal(key) {
return co.withSharedContext(
(context) =>
context[key]
);
}
* getTransaction() {
* saveTransactionAndThrow() {
return co.withSharedContext((context) => {
context.savedTransaction = context.currentTransaction;
throw new Error('Exception thrown');
});
}
* registerCommitListener(listener) {
* checkTransactionReused() {
return co.withSharedContext(function* (context) {
context.marker1 = 'the value of marker1';
yield TransactionManager.runInTransaction(true, Util.prototype.validateMarker1, this);
});
}
* delegateToReadWriteTransaction() {
* validateMarker1() {
return co.withSharedContext((context) => {
demand(context.marker1).be.not.undefined();
context.marker1.must.be.equal('the value of marker1');
});
}
* checkTransactionStarted() {
* mustBeInTransaction() {
return co.withSharedContext((context) => {
demand(context).is.not.undefined();
demand(context.currentTransaction).is.not.undefined();
});
}
* runMethod1InReadonly() {
* markTransaction() {
return co.withSharedContext((context) => {
context.currentTransaction.myMark = 1;
});
}
* validateNoMarkInTransaction() {