This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function memoize(callback) { | |
const cache = new Map(); | |
return (...args) => { | |
const strArgs = String(args) | |
if (cache.has(strArgs)) { | |
return String(cache.get(strArgs));; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PaginationHelper { | |
constructor(collection, itemsPerPage) { | |
this.collection = collection; | |
this.itemsPerPage = itemsPerPage; | |
} | |
itemCount() { | |
return this.collection.length; | |
} | |
pageCount() { | |
return Math.ceil(this.itemCount() / this.itemsPerPage); |