Skip to content

Commit 284e84d

Browse files
committed
Added generator support
1 parent 528ec34 commit 284e84d

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ module.exports = {
4848
'operator-linebreak': ['error', 'after'],
4949
'linebreak-style': 'off',
5050
'no-confusing-arrow': 'off',
51+
'no-restricted-syntax': 'off',
5152
'comma-dangle': 'off',
5253
'arrow-body-style': 'warn',
5354
'max-len': ['error', {

src/memory.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ export default class Memory<T extends Draft> {
2626
return this._docs.delete(_id);
2727
}
2828

29-
all() {
30-
return Array.from(this._docs.values());
29+
docs() {
30+
return this._docs.values();
3131
}
3232

3333
flush() {

src/model.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,7 @@ export default class LeafDB<T extends Draft> {
126126

127127
if (!isQuery(query)) return Promise.reject(INVALID_QUERY(query));
128128

129-
for (let i = 0, docs = this._memory.all(); i < docs.length; i += 1) {
130-
const doc = docs[i];
129+
for (const doc of this._memory.docs()) {
131130
if (!doc.__deleted && isQueryMatch(doc, query)) return Promise.resolve(doc);
132131
}
133132

@@ -147,10 +146,10 @@ export default class LeafDB<T extends Draft> {
147146
}
148147
if (!isQuery(query)) return Promise.reject(INVALID_QUERY(query));
149148

150-
const docs = this._memory.all().reduce<Array<Doc<T>>>((acc, doc) => {
151-
if (!doc.__deleted && isQueryMatch(doc, query)) acc.push(doc);
152-
return acc;
153-
}, []);
149+
const docs: Array<Doc<T>> = [];
150+
for (const doc of this._memory.docs()) {
151+
if (!doc.__deleted && isQueryMatch(doc, query)) docs.push(doc);
152+
}
154153

155154
return Promise.resolve(docs);
156155
}

0 commit comments

Comments
 (0)