chore: tidy things up and fix typos

This commit is contained in:
LuanRT
2022-07-06 23:47:38 -03:00
parent 021a7fd97a
commit 9c97434e5e
5 changed files with 21 additions and 24 deletions

View File

@@ -1,12 +1,9 @@
'use strict';
const fs = require('fs');
class NodeCache {
constructor() {
}
/**
*
* @param {string} key
* @returns {Promise<ArrayBuffer>}
*/
@@ -15,7 +12,6 @@ class NodeCache {
}
/**
*
* @param {string} key
* @param {ArrayBuffer} data
* @returns {Promise<void>}
@@ -23,19 +19,21 @@ class NodeCache {
async write(key, data) {
// Make sure the directory exists
const parts = key.split('/').slice(0, -1);
let current = '';
for (let i = 0; i < parts.length; i++) {
current += `${parts[i]}/`;
for (const part of parts) {
current += `${part}/`;
if (!(await this.exists(current))) {
await fs.promises.mkdir(current);
}
}
return await fs.promises.writeFile(key, data);
}
/**
*
* @param {string} key
* @returns {Promise<boolean>}
*/
@@ -44,7 +42,6 @@ class NodeCache {
}
/**
*
* @param {string} key
* @returns {Promise<void>}
*/