Skip to content

Commit 85ec16c

Browse files
authored
core/adapter: use findIndex() (#8791)
Replace `.map(...).indexOf(...)` with `.findIndex(...)`.
1 parent 60bf102 commit 85ec16c

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

packages/node_modules/pouchdb-core/src/adapter.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -598,8 +598,7 @@ class AbstractPouchDB extends EventEmitter {
598598

599599
for (var i = 0; i < paths.length; i++) {
600600
var currentPath = paths[i];
601-
var hashIndex = currentPath.ids.map(function (x) { return x.id; })
602-
.indexOf(revHash);
601+
const hashIndex = currentPath.ids.findIndex(x => x.id === revHash);
603602
var hashFoundAtRevPos = hashIndex === (revNo - 1);
604603

605604
if (hashFoundAtRevPos || (!path && hashIndex !== -1)) {
@@ -614,8 +613,8 @@ class AbstractPouchDB extends EventEmitter {
614613
return cb(err);
615614
}
616615

617-
var indexOfRev = path.ids.map(function (x) { return x.id; })
618-
.indexOf(doc._rev.split('-')[1]) + 1;
616+
const pathId = doc._rev.split('-')[1];
617+
const indexOfRev = path.ids.findIndex(x => x.id === pathId) + 1;
619618
var howMany = path.ids.length - indexOfRev;
620619
path.ids.splice(indexOfRev, howMany);
621620
path.ids.reverse();

0 commit comments

Comments
 (0)