refactor: slight performance improvements

This commit is contained in:
thecodrr
2019-12-01 00:13:59 +05:00
parent 66209c7a4b
commit 66ba9c4f9f
2 changed files with 10 additions and 2 deletions

View File

@@ -1,6 +1,7 @@
import Storage from "../helpers/storage";
import fuzzysearch from "fuzzysearch";
import ff from "fast-filter";
import { extractValues } from "../utils";
const KEYS = {
notes: "notes"
@@ -18,7 +19,7 @@ class Database {
async getNotes() {
//update our cache
this.notes = (await this.storage.read(KEYS.notes)) || {};
return Object.values(this.notes);
return extractValues(this.notes);
}
/**
@@ -89,7 +90,7 @@ class Database {
if (!notes) return;
return ff(
notes,
v => fuzzysearch(query, v.title) || fuzzysearch(query, v.content.text),
v => fuzzysearch(query, v.title + " " + v.content.text),
this
);
}