mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-19 04:21:35 +00:00
chore: tidy things up and fix typos
This commit is contained in:
@@ -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>}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user