Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
setItem: (id, item) => persist.set(id, item),
getAllKeys: () => Promise.resolve(persist.keys()),
async add(target: Target$) {
const self = this;
_.remove(
this.repositories,
repo =>
repo.source === target.source &&
repo.owner === target.owner &&
repo.name === target.name &&
repo.path === target.path
);
self.repositories.push(target);
await storage.set(self.key, self.repositories);
}
async clean() {
this.repositories = [];
await storage.set(this.key, this.repositories);
}
async remove(target: Target$) {
let before = this.repositories.slice();
_.remove(
this.repositories,
repo =>
repo.source === target.source &&
repo.owner === target.owner &&
repo.name === target.name &&
repo.path === target.path
);
const after = this.repositories;
if (!_.isEqual(before, after)) {
await storage.set(this.key, this.repositories);
}
}