Skip to content

Commit

Permalink
changed sorting a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
USERSATOSHI committed Jan 29, 2024
1 parent 6871dba commit f9fc00f
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 31 deletions.
2 changes: 1 addition & 1 deletion dist/cjs/KeyValue/src/newtable.d.ts.map

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

18 changes: 9 additions & 9 deletions dist/cjs/KeyValue/src/newtable.js

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

2 changes: 1 addition & 1 deletion dist/cjs/KeyValue/src/newtable.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/esm/KeyValue/src/newtable.d.ts.map

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

18 changes: 9 additions & 9 deletions dist/esm/KeyValue/src/newtable.js

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

2 changes: 1 addition & 1 deletion dist/esm/KeyValue/src/newtable.js.map

Large diffs are not rendered by default.

21 changes: 12 additions & 9 deletions lib/KeyValue/src/newtable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -732,15 +732,18 @@ Attempting to repair file ${fileObj.name} in table ${

if (order === "firstN") return this.getFirstN(query, limit);

const matchedData = await this.findMany(query);
if (order === "asc")
return matchedData
.sort(this.#db.options.cacheConfig.sortFunction)
.slice(0, limit);
else
return matchedData
.sort(this.#db.options.cacheConfig.sortFunction)
.slice(-limit);
let matchedData = await this.findMany(query);
if (order === "asc") {
matchedData = matchedData.sort((a, b) =>
this.#db.options.cacheConfig.sortFunction(a, b)
);
return matchedData.slice(0, limit);
} else {
matchedData = matchedData.sort((a, b) =>
this.#db.options.cacheConfig.sortFunction(b, a)
);
return matchedData.slice(0, limit);
}
}
async findOne(query: (d: Data) => boolean) {
if (this.locked)
Expand Down

0 comments on commit f9fc00f

Please sign in to comment.