feat(seh2g): replace lodash by JS

This commit is contained in:
2020-12-30 20:28:54 +01:00
parent 173b435731
commit f5a260c229

View File

@@ -11,7 +11,6 @@
href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.5/css/bulma.min.css" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.5/css/bulma.min.css"
/> />
<script src="https://unpkg.com/vue"></script> <script src="https://unpkg.com/vue"></script>
<script src="https://cdn.jsdelivr.net/npm/lodash@4.17.15/lodash.min.js"></script>
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1" />
</head> </head>
@@ -106,18 +105,16 @@
}, },
computed: { computed: {
results() { results() {
return _.filter(this.books, this.bookMatches); return this.books.filter(this.bookMatches);
}, },
}, },
methods: { methods: {
bookMatches(book) { bookMatches(book) {
if (this.search.length < 3) { return this.search.length < 3
return false; ? false
} else : JSON.stringify(book)
return _.includes( .toLowerCase()
_.toLower(_.toLower(JSON.stringify(book))), .includes(this.search.toLowerCase());
_.toLower(_.toLower(this.search))
);
}, },
renderBook(book) { renderBook(book) {
const text = ` const text = `
@@ -130,7 +127,7 @@
const searchPattern = new RegExp(`${this.search}`, "gi"); const searchPattern = new RegExp(`${this.search}`, "gi");
return _.replace(text, searchPattern, (x) => `<b>${x}</b>`); return text.replace(searchPattern, (x) => `<b>${x}</b>`);
}, },
}, },
}); });