Use let and const
This commit is contained in:
parent
19cd5c8881
commit
a9ea1a02ed
@ -1,15 +1,15 @@
|
|||||||
import makeError from 'make-error';
|
import makeError from 'make-error';
|
||||||
|
|
||||||
var IllegalId = makeError('IllegalId');
|
const IllegalId = makeError('IllegalId');
|
||||||
var OverrideViolation = makeError('OverrideViolation');
|
const OverrideViolation = makeError('OverrideViolation');
|
||||||
var NotFound = makeError('NotFound');
|
const NotFound = makeError('NotFound');
|
||||||
var TransactionAlreadyOpened = makeError('TransactionAlreadyOpened');
|
const TransactionAlreadyOpened = makeError('TransactionAlreadyOpened');
|
||||||
var NoTransactionOpened = makeError('NoTransactionOpened');
|
const NoTransactionOpened = makeError('NoTransactionOpened');
|
||||||
var FailedRollback = makeError('FailedRollback');
|
const FailedRollback = makeError('FailedRollback');
|
||||||
var FailedReplay = makeError('FailedReplay');
|
const FailedReplay = makeError('FailedReplay');
|
||||||
var UnrecognizedTransactionItem = makeError('UnrecognizedTransactionItem');
|
const UnrecognizedTransactionItem = makeError('UnrecognizedTransactionItem');
|
||||||
var UnexpectedLogFormat = makeError('UnexpectedLogFormat');
|
const UnexpectedLogFormat = makeError('UnexpectedLogFormat');
|
||||||
var UnexpectedLogItemData = makeError('UnexpectedLogItemData');
|
const UnexpectedLogItemData = makeError('UnexpectedLogItemData');
|
||||||
|
|
||||||
class Collection {
|
class Collection {
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ class Collection {
|
|||||||
throw new NoTransactionOpened('No opened transaction to commit.');
|
throw new NoTransactionOpened('No opened transaction to commit.');
|
||||||
}
|
}
|
||||||
|
|
||||||
let transactionLog = this._transaction;
|
const transactionLog = this._transaction;
|
||||||
this._transaction = null;
|
this._transaction = null;
|
||||||
|
|
||||||
if ('function' === typeof callback) {
|
if ('function' === typeof callback) {
|
||||||
@ -87,7 +87,7 @@ class Collection {
|
|||||||
throw new NoTransactionOpened('No opened transaction to rollback.');
|
throw new NoTransactionOpened('No opened transaction to rollback.');
|
||||||
}
|
}
|
||||||
|
|
||||||
let log = this._transaction;
|
const log = this._transaction;
|
||||||
this._transaction = null;
|
this._transaction = null;
|
||||||
|
|
||||||
return this._rollback(log, callback);
|
return this._rollback(log, callback);
|
||||||
@ -113,7 +113,7 @@ class Collection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let item;
|
let item;
|
||||||
let done = [];
|
const done = [];
|
||||||
|
|
||||||
while(item = log.pop()) {
|
while(item = log.pop()) {
|
||||||
try {
|
try {
|
||||||
@ -139,7 +139,7 @@ class Collection {
|
|||||||
|
|
||||||
done.unshift(item);
|
done.unshift(item);
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
let exc = new FailedRollback(
|
const exc = new FailedRollback(
|
||||||
'Rollback failed on index ' + log.lenght + '.'
|
'Rollback failed on index ' + log.lenght + '.'
|
||||||
);
|
);
|
||||||
exc.undone = log;
|
exc.undone = log;
|
||||||
@ -178,7 +178,7 @@ class Collection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let item;
|
let item;
|
||||||
let done = [];
|
const done = [];
|
||||||
|
|
||||||
while(item = log.shift()) {
|
while(item = log.shift()) {
|
||||||
try {
|
try {
|
||||||
@ -204,7 +204,7 @@ class Collection {
|
|||||||
|
|
||||||
done.push(item);
|
done.push(item);
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
let exc = new FailedReplay(
|
const exc = new FailedReplay(
|
||||||
'Replay failed on index ' + done.lenght + '.'
|
'Replay failed on index ' + done.lenght + '.'
|
||||||
);
|
);
|
||||||
exc.undone = log;
|
exc.undone = log;
|
||||||
@ -242,7 +242,7 @@ class Collection {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let checkFormer = () => {
|
const checkFormer = () => {
|
||||||
if (!item.hasOwnProperty('former')) {
|
if (!item.hasOwnProperty('former')) {
|
||||||
throw new UnexpectedLogItemData(
|
throw new UnexpectedLogItemData(
|
||||||
'Missing former item in ' + item.action + ' object.'
|
'Missing former item in ' + item.action + ' object.'
|
||||||
@ -250,7 +250,7 @@ class Collection {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let checkItem = () => {
|
const checkItem = () => {
|
||||||
if (!item.hasOwnProperty('item')) {
|
if (!item.hasOwnProperty('item')) {
|
||||||
throw new UnexpectedLogItemData(
|
throw new UnexpectedLogItemData(
|
||||||
'Missing item in ' + item.action + ' object.'
|
'Missing item in ' + item.action + ' object.'
|
||||||
@ -332,7 +332,7 @@ class Collection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
let former = this._collection[id];
|
const former = this._collection[id];
|
||||||
|
|
||||||
this._collection[id] = item;
|
this._collection[id] = item;
|
||||||
|
|
||||||
@ -375,7 +375,7 @@ class Collection {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let former = this._collection[id];
|
const former = this._collection[id];
|
||||||
|
|
||||||
delete this._collection[id];
|
delete this._collection[id];
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user