Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update build #256

Merged
merged 1 commit into from Jul 17, 2019
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Large diffs are not rendered by default.

@@ -0,0 +1,47 @@
'use strict';

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));

var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));

var EntryIndex =
/*#__PURE__*/
function () {
function EntryIndex() {
var entries = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
(0, _classCallCheck2.default)(this, EntryIndex);
this._cache = entries;
}

(0, _createClass2.default)(EntryIndex, [{
key: "set",
value: function set(k, v) {
this._cache[k] = v;
}
}, {
key: "get",
value: function get(k) {
return this._cache[k];
}
}, {
key: "delete",
value: function _delete(k) {
return delete this._cache[k];
}
}, {
key: "add",
value: function add(newItems) {
this._cache = Object.assign(this._cache, newItems);
}
}, {
key: "length",
get: function get() {
return Object.values(this._cache).length;
}
}]);
return EntryIndex;
}();

module.exports = EntryIndex;
@@ -40,6 +40,8 @@ var _require2 = require('./utils'),
isDefined = _require2.isDefined,
findUniques = _require2.findUniques;

var EntryIndex = require('./entry-index');

var randomId = function randomId() {
return new Date().getTime().toString();
};
@@ -141,7 +143,7 @@ function (_GSet) {
_this._identity = identity; // Add entries to the internal cache

entries = entries || [];
_this._entryIndex = entries.reduce(uniqueEntriesReducer, {}); // Set heads if not passed as an argument
_this._entryIndex = new EntryIndex(entries.reduce(uniqueEntriesReducer, {})); // Set heads if not passed as an argument

heads = heads || Log.findHeads(entries);
_this._headsIndex = heads.reduce(uniqueEntriesReducer, {}); // Index of all next pointers in this log
@@ -180,7 +182,7 @@ function (_GSet) {
* @returns {Entry|undefined}
*/
value: function get(hash) {
return this._entryIndex[hash];
return this._entryIndex.get(hash);
}
/**
* Checks if a entry is part of the log
@@ -191,7 +193,7 @@ function (_GSet) {
}, {
key: "has",
value: function has(entry) {
return this._entryIndex[entry.hash || entry] !== undefined;
return this._entryIndex.get(entry.hash || entry) !== undefined;
}
}, {
key: "traverse",
@@ -298,7 +300,8 @@ function (_GSet) {
throw new Error("Could not append entry, key \"".concat(this._identity.id, "\" is not allowed to write to the log"));

case 13:
this._entryIndex[entry.hash] = entry;
this._entryIndex.set(entry.hash, entry);

nexts.forEach(function (e) {
return _this3._nextsIndex[e] = entry.hash;
});
@@ -603,7 +606,8 @@ function (_GSet) {

Object.values(newItems).forEach(addToNextsIndex); // Update the internal entry index

this._entryIndex = Object.assign(this._entryIndex, newItems); // Merge the heads
this._entryIndex.add(newItems); // Merge the heads


notReferencedByNewItems = function notReferencedByNewItems(e) {
return !nextsFromNewItems.find(function (a) {
@@ -622,9 +626,10 @@ function (_GSet) {
if (size > -1) {
tmp = this.values;
tmp = tmp.slice(-size);
this._entryIndex = tmp.reduce(uniqueEntriesReducer, {});
this._entryIndex = null;
this._entryIndex = new EntryIndex(tmp.reduce(uniqueEntriesReducer, {}));
this._headsIndex = Log.findHeads(tmp).reduce(uniqueEntriesReducer, {});
this._length = Object.values(this._entryIndex).length;
this._length = this._entryIndex.length;
} // Find the latest clock from the heads


ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.