Skip to content

Commit

Permalink
Removing superficial/unneeded ops & property
Browse files Browse the repository at this point in the history
  • Loading branch information
avoidwork committed Dec 9, 2020
1 parent e94411e commit d00a01b
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 19 deletions.
13 changes: 6 additions & 7 deletions dist/haro.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ class Haro {
this.index = index;
this.indexes = new Map();
this.key = key;
this.size = 0;
this.versions = new Map();
this.versioning = versioning;

Expand All @@ -113,6 +112,11 @@ class Haro {
get: () => Array.from(this.data.keys())
});

Object.defineProperty(this, "size", {
enumerable: true,
get: () => this.data.size
});

return this.reindex();
}

Expand Down Expand Up @@ -147,7 +151,6 @@ class Haro {

clear () {
this.beforeClear();
this.size = 0;
this.data.clear();
this.indexes.clear();
this.versions.clear();
Expand All @@ -166,7 +169,6 @@ class Haro {
this.beforeDelete(key, batch, lazyLoad, retry);
delIndex(this.index, this.indexes, this.delimiter, key, og);
this.data.delete(key);
--this.size;
this.ondelete(key, batch, retry, lazyLoad);

if (this.versioning) {
Expand Down Expand Up @@ -293,7 +295,6 @@ class Haro {
} else if (type === "records") {
this.indexes.clear();
this.data = new Map(data);
this.size = this.data.size;
} else {
throw new Error("Invalid type");
}
Expand Down Expand Up @@ -365,8 +366,6 @@ class Haro {
this.beforeSet(key, data, batch, override, lazyLoad, retry);

if (this.has(key) === false) {
++this.size;

if (this.versioning) {
this.versions.set(key, new Set());
}
Expand All @@ -392,7 +391,7 @@ class Haro {
}

sort (fn, frozen = true) {
return frozen ? Object.freeze(this.limit(0, this.size, true).sort(fn).map(i => Object.freeze(i))) : this.limit(0, this.size, true).sort(fn);
return frozen ? Object.freeze(this.limit(0, this.data.size, true).sort(fn).map(i => Object.freeze(i))) : this.limit(0, this.data.size, true).sort(fn);
}

sortBy (index, raw = false) {
Expand Down
2 changes: 1 addition & 1 deletion dist/haro.esm.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d00a01b

Please sign in to comment.