Skip to content

Commit

Permalink
Updates typing.
Browse files Browse the repository at this point in the history
  • Loading branch information
queercat committed Jan 13, 2024
1 parent 846d112 commit e06365e
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions docusnore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@ export class Docusnore {
public async initStore() {
this.hasInit = false;

await fs.writeFile(this.fileLocation, "{}", {flag: "wx"});
try {
await fs.writeFile(this.fileLocation, "{}", {flag: "wx"});
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (error: any) {
if (error.code !== "EEXIST") {
throw error;
}
}

this.hasInit = true;
}
Expand Down Expand Up @@ -147,7 +154,7 @@ export class Docusnore {
* @param filter the filter to apply to the key, if any.
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
public async update<T extends object = any>(key: string, value: object | ((item: T) => object), filter: (item: T) => boolean) {
public async update<T extends object = any>(key: string, value: T | ((item: T) => T), filter: (item: T) => boolean) {
const data = await this.read();
const updated = data[key].map((item: T) => {
if (filter(item)) {
Expand Down Expand Up @@ -231,6 +238,4 @@ export class Docusnore {

await this.write(data);
}
}

module.exports = Docusnore;
}

0 comments on commit e06365e

Please sign in to comment.